i need to do check box that if i check it will add value to another textfield
and i have about 3 check box and id check which one it will add value only not replace
how can i do that thx
i need to do check box that if i check it will add value to another textfield
and i have about 3 check box and id check which one it will add value only not replace
how can i do that thx
Please restate your question more clearly, and supply example markup.
- John________________________
Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate
Code:<script type="text/javascript"> function map(f, a) { for(var i = 0, r = []; i < a.length; r.push(f(a, i++))); return r; } function filter(f, a) { for(var i = 0, r = []; i < a.length; f(a[i++], i) ? r.push(a[i]) : ''); return r; } function catVals(els) { return map(function(el) { return el.value; }, filter(function(el) { return el.checked; }, els)).join("\r\n"); } </script> </head> <body> <!-- ... --> <form action=""> <textarea name="vals"> </textarea> <input type="checkbox" value="cats" onclick="this.form.elements.vals.value = catVals(this.form.elements.chks);" name="chks"> <input type="checkbox" value="dogs" onclick="this.form.elements.vals.value = catVals(this.form.elements.chks);" name="chks"> </form>
Twey | I understand English | 日本語が分かります | mi jimpe fi le jbobau | mi esperanton komprenas | je comprends français | entiendo español | tôi ít hiểu tiếng Việt | ich verstehe ein bisschen Deutsch | beware XHTML | common coding mistakes | tutorials | various stuff | argh PHP!
I haven't looked over Twey's above response, which is probably good. I was just playing around with the idea as best that I understood it. I came up with this:
as a possible avenue toward what you are asking about.Code:<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"> <html> <head> <title></title> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> <script type="text/javascript"> function cbox(box, tf){ if(box.checked) box.form.elements[tf].value=isNaN(box.form.elements[tf].value-0)? box.value : (box.form.elements[tf].value-0)+(box.value-0); else box.form.elements[tf].value=box.form.elements[tf].defaultValue; } </script> </head> <body> <form action="#"> <div> <input type="text" name="num" readonly value="1"> <input type="checkbox" name="bob" value="10" onclick="cbox(this, 'num');"> </div> </form> </body> </html>
- John________________________
Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate
I read "add" as meaning "concatenate." Clarify please, jackavin?
Twey | I understand English | 日本語が分かります | mi jimpe fi le jbobau | mi esperanton komprenas | je comprends français | entiendo español | tôi ít hiểu tiếng Việt | ich verstehe ein bisschen Deutsch | beware XHTML | common coding mistakes | tutorials | various stuff | argh PHP!
Thank for all post but i want something like hotmail that add contact to CC field when u click on the name it will add more and more and when uncheck that name will out of the textfield something like that
thank you
Last edited by jackavin; 09-10-2007 at 05:50 AM.
Yes, that's what I thought you meant. See my code.
Twey | I understand English | 日本語が分かります | mi jimpe fi le jbobau | mi esperanton komprenas | je comprends français | entiendo español | tôi ít hiểu tiếng Việt | ich verstehe ein bisschen Deutsch | beware XHTML | common coding mistakes | tutorials | various stuff | argh PHP!
Well, that certainly sounds like concatenate, as Twey (mind reader that he is :) ) already offered. Does his code work for you or not?
In any case, have a look at this:
Code:<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"> <html> <head> <title></title> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> <script type="text/javascript"> function cbox(box, tf){ var dat=box.checked? ' '+box.value : new RegExp(' '+box.value); if(box.checked) box.form.elements[tf].value+=dat; else box.form.elements[tf].value=box.form.elements[tf].value.replace(dat, ''); } </script> </head> <body> <form action="#"> <div> <input type="text" name="addys" readonly><br> <input type="checkbox" name="bob" value="someone@some.com" onclick="cbox(this, 'addys');"> someone@some.com </div> </form> </body> </html>
- John________________________
Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate
thank you all without u i will die![]()
Here's more (from my take on this):
Added Later:Code:<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"> <html> <head> <title></title> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> <script type="text/javascript"> function cbox(box, tf){ var dat=box.checked? ';'+box.value : new RegExp(';\?'+box.value); if(box.checked) box.form.elements[tf].value+=dat; else box.form.elements[tf].value=box.form.elements[tf].value.replace(dat, ''); box.form.elements[tf].value=box.form.elements[tf].value.replace(/^;/, ''); } </script> </head> <body> <form action="#"> <div> <input type="text" name="addys" readonly size="75"><br> <input type="checkbox" name="someone0" value="someone0@some.com" onclick="cbox(this, 'addys');"> someone0@some.com<br> <input type="checkbox" name="someone1" value="someone1@some.com" onclick="cbox(this, 'addys');"> someone1@some.com<br> <input type="checkbox" name="someone2" value="someone2@some.com" onclick="cbox(this, 'addys');"> someone2@some.com<br> </div> </form> </body> </html>
But, unless this isn't all that critical, none of this will be all that good if there isn't a server side fall back.
Last edited by jscheuer1; 09-10-2007 at 06:50 AM. Reason: add info
- John________________________
Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate
Bookmarks