rn14 Posted February 14, 2007 Share Posted February 14, 2007 Im attempting to disable the text field amount. The value is passed from a form on a previous page. I need to the field to be disabled when the form is opened. Any suggestions?? <html> <head> <script type="text/javascript"> function disableField() { document.getElementById("amount").disabled=true } </script> </head> <body><form> <input type="text" id="amount" value="<?echo $amount;?>" /> value="Disable text field" /> </form></body> </html> Quote Link to comment Share on other sites More sharing options...
effigy Posted February 14, 2007 Share Posted February 14, 2007 Use <body onload="disableField()">, or call the function through the script tags. Quote Link to comment Share on other sites More sharing options...
rn14 Posted February 14, 2007 Author Share Posted February 14, 2007 for some reason that doesnt seem to work. where will i place the script tags? Sorry begginner here Quote Link to comment Share on other sites More sharing options...
effigy Posted February 14, 2007 Share Posted February 14, 2007 Within the head tag, or in the body after the element. Do you really need javascript here? Can you not echo these values out with the HTML (<input ... disabled="disabled"/>)? Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.