Please support our JavaScript / DHTML / AJAX advertiser: Lunarpages Web Hosting
•
•
Join Date: Nov 2007
Posts: 4
Reputation:
Rep Power: 0
Solved Threads: 0
Hello,
I am trying to print all the selected checkbox values to a textbox separated by commas (, ). However, the first value in the textbox always starts with a comma (, ) i.e. (, one, two, three) etc. My current script trys to check if the first 2 characters (substring) are ", " (comma then space) then attempts to remove them. However this hasn't worked and I have no idea what to try next.
Thanks
Chris
I am trying to print all the selected checkbox values to a textbox separated by commas (, ). However, the first value in the textbox always starts with a comma (, ) i.e. (, one, two, three) etc. My current script trys to check if the first 2 characters (substring) are ", " (comma then space) then attempts to remove them. However this hasn't worked and I have no idea what to try next.
<head>
<script type="text/javascript">
function list(c,n,z) {
s=document.form.marktext.value;
if (c.checked) {
if (s.indexOf(n)<0) s+=', '+n;
} else {
s=document.form.marktext.value.replace(', '+n,'');
}
z=", ";
if (s.substring(2) == z) s=s.substring(2);
document.form.marktext.value=s;}
</script>
</head>
<body>
<form name="form">
<input type="text" value="" name="marktext"><br>
<input type="checkbox" name="mark" onclick="list(this,'Word')">Word<br>
<input type="checkbox" name="mark" onclick="list(this,'Type')">Type<br>
<input type="checkbox" name="makr" onclick="list(this,'Other')">Other<br>
</form>
</body>Thanks
Chris
Last edited by xmassey : Nov 21st, 2007 at 3:12 am.
Similar Threads
Other Threads in the JavaScript / DHTML / AJAX Forum
- datagrid coantianing checkbox as column (ASP.NET)
- How to use HTML tags in PHP (PHP)
- Forms authorization, only want a few links (ASP.NET)
- Javascript, Form fields validation and submit (JavaScript / DHTML / AJAX)
- Printing a textbox? (C#)
- TextBox - how to determine focus (ASP.NET)
- Adding a checkbox column dynamically (C#)
- Forms Authorization/ Authentication using asp .net and vb .net (ASP.NET)
- Populating & Retrieving Data in a listbox : ASP.NET (w/ VB.NET) (ASP.NET)
Other Threads in the JavaScript / DHTML / AJAX Forum
- Previous Thread: radio button looses the selected state after validation
- Next Thread: People like Yaldex slow down the progress of web development
•
•
•
•
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)






Threaded Mode