Wrox Home  
Search P2P Archive for: Go

  Return to Index  

beginning_javascript thread: SV: Setting Value with OnClick


Message #1 by "Robert Nyman" <robert.nyman@c...> on Tue, 10 Sep 2002 19:58:24 +0200
Hugh,

you have to bear in mind that JavaScript is case-sensitive (as opposed
to VBScript and HTML).

The first error I see (which is probably your problem) is this:

document.MyForm.frmSendTo.Value =3D 'All';  // This is WRONG

It should be value with a small 'v', like this:

document.MyForm.frmSendTo.value =3D 'All';  // This is CORRECT


/Robert


-----Ursprungligt meddelande-----
Fr=E5n: Hugh McLaughlin [mailto:hugh@k...]
Skickat: den 10 september 2002 14:32
Till: Beginning JavaScript
=C4mne: [beginning_javascript] Setting Value with OnClick


Hello Everyone and thanks for your help in advance.  I am learning
Javascript and am trying to write a script that upon the click event of
a
checkbox, and text field is populated with a value.  The script is:

<body>
<script language=3D"JavaScript">
<!--
function jsSendToAll()
{
                document.MyForm.frmSendTo.Value =3D 'All';

}
//-->
</script>
<table border=3D"1" width=3D"100%">
<form id=3D"MyForm" method=3D"POST" >
	<tr>
		<td width=3D"50%">
		<input type=3D"text" name=3D"frmSendTo" size=3D"20"><br>
		<input type=3D"submit" value=3D"Submit" name=3D"B1">
                <input type=3D"reset" value=3D"Reset" name=3D"B2">
		</td>
		<td width=3D"50%">
		<input type=3D"checkbox" name=3D"AllRecipients" value=3D"ON"
OnClick=3D"if(this.checked){jsSendToAll();}">&nbsp; Send to
				All Recipients
	</tr>
</form>
</table>

</body>

I get an error each time I run this script and am not exactly sure why.

Any help would be greatly appreciated.  Thanks.

---

Improve your web design skills with these new books from Glasshaus.

Usable Web Menus
http://www.amazon.com/exec/obidos/ASIN/1904151027/ref=3Dnosim/theprogramm
e
r-20
Constructing Accessible Web Sites
http://www.amazon.com/exec/obidos/ASIN/1904151000/ref=3Dnosim/theprogramm
e
r-20
Practical JavaScript for the Usable Web
http://www.amazon.com/exec/obidos/ASIN/1904151051/ref=3Dnosim/theprogramm
e
r-20

Message #2 by Jonathan Gold <jonnygee@p...> on Tue, 10 Sep 2002 12:21:06 -0700
Hugh, and if Robert's correction doesn't do it all, try adding name="MyForm"
in this line:

	<form id="MyForm" method="POST" >

so it will read

	<form id="MyForm" name="MyForm" method="POST" >

HTH,

Jonathan

Jonathan Gold
jonnygee@p...

-----Original Message-----
From: Robert Nyman [mailto:robert.nyman@c...]
Sent: Tuesday, September 10, 2002 10:58 AM
To: Beginning JavaScript
Subject: [beginning_javascript] SV: Setting Value with OnClick


Hugh,

you have to bear in mind that JavaScript is case-sensitive (as opposed
to VBScript and HTML).

The first error I see (which is probably your problem) is this:

document.MyForm.frmSendTo.Value = 'All';  // This is WRONG

It should be value with a small 'v', like this:

document.MyForm.frmSendTo.value = 'All';  // This is CORRECT


/Robert


-----Ursprungligt meddelande-----
Från: Hugh McLaughlin [mailto:hugh@k...]
Skickat: den 10 september 2002 14:32
Till: Beginning JavaScript
Ämne: [beginning_javascript] Setting Value with OnClick


Hello Everyone and thanks for your help in advance.  I am learning
Javascript and am trying to write a script that upon the click event of
a
checkbox, and text field is populated with a value.  The script is:

<body>
<script language="JavaScript">
<!--
function jsSendToAll()
{
                document.MyForm.frmSendTo.Value = 'All';

}
//-->
</script>
<table border="1" width="100%">
<form id="MyForm" method="POST" >
	<tr>
		<td width="50%">
		<input type="text" name="frmSendTo" size="20"><br>
		<input type="submit" value="Submit" name="B1">
                <input type="reset" value="Reset" name="B2">
		</td>
		<td width="50%">
		<input type="checkbox" name="AllRecipients" value="ON"
OnClick="if(this.checked){jsSendToAll();}">&nbsp; Send to
				All Recipients
	</tr>
</form>
</table>

</body>

I get an error each time I run this script and am not exactly sure why.

Any help would be greatly appreciated.  Thanks.

---

Improve your web design skills with these new books from Glasshaus.

Usable Web Menus
http://www.amazon.com/exec/obidos/ASIN/1904151027/ref=nosim/theprogramme
r-20
Constructing Accessible Web Sites
http://www.amazon.com/exec/obidos/ASIN/1904151000/ref=nosim/theprogramme
r-20
Practical JavaScript for the Usable Web
http://www.amazon.com/exec/obidos/ASIN/1904151051/ref=nosim/theprogramme
r-20



---

Improve your web design skills with these new books from Glasshaus.

Usable Web Menus
http://www.amazon.com/exec/obidos/ASIN/1904151027/ref=nosim/theprogramme
r-20
Constructing Accessible Web Sites
http://www.amazon.com/exec/obidos/ASIN/1904151000/ref=nosim/theprogramme
r-20
Practical JavaScript for the Usable Web
http://www.amazon.com/exec/obidos/ASIN/1904151051/ref=nosim/theprogramme
r-20

Message #3 by "Hugh McLaughlin" <hugh@k...> on Wed, 11 Sep 2002 01:05:28
Actually, it required both to be changed.  Thanks for your help.

> Hugh, and if Robert's correction doesn't do it all, try adding 
name="MyForm"
in this line:

	<form id="MyForm" method="POST" >

so it will read

	<form id="MyForm" name="MyForm" method="POST" >

HTH,

Jonathan

Jonathan Gold
jonnygee@p...

-----Original Message-----
From: Robert Nyman [mailto:robert.nyman@c...]
Sent: Tuesday, September 10, 2002 10:58 AM
To: Beginning JavaScript
Subject: [beginning_javascript] SV: Setting Value with OnClick


Hugh,

you have to bear in mind that JavaScript is case-sensitive (as opposed
to VBScript and HTML).

The first error I see (which is probably your problem) is this:

document.MyForm.frmSendTo.Value = 'All';  // This is WRONG

It should be value with a small 'v', like this:

document.MyForm.frmSendTo.value = 'All';  // This is CORRECT


/Robert


-----Ursprungligt meddelande-----
Från: Hugh McLaughlin [mailto:hugh@k...]
Skickat: den 10 september 2002 14:32
Till: Beginning JavaScript
Ämne: [beginning_javascript] Setting Value with OnClick


Hello Everyone and thanks for your help in advance.  I am learning
Javascript and am trying to write a script that upon the click event of
a
checkbox, and text field is populated with a value.  The script is:

<body>
<script language="JavaScript">
<!--
function jsSendToAll()
{
                document.MyForm.frmSendTo.Value = 'All';

}
//-->
</script>
<table border="1" width="100%">
<form id="MyForm" method="POST" >
	<tr>
		<td width="50%">
		<input type="text" name="frmSendTo" size="20"><br>
		<input type="submit" value="Submit" name="B1">
                <input type="reset" value="Reset" name="B2">
		</td>
		<td width="50%">
		<input type="checkbox" name="AllRecipients" value="ON"
OnClick="if(this.checked){jsSendToAll();}">&nbsp; Send to
				All Recipients
	</tr>
</form>
</table>

</body>

I get an error each time I run this script and am not exactly sure why.

Any help would be greatly appreciated.  Thanks.

---

Improve your web design skills with these new books from Glasshaus.

Usable Web Menus
http://www.amazon.com/exec/obidos/ASIN/1904151027/ref=nosim/theprogramme
r-20
Constructing Accessible Web Sites
http://www.amazon.com/exec/obidos/ASIN/1904151000/ref=nosim/theprogramme
r-20
Practical JavaScript for the Usable Web
http://www.amazon.com/exec/obidos/ASIN/1904151051/ref=nosim/theprogramme
r-20



---

Improve your web design skills with these new books from Glasshaus.

Usable Web Menus
http://www.amazon.com/exec/obidos/ASIN/1904151027/ref=nosim/theprogramme
r-20
Constructing Accessible Web Sites
http://www.amazon.com/exec/obidos/ASIN/1904151000/ref=nosim/theprogramme
r-20
Practical JavaScript for the Usable Web
http://www.amazon.com/exec/obidos/ASIN/1904151051/ref=nosim/theprogramme
r-20


  Return to Index