Click here to Skip to main content
11,713,864 members (84,186 online)
Rate this: bad
good
Please Sign up or sign in to vote.
See more: PHP
hi,
I want to get value of dropdown list out side form tag.
Drop Down
<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>
<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
    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 6-Feb-13 21:21pm

1 solution

Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

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.
  Permalink  

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

  Print Answers RSS
0 Sergey Alexandrovich Kryukov 430
1 Maciej Los 229
2 Richard MacCutchan 210
3 CHill60 175
4 OriginalGriff 175
0 Sergey Alexandrovich Kryukov 365
1 CHill60 335
2 OriginalGriff 245
3 Andy Lanng 173
4 Richard MacCutchan 150


Advertise | Privacy | Mobile
Web04 | 2.8.150819.1 | Last Updated 7 Feb 2013
Copyright © CodeProject, 1999-2015
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100