Problem trywialny ale niestety nie wiem gdzie robię błąd:
Chodzi o to aby zaznaczając wybrane checkbox'y, wartości z nich dodawały się do pola input typu tekstowego.
  1. <input type='checkbox' id="1" name='my_checkbox1' value='asd'>
  2. <input type='checkbox' id="2" name='my_checkbox2' value='zxc'>
  3. <input type='checkbox' id="3" name='my_checkbox3' value='fds'>
  4.  
  5. <div><input type="text" /></div>
  6.  
  7. $(document).ready(function(){
  8. $(":checkbox").change(function(){
  9. if($(this).attr("checked"))
  10. {
  11. var str = "";
  12.  
  13. $("input").each(function () {
  14. str += $(this).val() + " "
  15. });
  16. }
  17. else
  18. {
  19. var str = "";
  20. }
  21. $(":text").val(str);
  22. });
  23. });


Udało się rozwiązaćwink.gif
  1. <!DOCTYPE html>
  2. div { color:red; }
  3. </style>
  4. </head>
  5. Karol
  6. <input type='checkbox' value='Karol'>
  7. Zofia
  8. <input type='checkbox' value='Zofia'>
  9. Adam
  10. <input type='checkbox' value='Adam'>
  11. <input type="text" id="pole" value=""/>
  12. $("input").click(function () {
  13. var str = "";
  14. $("input:checked").each(function () {
  15. str += $(this).val() + " ";
  16. });
  17. $("#pole").val(str);
  18. })
  19.  
  20. </body>
  21. </html>