| | |
Accessing Non-form Variables
Please support our JavaScript / DHTML / AJAX advertiser: PostgreSQL or MySQL? Compare and contrast the two most popular open source databases
![]() |
JavaScript / DHTML / AJAX Syntax (Toggle Plain Text)
<html> <head> <meta http-equiv="Content-Type"content="text/html; charset=windows-1254"> <title>JavaScript</title> </head> <body bgcolor="#000000" text="#ffffff" vlink="#99FF33" link="#FF99FF"> <script language="javascript"> function ShowValue() { document.TextBox.value = "You clicked the button."; //Error on this line } </script> <input type="text" name="TextBox" width="128"><br> <input type="button" name="Show" value="Show" onClick="ShowValue();"> </body> </html>
For reasons that are beyond my understanding, we are being moved into the whole new era of having to give things ID's. If someone knows another way, simplier, using names, please let me know, but try this:
JavaScript / DHTML / AJAX Syntax (Toggle Plain Text)
<html> <head> <meta http-equiv="Content-Type"content="text/html; charset=windows-1254"> <title>JavaScript</title> <script language="javascript"> function ShowValue() { document.getElementById("TextBox").value = "You clicked the button."; } </script> </head> <body bgcolor="#000000" text="#ffffff" vlink="#99FF33" link="#FF99FF"> <input type="text" ID="TextBox" name="TextBox" width="128"><br> <input type="button" name="Show" value="Show" onClick="ShowValue();"> </body> </html>
•
•
Join Date: Dec 2004
Posts: 1,655
Reputation:
Solved Threads: 35
Well, you don't show any DOCTYPE, so we, and your browser, have no idea of which Document Object Model to use. "document.Textbox" may or may not be meaningful in any particular browser's default HTML version/DOM.
You simply must declare a proper DOCTYPE, and then work within that Object Model.
Both "document.getElementById()" and "document.getElementByName()" are perfectly valid methods within their DOMs.
You simply must declare a proper DOCTYPE, and then work within that Object Model.
Both "document.getElementById()" and "document.getElementByName()" are perfectly valid methods within their DOMs.
![]() |
Similar Threads
- Send form inputs to email address (PHP)
- Accessing objects that are not in the form fields (JavaScript / DHTML / AJAX)
- cdoMessage.To=Request.Form("email") (ASP)
- PHP, ASP, ColdFusion, what's your fav? (IT Professionals' Lounge)
- Unable to insert form data into a database (ASP)
- help with creating form counter (PHP)
- Zend PHP Certification (PHP)
Other Threads in the JavaScript / DHTML / AJAX Forum
- Previous Thread: Help w (document.lastModified)
- Next Thread: JavaScript for uploading images to website
Views: 2432 | Replies: 2
| Thread Tools | Search this Thread |
Tag cloud for JavaScript / DHTML / AJAX
acid2 ajax ajaxexample ajaxjspservlets array autoplay blackjack browser captcha captchaformproblem cart close codes css date debugger decimal dependent design developer disablefirebug dom download element embed engine enter error events ext file firefox flash focus form frameworks game gears getselection google gxt hiddenvalue highlightedword hint html ie7 iframe index java javascript javascripthelp2020 javascripts jquery jsp libcurl listbox maps margin marquee masterpage media menu mp4 onerror onmouseoutdivproblem onmouseover parameters paypal pdf php player position post problem programming prototype rated rating redirect safari scale scriptlets scroll search security select size software solutions sources starrating synchronous toggle tweet unicode variables web webkit webservice window






