Is there a way to have a checkbox populate a textbox with a value?
I have three checkboxes on a form each representing a different value. 45 , 20 , 60 If for instance the 1st checkbox is checked then 45 would show up in a textbox if the second is check then 20 would show in the textbox.. and so on. There’s only one textbox and only one checkbox can be used at a time.
The form is html and php information is stored on a mysgl database.
See excample here click the X in the upper left hand corner of page. the checkboxes are the membership options and the text box is amount box at bottom.

    It seems to do what I want sort of, but has error if you uncheck a box and also only one box should beable to be checked.
    I created radio buttons insted and it does good, now my question is how do I hide the last radio button in the form.
    and since I created a form and it made a sql database will changing the checkboxes on the for to radio buttons affect the database information for the checkboxes

    <html>

    <head>
    <script type="text/javascript">
    function addVal(newVal, dest, addOrRemove) {
    if (addOrRemove) { // true == add; false == remove;
    if (dest.value.length != 0) {
    dest.value= "";
    }
    dest.value += newVal;
    } else {
    dest.value.replace(new RegExp("[, ]?" + value, "ig"), "");
    }
    }
    </script>

    </head>

    <body>

    <form ...>
    <input type="text" name="AmountEnclosed" id="AmountEnclosed" value="" />
    <input type="radio" value="$45.00" name="R1"onclick="addVal(this.value, this.form.AmountEnclosed, this.checked)" />
    <input type="radio" name="R1" value="$20.00"onclick="addVal(this.value, this.form.AmountEnclosed, this.checked)" />

    <input type="radio" name="R1" value="$60.00"onclick="addVal(this.value, this.form.AmountEnclosed, this.checked)" />
    <input type="radio" name="R1" value="0" checked class="hidden"></form>
    </body>

    </html>

      Write a Reply...