display:none inputs not posting

JavaScript and client side scripting.

Moderator: General Moderators

Post Reply
imanewbe
Forum Newbie
Posts: 3
Joined: Mon Feb 07, 2011 12:12 am

display:none inputs not posting

Post by imanewbe »

Hey.

What i have is a multi step form which is on one page. The way it works is at the start only the first step shows. After this part is completed step 1 is made display:none and the second part is made display:block. This is fine but when i post the form the the inputs in the hidden part of the form are not posted.

Is there a better way to be doing this or is there a way to get this to work? One way i can do it is make everything visible then post the form on submit but i want to do it a different way so I don't have to make anything visible.
User avatar
getmizanur
Forum Commoner
Posts: 71
Joined: Sun Sep 06, 2009 12:28 pm

Re: display:none inputs not posting

Post by getmizanur »

can you post your code?
imanewbe
Forum Newbie
Posts: 3
Joined: Mon Feb 07, 2011 12:12 am

Re: display:none inputs not posting

Post by imanewbe »

This is what I have.

Code: Select all

<div id="formstep2" style="display:none;">
        	<input type="hidden" id="step2complete" value="false" />
            <table>
            <?php
            	foreach($userfields as $key => $field)
				{
			?>
            	<tr>
                	<td width="130"><?php if($userfieldsrequired[$key]){print $required;}?><?php print $field?>:</td>
                    <td><input type="text" name="<?php print str_replace(" ","",strtolower($field))?>" /></td>
                </tr>
            <?php
				}
			?>
            	<tr>
                	<td width="130">Country:</td>
                    <td><select name="country" id="countryddl">
                    	<option value="">Please Select</option>
                        <option value="">----------------</option>
                        <option value="New Zealand">New Zealand</option>
                        <option value="Australia">Australia</option>
                        <option value="UK">UK</option>
                        <option value="USA">USA</option>
                        <option value="">----------------</option>
                        <?php
						foreach($countrylist as $country)
						{
							print "<option value=" . $country . ">" . $country . "</option>";
						}
						?>
                    	</select></td>
                    </tr>
                    <tr>
			            <td colspan="2"><input type="checkbox" name="differentpostal" id="differentpostal" onclick="showdifferentpostal(this.checked);"/><label for="differentpostal" > postal address if different from above.</label></td>
                    </tr>
                    <tr id="differentpostalrow" style="display:none;">
                    	<td width="130" > 
                            Street Address:<?php print $required;?><br />
                            Suburb:<?php print $required;?><br />
                            City:<?php print $required;?><br />
                            Country:<?php print $required;?><br />
                        </td>
                        <td>
                        	<input type="text" name="streetaddress2" /><br />
                            <input type="text" name="suburb2" /><br />
                            <input type="text" name="city2" /><br />
                            <select name="country2">
                                <option value="">Please Select</option>
                                <option value="">----------------</option>
                                <option value="New Zealand">New Zealand</option>
                                <option value="Australia">Australia</option>
                                <option value="UK">UK</option>
                                <option value="USA">USA</option>
                                <option value="">----------------</option>
                            </select>                        
                        </td>
                    </tr>
            </table>
This is the second part of a form i am using. I only show the current step. There are 3 steps so when I post the form this step and the first step are set display:none so they cant be seen at the time but this also means that they won't post with the form.

Any ideas?
Post Reply