开发者

Grabbing the Value of a Form and Using POST

Would like to post the value of a dynamic selection menu when the OnChange event is called. My code is currently this:

<form action="test4.php" method="POST" name="itemform">
<select name="input_name" id="input_name" onChange="this.form.submit();">
<?php
    while($row = mysql_fetch_array($result))
        echo "<option value='".$row['item_id']."'>" . $row['itemname'] . "</option>";
?>
</form>

The option values are populated by a query defined above and that works like a charm开发者_JS百科. The problem I am facing is for some reason the form is not grabbing and POSTing the value selected in the menu box when the OnChange event is raised. Any Ideas?


<form action="test4.php" method="POST" name="itemform">

My page test4.php uses this line to retrieve the value: echo ($_GET["input_name"]);

You're mixing up $_GET and $_POST, you need to use the one that corresponds to your form's method.


Close your <select> tag. ;D


Try closing your <select> element - that could be it.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜