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.
Author |
Topic |
afrika
Master Smack Fu Yak Hacker
2706 Posts |
Posted - 2005-10-24 : 04:46:25
|
hello,i have the following code that writes the value of a check box to a textfield area.When a user clicks a check box, the value is written to the text box.However how do i get the value removed from the text box once the user unchecks the value ?thanksAfrika[CODE]<html><head><meta http-equiv="Content-Language" content="en-us"><meta http-equiv="Content-Type" content="text/html; charset=windows-1252"><title>Quick Insert</title><script>var totalcount;totalcount = 0;function doAction(thevalue){var commaval="," if (document.all.item("phone_nu2").value.length > 0) { document.all.item("phone_nu2").value = document.all.item("phone_nu2").value + ", " + thevalue; } else { document.all.item("phone_nu2").value = thevalue; } totalcount = totalcount + 1; document.all.item("totalno").value = totalcount+" numbers"; }</script></head><body><form method="POST" action="index.asp" name="test"><table border="0" width="100%" id="table1"><tr><td width="122" id="qi" style="display:none;"> </td><td width="116"> </td><td width="196"> </td><td> </td><td> </td></tr><tr><td width="122"> </td><td width="116"> </td><td width="196"><input type="text" id="phone_nu2" name="phone_nu2" size="65"></td><td> </td><td> </td></tr><tr><td width="122"><input type="checkbox" onClick='doAction(document.activeElement.value)';" value="2348023305711" value="ON"> <input type="checkbox" onClick='doAction(document.activeElement.value)';" value="2348023658011" name="C1" value="ON" ><p> </td><td width="116">Total</td><td width="196"><input type="text" id="totalno" size="20" name="T1"></td><td> </td><td> </td></tr><tr><td width="122"> </td><td width="116"> </td><td width="196"> </td><td> </td><td> </td></tr></table><p> </p><p><input type="submit" value="Submit" name="B1"><input type="reset" value="Reset" name="B2"></p></form></body></html>[/CODE] |
|
spirit1
Cybernetic Yak Master
11752 Posts |
Posted - 2005-10-24 : 08:11:10
|
[code]var phoneValues = document.all.item("phone_nu2").value;if (phoneValues.indexOf("yourValue") >= 0) phoneValue.replace(/yourValue/gi, "") // this is a regular expression: /yourValue/gi. g = flag to // replace all values not just first found, i = case insensitive compare[/code]Go with the flow & have fun! Else fight the flow |
|
|
afrika
Master Smack Fu Yak Hacker
2706 Posts |
Posted - 2005-10-24 : 08:40:47
|
Amazing Spirit1, how many languages do you speak ?Am trying it out nowthanks |
|
|
afrika
Master Smack Fu Yak Hacker
2706 Posts |
Posted - 2005-10-24 : 08:47:57
|
this is what i am trying, not workingwhere am i wrong ?<script>var totalcount;totalcount = 0;function doAction(thevalue){var commaval=","var phoneValues = document.all.item("phone_nu2").value;if (phoneValues.indexOf("phone_nu2") >= 0) phoneValue.replace(/phone_nu2/gi, "") // this is a regular expression: /yourValue/gi. g = flag to // replace all values not just first found, i = case insensitive compare if (document.all.item("phone_nu2").value.length > 0) { document.all.item("phone_nu2").value = document.all.item("phone_nu2").value + ", " + thevalue; } else { document.all.item("phone_nu2").value = thevalue; } totalcount = totalcount + 1; document.all.item("totalno").value = totalcount+" numbers"; }</script> |
|
|
spirit1
Cybernetic Yak Master
11752 Posts |
Posted - 2005-10-24 : 10:22:34
|
yourValue is your phonenumber or some text you want to get rid of. not the name of your field.well i speak english, a little german, slovene, croatian, c++, Visual C++ 6, all .net languages, T-sql, javascript, vbscript, matlab... i probably forgot one or two Go with the flow & have fun! Else fight the flow |
|
|
afrika
Master Smack Fu Yak Hacker
2706 Posts |
Posted - 2005-10-24 : 10:40:45
|
quote: well i speak english, a little german, slovene, croatian, c++, Visual C++ 6, all .net languages, T-sql, javascript, vbscript, matlab... i probably forgot one or two
Right ! Must really be a Spirit1 :-) |
|
|
spirit1
Cybernetic Yak Master
11752 Posts |
Posted - 2005-10-24 : 11:02:05
|
LOL Go with the flow & have fun! Else fight the flow |
|
|
|
|
|
|
|