0

I have a Loop with checkbox values from database and when I check some box I need that the value passes to the input (without submit button);

<?php

        while($row = $sth->fetch()) {

              echo("<input type='checkbox' value='".$row['name']."'>".$row['name']."</option>");
        }
        echo('<input type="text" name="modelos" />');

?>

Thanks

1
  • 1
    markup is not right you /option> at the end ? Commented Mar 9, 2011 at 19:07

2 Answers 2

2
$(":checkbox").click(function(){
    var options="";
    $(":checkbox:checked").each(function(){
        options += $(this).val()+";"; 
    });

    $("input[name='modelos']").val(options);
});

Online demo: http://jsfiddle.net/ZPxqJ/6/

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

1 Comment

Yes, is this that I want, but I need all values that I check the input, for example: name1 ; name2 ; name3
0

add a button and the following snippet

$("input[name=mybutton]").click(function(){
    $("input[name='modelos']").val($(":checkbox:checked").val());
});

Comments

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.