Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 Other Forums
 Other Topics
 Java Script: On check value appears

Author  Topic 

afrika
Master Smack Fu Yak Hacker

2706 Posts

Posted - 2005-10-19 : 05:24:16
hello
i have the following phone book which i would like to implement a few extra jscript functions

I would like
1. When a user clicks the checkbox the value appears in the textfield and is written to the page.

"1 recepient added"

2. When a user checks a 2nd option, the value is added to the textfield seperated by a comma

And a value written

"2 recepient(s) added"

based on the total

Any assistance ?

Thanks
afrika

<html>

<head>
<title>Help</title>
</head>

<body>

<form method="POST" action="index.asp">
<table border="0" cellpadding="0" cellspacing="0" style="border-collapse: collapse" bordercolor="#111111" width="100%" id="AutoNumber1">
<tr>
<td width="33%"><input type="checkbox" name="user1" value="254254245243"></td>
<td width="33%"><input type="text" name="phone_nu" size="20"></td>
<td width="34%"> </td>
</tr>
<tr>
<td width="33%"><input type="checkbox" name="user5" value="5354353245234"></td>
<td width="33%"> </td>
<td width="34%"> </td>
</tr>
<tr>
<td width="33%"><input type="checkbox" name="user2" value="254234543"></td>
<td width="33%"> </td>
<td width="34%"> </td>
</tr>
<tr>
<td width="33%"><input type="checkbox" name="user4" value="2542534543"></td>
<td width="33%"> </td>
<td width="34%"> </td>
</tr>
<tr>
<td width="33%"><input type="checkbox" name="user3" value="542454254543"></td>
<td width="33%"> </td>
<td width="34%"> </td>
</tr>
</table>
<p><input type="submit" value="Submit" name="B1"></p>
</form>

<p> </p>

</body>

</html>

spirit1
Cybernetic Yak Master

11752 Posts

Posted - 2005-10-19 : 05:42:51
use onchange event on the checkbox.

onchange='AddStuff(this)'

function AddStuff(obj)
{
document.all["phone_nu"] += ", " + document.all[obj.name];
// you can add desired text in every field in this way.
}



Go with the flow & have fun! Else fight the flow
Go to Top of Page

SamC
White Water Yakist

3467 Posts

Posted - 2005-10-19 : 09:46:48
Be afraid... be very afraid...

IE isn't W3C DOM compliant, so you must test in both IE and either Firefox or Netscape to ensure you are supporting standards compliant browsers.
Go to Top of Page

afrika
Master Smack Fu Yak Hacker

2706 Posts

Posted - 2005-10-19 : 17:02:50
Thanks Spirit, Sam

Yes i know about the W3C DOM compliant issues, way back during the IE vs Netscape wars. Truely it sucks

am not really a jscript person.

But would work on the above
rgds
Afrika
Go to Top of Page
   

- Advertisement -