Hey. I have a webform, where I would like to be able to post a couple of hidden form fields if one particular checkbox is checked. I tried something like this: <p><label>Adresser:</label><input id="address" type="checkbox" name="pm_street_address" /></p> <script type="text/javascript"> if (document.forms.pm_street_address.checkbox.checked) { <input type="hidden" name="pm_post_num" value="pm_post_num" /> <input type="hidden" name="pm_post_area" value="pm_post_area" /> } </script> Code (markup): but that didn't work - at least nothing gets posted to the receiving page, it seems, whether the checkbox is checked or not (the "pm_street_adress" gets posted, of course). So, how would I approach this to get a couple of $_POST-variables from this, if the address-checkbox is checked? Anyone?
You don't have a checkbox value. Assign a value to your checkbox such as value="yes". Then use something like this: if ($_POST['pm_street_address'] == 'yes') // If it's checked { //Get other variables }
Yeah, I figured out how to achieve my goal a little earlier You are absolutely right - I was trying to do it in an overcomplicated fashion