hello,
I am a fairly experienced programmer, but new to javascript. I have written the following script (simplified, of course) that works. the strings are all dynamically generated by php based on database queries, and the function is called by an onclick method which currently passes in a number. My biggest problem is that while there is currently only about 5 or 10 different strings maximum, that number could concievably rise to 100. My question is, Is there a different way to do it?
I tried calling
[CODE]writeNote(str3)
and then
[CODE]document.getElementById(“dynamic”).innerHTML = str3;
but I couldn’t make that work.
Thanks
Ray
p.s. I am aware that page load speed could be affected if I try to pass in 100 strings, especially if they are very big. I am watching it.
[CODE]
function writeNote(num)
{
str1=”<p>Text 1</p>”;
switch(num)
{
case ‘1’:
var outstr=str1
break;
default:
var outstr='<p>default text</p>’
}
document.getElementById(“dynamic”).innerHTML = outstr;
}