我有这个用于从数据库中提取的下拉列表。 当用户选择下拉列表中的一个时,它应该打开一个新页面,其中已从下拉值中拉出已发布变量。我应该如何使用jquery来处理它?</ p> 到目前为止,我有这个
echo '<label><SELECT name="cd-dropdown" id="cd-dropdown" class="cd-select">'.'<br>';
echo '<OPTION VALUE="-1" selected>'."Choose Project".'</OPTION>';
while($row = oci_fetch_array($compCuttingResult,OCI_ASSOC)){
$projectName = $row ['PROJECT_NAME'];
echo "<OPTION name='valueSelected' VALUE='$projectName' class='icon-fab'>$projectName</OPTION>";
}
echo '</SELECT></label><br />';
答案 0 :(得分:0)
echo '<label><SELECT name="cd-dropdown" id="cd-dropdown" onchange="myFunction()" class="cd-select">'.'<br>';
echo '<OPTION VALUE="-1" selected>'."Choose Project".'</OPTION>';
echo "<OPTION name='valueSelected' VALUE='test' class='icon-fab'>test</OPTION>";
echo '</SELECT></label><br />';
?>
<script type="text/javascript">
function myFunction(){
var myselect = document.getElementById("cd-dropdown");
var val = myselect.options[myselect.selectedIndex].value;
window.location = "https://www.google.co.in/#q="+val;
}
</script>