Jump to content

Form issue (unable to pass select box value from 1 form to another)


Recommended Posts

Hello everyone,
 
In my webpage i have 2 forms. 1 form has 3 select dropdown boxes and the other one is the main form which parses to a php script.

 

I would want the values of my 1st form dropdown select boxes to be passed into a hidden input field in the second form so that I can parse those to mysql database.

 

I am having difficulties passing the value of my 3 dropdown list in 1st form to the main form. Please help and thanks in advance.

 

 

below are my 2 forms

 

3 dropdown select form--->

 

<form action="" method="get" name="tripleplay"><table width="65%" border="1">

<tr>

<td width="25%" align="right">Category  </td>

<td width="75%"><select name='List1' id="catg1" onchange="fillSelect(this.value,this.form['List2'])">

<option selected="selected">Make a selection</option>

</select></td>

</tr>

<tr>

<td align="right">First-Subcategory  </td>

<td><select name='List2' id="catg2" onchange="fillSelect(this.value,this.form['List3'])">

<option selected="selected">Make a selection</option>

</select></td>

</tr>

<tr>

<td align="right">Second-Subcategory  </td>

<td><select name='List3' id="catg3" onchange="getValue(this.value, this.form['List2'].value, 

this.form['List1'].value)">

<option selected="selected" >Make a selection</option>

</select></td>

</tr>

</table></form>

++++++++++++++++++++++++++++++++++++++++

 

 

Main Form--->

 

<form action="inventory_list.php" method="post" enctype="multipart/form-data" name="myForm"><table width="65%" border="1">

<tr>

<td align="right" width="25%">Product Name </td>

<td width="75%"><input name="product_name" type="text" id="product_name"/></td>

</tr>

<tr>

<td align="right">Price  </td>

<td> $ <input name="price" type="text" id="price"/></td>

</tr>

<tr>

<td align="right">Details  </td>

<td><textarea name="details" cols="55" rows="10"> </textarea></td>

</tr>

<tr>

<td align="right">Upload Product Image  </td>

<td> <input name="imagefile" type="file" /></td>

</tr>

<tr>

<td> </td>

<td><input name="submit" type="submit" value="submit" />  <input name="reset" type="reset" value="reset" /> <input name="category" type="hidden" value="cat1"/>

<input name="first_subcategory" type="hidden" value="cat2" />

<input name="second_subcategory" type="hidden" value="cat3"/>

 

</td>

</tr>

</table></form>

 

Again Thanks in advance

 

Are these 2 forms on the same page?  You have the first form posting back to the same page it's on and the second form posting to a different page.  If the intention is to fill out the first form and submit it, then fill out the second form and submit that to the other page then you need to grab the $_GET vars form the url after the first submit and put them in the hidden fields of the second form.

<input name="category" type="hidden" value="<?php echo (isset($_GET['List1'])) ? $_GET['List1'] : '';  ?>"/>
<input name="first_subcategory" type="hidden" value="<?php echo (isset($_GET['List2'])) ? $_GET['List2'] : '';  ?>" />
<input name="second_subcategory" type="hidden" value="<?php echo (isset($_GET['List3'])) ? $_GET['List3'] : '';  ?>"/>

 

Are these 2 forms on the same page?  You have the first form posting back to the same page it's on and the second form posting to a different page.  If the intention is to fill out the first form and submit it, then fill out the second form and submit that to the other page then you need to grab the $_GET vars form the url after the first submit and put them in the hidden fields of the second form.

<input name="category" type="hidden" value="<?php echo (isset($_GET['List1'])) ? $_GET['List1'] : '';  ?>"/>
<input name="first_subcategory" type="hidden" value="<?php echo (isset($_GET['List2'])) ? $_GET['List2'] : '';  ?>" />
<input name="second_subcategory" type="hidden" value="<?php echo (isset($_GET['List3'])) ? $_GET['List3'] : '';  ?>"/>

 

Thank you for the quick response.

 

I have both the forms in 1 webpage. The dropdown box values from the first form will need to be passed to the second form which has a submit button to parse to a php script. The first form does not have a submit button.Only the values needs to be passed from 1st form to second form in the same page.

What i need is to get values of the 3 dropdowns from the first form to be passed to the second form.

 

The first form has no submit button. Both the forms are on the same page, and only the second form has the submit button which used the values of the 1st form dropdown to then parse to a php script.

 

I think we need some javascript to collect values from 1st forms select boxes and pass them to second form.

 

Not sure how to proceed..

If the first form doesn't submit anything then why do you have it as a different form than the second?  Why not just put them in the same form and submit it all at once?  Is the select boxes in the first form dynamic and gather info as you select down the list?  Even if it does, you can put it all in the same form unless you're not telling us some critical part to why you are doing it this way.

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.