php - javascript replace with regular expression not working -


i have breadcrumb system generated php , set make last item of breadcrumb not link. i'm using 3rd party php class create this. without going depth fine except in 1 situation want grab value query , append value on breadcrumb. 3rd party php class last item last 1 generated php class , because of not have link around need.

therefore, want grab last item generated php class javascript , make link, , append value query using javascript breadcrumbs without link.

basically breadcrumb should @ it's final stage:

<h4><link>client</link> / <link>year</link> / <link>project</link> / asset</h4> 

so need grab "project" , make link , append asset name (getting value php get).

i'm trying use javascript's replace function accomplish this.

my code right now:

        var title = "<?php echo $_get['asset'];?>";//get php variable         var value = document.getelementbyid("bread-crumbs").innerhtml; //<h4 id="bread-crumbs">content</h4>          var stripval = value.replace(/(<([^>]+)>)/ig,"");//remove html link tags          var n = stripval.lastindexof('/');//grab item after last / (projectname)         var searchfor = stripval.substring(n + 1); //project folder name          //alert(stripval);         var re = new regexp(searchfor,"g"); //create regex holds last item value                   //replace value itself, except wrapped in href           value = value.replace(re, "<a href='index.php'>"+searchfor+"</a>");          //append title end of breadcrumb                  var newvalue = value.concat('<span class="dir-slash"> / </span> ' + title);          //replace html updated markup         document.getelementbyid("bread-crumbs").innerhtml = newvalue; 

unfortunately doesn't seem work @ all. there standing out i'm messing on? sorry long winded post. i'm not great @ explaining programming sometimes.

thanks!


Comments

Popular posts from this blog

matlab - Deleting rows with specific rules -

jquery - How would i go about shortening this code? And to cancel the previous click on click of new section? -