Click here to Skip to main content
15,915,859 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
hi,
I want to get value of dropdown list out side form tag.
Drop Down
HTML
<td width="225" align="left"><select id="month" name="month" >
<option selected="selected" value="">----Month----</option>
<option value="January">January</option>
<option value="February">February</option>
<option value="March">March </option>
<option value="April">April</option>
<option value="May">May</option>
<option value="June">June </option>
<option value="July">July</option>
<option value="August">August</option>
<option value="September">September </option>
<option value="October">October</option>
<option value="November">November</option>
<option value="December">December </option>
</select>
</td>
text fox.
<td width="80%" align="left"  ><input id="name" name="name" disabled="disabled" type="text" value="abc" style="width:200px;"/></td>

PHP
<form enctype="multipart/form-data" action="<?php echo $_SERVER['PHP_SELF'];?>" method="post"><td align="right"><label for="file1">Attache File</label> <input type="file" name="file" id="file"><input type="submit" Value="Send For Approval" id="mail" name="mail" /></td></tr></table></form>


I want to get value on the mail button click but unable to get any value content from out side form.

Here is my php code.

PHP
<?php
    if(isset($_POST['mail']))
    {
	 $month=$_GET['month'];// not by this
    $month=$_POST['month'];// not by this

	echo "<script>alert($month);</script>";
    	
    }
?>


If any one of you have any idea then pls let me know.
Thanks
Posted

1 solution

The month value has to be inside the form if you want it sent to the server. Either move the drop-down inside the form tag, or increase the area of the form to take in the drop-down.

Another option is copying the value from the drop-down into a hidden field inside the form using Javascript, but it obviously won't work if Javascript is disabled.

Your form and table tags seem to be uneven too - the form is closed after the table, but opened before a table cell. Either move the form tags outside the table or wholly inside the table cell.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900