Hi, I'm looking for some help.

I need to add the letter "a" to the id of an option. The content is dynamic but you will get the idea from below.

Any help would really be great. Thanks

e.g.

<script type="text/javascript"> 
	function Toggle(id) { 
	document.getElementById("a18").style.display = "none"; 
	document.getElementById("a19").style.display = "none"; 
	document.getElementById("a20").style.display = "none";
	document.getElementById(id).style.display = "block"; } // need to add "a" to the id
	</script>  

<html>
<input type="radio" name="abc"  onClick="Toggle(a18);" value="a18"> //18 is the id from the database
<input type="radio" name="abc"  onClick="Toggle(a19);" value="a19">//19 is the id from the database
<input type="radio" name="abc"  onClick="Toggle(a20);" value="a20">//20 is the id from the database

<div id="a18" style="float:left; display: none; margin:9px 0px 0px 30px;">
<img src="images/a18.png"></div> 

<div id="a19" style="float:left; display: none; margin:9px 0px 0px 30px;">
<img src="images/a19.png"></div> 

<div id="a20" style="float:left; display: none; margin:9px 0px 0px 30px;">
<img src="images/a20.png"></div> 
</html>

Recommended Answers

All 2 Replies

Looking at the code snippet posted by you, I dont think you need to append 'a' as you are already passing parameters like 'a19', 'a20'.....etc in the Toggle() function.
Only thing is that pass them as a string as shown in eg below

...
<input type="radio" name="abc"  onClick="Toggle('a18');" value="a18"> //18 is the id from the database
....

Hope this was helpful

Thanks, that makes sense.

Much appreciated.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.