我遇到了问题,我在页面上添加了一个下拉列表,只是post方法不起作用。
这是一个测试页面:见到你。
<?php
$values=$_POST['list'];
if($_SERVER['REQUEST_METHOD']=='POST')
{
if(isset($_POST['submit']))
{
$i="<span style='font-color:red;font-weight:bold'>";$s="</span>";
echo $i;
echo $options[$value];
echo $values;
echo $s;
}
}
?>
<center><h2>This is a page to test the drop down</h2>
<form method='post'>
<select id="demo-htmlselect-basic"name="list">
<option value="0">Select</option>
<option value="1">Part 1</option>
<option value="2">Part 2</option>
<option value="3">Part 3</option>
</select><br/><br/>
<input type="submit"name="submit"id="submit"value="Submit"/>
</form>
</center>
<script type="text/javascript"src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"></script>
<script type="text/javascript"src="https://ajax.googleapis.com/ajax/libs/jqueryui/1.8.18/jquery-ui.min.js"></script>
<script type="text/javascript"src="//healtend.it/uploads/script.js"></script>
<script type="text/javascript"src="//healtend.it/uploads/jquery.ddslicksd.min.js"></script>
等待你的帮助。
感谢。
答案 0 :(得分:0)
你错过了写“;”在一个回声的最后一个。
echo $ s;
if(isset($_POST['submit']))
{
$i="<span style='font-color:red;font-weight:bold'>";$s="</span>";
echo $i;
echo $options[$value];
echo $values;
echo $s;
}
答案 1 :(得分:0)
您的name="list"
文件中缺少jquery.ddslicksd.min.js
,请修改您的代码
http://healtend.it/uploads/jquery.ddslicksd.min.js
添加
name="list"
到<input class="dd-selected-value" type="hidden" />
行。
对于php + HTML代码,如下所示:
PHP:
if(isset($_POST['submit'])){
$values = $_POST['list'];
$i="<span style='font-color:red;font-weight:bold'>";
$s="</span>";
echo $i;
echo $values;
echo $s;
}
HTML:
<script type="text/javascript"src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"></script>
<script type="text/javascript"src="https://ajax.googleapis.com/ajax/libs/jqueryui/1.8.18/jquery-ui.min.js"></script>
<center>
<h2>This is a page to test the drop down</h2>
<form method='POST' action="" id="dropdown">
<select id="demo-htmlselect-basic" name="list">
<option value="0">Select</option>
<option value="1">Part 1</option>
<option value="2">Part 2</option>
<option value="3">Part 3</option>
</select>
<br/><br/>
<input type="submit"name="submit" id="submit"value="Submit"/>
</form>
</center>
<script type="text/javascript"src="//healtend.it/uploads/script.js"></script>
<script type="text/javascript"src="//healtend.it/uploads/jquery.ddslicksd.min.js"></script>