Onclick help

Discussion in 'JavaScript' started by D-Fraz, Dec 16, 2009.

  1. #1
    Hey.
    When a checkbox is checked, I want it to add the id number of what I've got in a PHP variable, to appear in a <input type="text" />.
    For example:

    The id is 1, 2, and 3. So 3 checkbox's.
    I click on the first, and it adds to another input field, '1'.
    I hit the second, and the same thing happens, except the id is 2.

    Of course, I know how to do the ID and all with PHP.
    All I need to do now, is where when you click a check box, it adds to another field, and adds & after every check.

    Here is my code:
    
    <input type="checkbox" name="delete" 
             onclick="this.checkedbox.style.display=(this.value=='checked' ? 'inline' : '2' )" />
    <input type="text" name="checkedbox" />
    
    Code (markup):
    Thanks. :)
     
    D-Fraz, Dec 16, 2009 IP
  2. SIPHILP

    SIPHILP Peon

    Messages:
    14
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #2
    Can you use jQuery or does it have to be "Javascript"?

    jQuery solution :)

    siphilp.co.uk/archive/2009/04/13/jquery-fun-with-radio-button-lists-checkboxes-and-labels.aspx

    Sorry above isn't a link, not posted enough or something :S
     
    Last edited: Dec 17, 2009
    SIPHILP, Dec 17, 2009 IP