如何将我的选项传递给URL参数?
选择代码:
echo "<select id=\"reasoncode\" name=\"reasoncode[$transnum]\"><option value=\"$ot_reasoncode\" default>$convert_rc</option><option value=\"0\"></option>"; select_reasoncode();
echo "</select>\n";
与所有预先设定的参数相关联:
echo "<a href=\"file_action.php?id=$id&confirmsubmit=1&uid=$uid\" title=\"Submit\"><img src=\"images/submit.png\" border=\"0\"></a>
所以基本上我想要todo以某种方式将下拉选择集成到我的ahref链接中,如下所示:
echo "<a href=\"file_action.php?id=$id&confirmsubmit=1&uid=$uid&SELECT=$SELECTVAR\" title=\"Submit\"><img src=\"images/submit.png\" border=\"0\"></a>
这可能吗?
答案 0 :(得分:3)
<select name="reasoncode" id="reasoncode" onchange="changePath();">
<option value=""></option>
<option value="page1.php?id=<?php echo $id;?>&confirmsubmit=1&uid=<?php echo $uid;?>">Option1</option>
<option value="page2.php?id=<?php echo $id;?>&confirmsubmit=1&uid=<?php echo $uid;?>">Option2</option>
<option value="page3.php?id=<?php echo $id;?>&confirmsubmit=1&uid=<?php echo $uid;?>">Option3</option>
</select>
<a id="link1" href="" target="_blank">CLICK</a>
<!--jquery min file-->
<script src="http://code.jquery.com/jquery-1.10.1.min.js"></script>
<script type="text/javascript">
function changePath()
{
var path= document.getElementById("reasoncode").value;
alert(path);
$("#link1").attr('href',path);
}
</script>