![]() |
Javascript debugging
I hate javascript debugging because it is so non specific when you have an error... Anyway here is my script I am having trouble with... (I am getting an error saying I am "missing ; before statement" Please Help
onclick=" if(document.form2.shipfax.value=='Shipper Fax') { document.form2.shipfax.value='Shipper Fax <--- REQUIRED'; document.form2.shipfax.style.color='red'; document.form2.shipfax.onfocus=' if(document.form2.shipfax.value=='Shipper Fax <--- REQUIRED') { document.form2.shipfax.value=''; document.form2.shipfax.style.color='black'; };'; document.form2.shipfax.onblur=' if(document.form2.shipfax.value=='') { document.form2.shipfax.value='Shipper Fax <--- REQUIRED'; document.form2.shipfax.style.color='red'; };'; };" |
Please investigate the use of code tags, in order to retain your formatting and indentation. You'll find this mentioned in the rules/faq and the "How to Post a Question" thread.
|
It looks like you have quotes inside your quotes, so to speak, and some odd placement of semicolons. Strictly speaking, though, you shouldn't need to quote any code at all.
Now, it appears as if you want all required values to show up in red, and then to change to black when the user clicks on them. However, you only seem to be doing this for one field, and it seems possible there might be several required fields. Could you perhaps explain exactly what it is you're trying to do? You might be going about it the hard way. For reference, here's a version of your code that uses functions, rather than strings of executable code. However, I think that there might be an easier way to do what you're trying to achieve. :
|
| All times are GMT -5. The time now is 8:19 PM. |
Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC