Ok So im trying to add an id to a link example:
<a href="http://google.com/stats.php?go=normal">normal</a>
<a href="http://google.com/stats.php?go=normalmedium">normal medium</a>
<a href="http://google.com/stats.php?go=normalmediumhigh">normal medium high</a>
<a href="http://google.com/stats.php?go=normalhigh">normal high</a>
<a href="http://google.com/stats.php?go=superhigh">super high</a>
by default the links are like this but if they click on let say a button or link like this:
<a href="#" onclick="changeIt('bnone9099');>burner one</a>
<a href="#" onclick="changeIt('bnone9034');>burner two</a>
<a href="#" onclick="changeIt('bnone9098');>burner three</a>
when they click on one of the links it should add an id like this example if they click “burner one” :
<a href="http://google.com/stats.php?go=normal&id=bnone9099">normal</a>
<a href="http://google.com/stats.php?go=normalmedium&id=bnone9099">normal medium</a>
<a href="http://google.com/stats.php?go=normalmediumhigh&id=bnone9099">normal medium high</a>
<a href="http://google.com/stats.php?go=normalhigh&id=bnone9099">normal high</a>
<a href="http://google.com/stats.php?go=superhigh&id=bnone9099">super high</a>
and so on and if they click
<a href="#" onclick="changeIt('back');>default</a>
it should change the links back to normal like this
<a href="http://google.com/stats.php?go=normal">normal</a>
<a href="http://google.com/stats.php?go=normalmedium">normal medium</a>
<a href="http://google.com/stats.php?go=normalmediumhigh">normal medium high</a>
<a href="http://google.com/stats.php?go=normalhigh">normal high</a>
<a href="http://google.com/stats.php?go=superhigh">super high</a>
i hope this example is not too complicated! thanks 🙂
and html…
and…
Explanation of the above code.
We are creating a new object of “changer()”, in the changeIt class, we are passing two arguments – the first is the id of the link who’s id is to be edited, and the second one is the value’s/id’s data.
we are keeping the changed links into an array called changedArr, and when back is clicked (triggered because it sents ‘back’ as the second argument), we are doing a for-loop in the changedArr, and remove everything that follows the last occurance of &…. (which is always in this situation the id arg)
You can see a working example here,
http://jsfiddle.net/H2YHw/