0

I need to store the values in the hidden text field when I select any check box from the page

    <input type="checkbox" name="checked1" value="checked1" onselect="getvalue()">
<input type="checkbox" name="checked1" value="checked2" onselect="getvalue()">
<input type="checkbox" name="checked1" value="checked3" onselect="getvalue()">

When I any of the check box that will store into below hidden field:

<input type="hidden" />

1 Answer 1

2

Using jquery, and assuming you gave an id (here "myhidden") to your hidden input, you can do this :

$('input[type="checkbox"]').change(function(){
    $('#myhidden').val($(this).val());
});

This fiddle demonstrates it : http://jsfiddle.net/dystroy/e6jpG/

Sign up to request clarification or add additional context in comments.

1 Comment

OP specified JavaScript, not jQuery.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.