User Name Password Register
DaniWeb IT Discussion Community
All
What is DaniWeb IT Discussion Community?
You're currently browsing the JavaScript / DHTML / AJAX section within the Web Development category of DaniWeb, a massive community of 429,870 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 2,456 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our JavaScript / DHTML / AJAX advertiser: Lunarpages Web Hosting
Views: 1848 | Replies: 2
Reply
Join Date: Apr 2005
Posts: 69
Reputation: AhmedHan is an unknown quantity at this point 
Rep Power: 4
Solved Threads: 1
AhmedHan's Avatar
AhmedHan AhmedHan is offline Offline
Junior Poster in Training

Question Accessing Non-form Variables

  #1  
Apr 24th, 2006
<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>
Text control doesn't show the text. Why doesn't it?
AddThis Social Bookmark Button
Reply With Quote  
Join Date: Dec 2004
Location: Lincoln Park, Michigan
Posts: 1,744
Reputation: Comatose is an unknown quantity at this point 
Rep Power: 7
Solved Threads: 108
Colleague
Comatose's Avatar
Comatose Comatose is offline Offline
Moderator

Re: Accessing Non-form Variables

  #2  
Apr 24th, 2006
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:
<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>
Reply With Quote  
Join Date: Dec 2004
Posts: 1,590
Reputation: tgreer is an unknown quantity at this point 
Rep Power: 7
Solved Threads: 35
Colleague
tgreer tgreer is offline Offline
Made Her Cry

Re: Accessing Non-form Variables

  #3  
Apr 24th, 2006
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.
Reply With Quote  
Reply

Only community members can participate in forum threads. You must register or log in to contribute.

DaniWeb JavaScript / DHTML / AJAX Marketplace
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 

Thread Tools Display Modes

Similar Threads
Other Threads in the JavaScript / DHTML / AJAX Forum

All times are GMT -4. The time now is 7:43 pm.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC