Click to See Complete Forum and Search --> : Javascript Character Problem
AssGoblin
07-31-2003, 07:56 PM
I have a simple Javascript syntax problem. The code goes like this:
<select name=choice_5201:location class="small" onChange="document.xerox.email_notification.value=center[choice_5201:location.options[selectedIndex].value];">
My code DOES NOT work becuase it has a COLON in it...How do I escape the colon.. i cannot remove the colon do to DB restrictions. I tried choice_5201\:location but that did not work.
Any ideas?
Thank you in advance
gil davis
07-31-2003, 09:46 PM
According to the W3C:
ID and NAME tokens must begin with a letter ([A-Za-z]) and may be followed by any number of letters, digits ([0-9]), hyphens ("-"), underscores ("_"), colons (":"), and periods (".").Colons are legal as long as they are not the first character. Your browser apparently thinks otherwise. Try placing quotes around the declaration. They should be there anyway.
<select name="choice_5201:location" ...>
The problem is not with the naming convention, but with javascirpt trying to reference names with colons in them. What you need to do is reference them using the forms elements array, something like this:
<form name="xerox">
<select name="choice_5021:location" onchange="document.xerox.email_notification.value = document.xerox.elements['choice_5021:location'].options[document.xerox.elements['choice_5021:location'].selectedIndex].value;">
<option value="0">Zero</option>
<option value="1">One</option>
</select>
<input type="text" name="email_notification">
</form>
AssGoblin
08-01-2003, 01:46 PM
If there was a way I could electornically kiss i Would!
It worked!!!
Thanks sooo much!
lol...
Appreciative people make my day. :)