我有一个问题,我正在设计一个网页来处理数据库。所以这个想法是,
dropdown
$_POST
获取数据库监控的值
醇>
问题是,当我单击该选项时,它会重定向到该新页面,但不会以新窗口的形式重定向。 如何使用
发送要在新页面上使用的选定值$newVal = strval($_POST['PROJECT_NAME']);
我的代码是,
<script>
$(function(){
$('#cd-dropdown').bind('change', function () {
var url = $(this).val(); // get selected value
if (url) { // require a URL
window.location = "monitorIndex.php"; // redirect
}
return false;
});
});
</script>
标记:
$projectParse = oci_parse($conn, 'SELECT DISTINCT PROJECT_NAME FROM MASTER_DRAWING '
. 'ORDER BY PROJECT_NAME ASC');
oci_execute($projectParse);
echo '<select name="cd-dropdown "id="cd-dropdown" class="cd-select">';
echo '<OPTION VALUE="">PROJECT SELECT</OPTION>';
while($row = oci_fetch_array($projectParse,OCI_ASSOC)){
$projectName = $row ['PROJECT_NAME'];
echo "<OPTION VALUE='$projectName'>$projectName</OPTION>";
}
echo '</select>';
答案 0 :(得分:1)
试试这个。
$('#cd-dropdown').change(function(){
var id = $(this).val();
window.location = 'monitorIndex.php?id=' + id;
});
答案 1 :(得分:0)
This method should take you to new window with ProjectName in URL.
$('#dropdown').change(function(){
var id = $(this).val();
window.open ('monitorIndex.php?id=' + id ,'_blank');
});
Or another way is if you are using HTML5 , you can use local storage,
You can basically keep the value on client side localstorage and can access it on any other page.
// Store
localStorage.setItem("projectname", "abc");
// Retrieve
document.getElementById("result").innerHTML = localStorage.getItem("projectname");
答案 2 :(得分:0)
尝试以下代码
$('#cd-dropdown').change(function(){
var id = $(this).val();
$.ajax({
type: "POST",
url: "monitorIndex.php",
data: { PROJECT_NAME: id }
})
.done(function( msg ) {
var myWindow = window.open("", "MsgWindow", "width=800, height=800");
myWindow.document.write(msg );
});
});