[英]why this document.getElementById().value() does not work in my php?
in my php code,i include -在我的 php 代码中,我包括 -
<select class="ht__select" onchange=" sorting('<?php echo $id?>')" id="sorting"> <option value="">Default softing</option> <option value="low_price">Sort by price low to high</option> <option value="high_price">Sort by price high to low</option> <option value="new">Sort by new first</option> </select>
after my php section and after the html body tag i write-在我的 php 部分和 html 正文标签之后我写-
function sorting(cat_id) { var sort_info = document.getElementByID('sorting').value(); alert(sort_info); window.location.href = "http://localhost/first/ecom_website/frontend/categories.php?id=" + cat_id + "&sort=" + sort_info; }
but my alert box is not showing.但我的警报框没有显示。 please help me.
请帮我。
Try this尝试这个
<html>
<head>
<title>Online PHP Script Execution</title>
</head>
<body>
<select class="ht__select" onchange="sorting('<?php echo $id ?>')" id="sorting">
<option value="">Default softing</option>
<option value="low_price">Sort by price low to high</option>
<option value="high_price">Sort by price high to low</option>
<option value="new">Sort by new first</option>
</select>
<script>
function sorting(cat_id){
var sort_info=document.getElementById('sorting').value;
alert(sort_info);
window.location.href="http://localhost/first/ecom_website/frontend/categories.php?id="+cat_id+"&sort="+sort_info;
}
</script>
</body>
</html>
value()
method doesn't exist on getElementById
. getElementById
上不存在value()
方法。 You can get the value using the value
attribute.您可以使用
value
属性获取值。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.