html输入中带有javascript的多if语句
如果$\u post['value']大于100,我想执行特定的javascript;如果$\u post['value']小于100,我想执行另一个javascripthtml输入中带有javascript的多if语句,javascript,php,html,if-statement,Javascript,Php,Html,If Statement,如果$\u post['value']大于100,我想执行特定的javascript;如果$\u post['value']小于100,我想执行另一个javascript <script language="JavaScript"> if (document.getElementById("user_amount") > 100) { function euroConverter() { document.amount.value
<script language="JavaScript">
if (document.getElementById("user_amount") > 100) {
function euroConverter() {
document.amount.value = document.user_amount.value - (document.user_amount.value * 0.08)
}
}
if (document.getElementById("user_amount") < 100) {
function euroConverter() {
document.amount.value = document.user_amount.value - (document.user_amount.value * 0.1)
}
}
</script>
if(document.getElementById(“用户金额”)>100){
功能欧洲转换器(){
document.amount.value=document.user\u amount.value-(document.user\u amount.value*0.08)
}
}
if(document.getElementById(“用户金额”)<100){
功能欧洲转换器(){
document.amount.value=document.user\u amount.value-(document.user\u amount.value*0.1)
}
}
和html
<div class="form-group input-group">
<input type="number" id="user_amount" class="form-control" name="user_amount" onChange="euroConverter()">
<span class="input-group-addon"><i class="glyphicon glyphicon-usd"></i></span>
</div>
<div class="form-group input-group">
<input type="number" class="form-control" name="amount" onChange="dollarConverter()">
<span class="input-group-addon"><i class="glyphicon glyphicon-usd"></i></span>
</div>
感谢因为user615274说$\u POST值在JavaScript中是一个PHP值——大多数项都是对象。首先,HTML中缺少结束输入标记。其次,我们使用var声明变量,但您没有,例如var name='billy';document.write(name.toLowerCase());此外,您还需要并修复您的逻辑 你的问题不清楚,我认为在你分享的代码中有一系列不一致的地方与你的担忧没有明确的联系。我建议您编辑您的问题,以便更清楚地解释问题,并帮助您更好地执行以下操作:我希望在$\u POST['value']大于100时执行一个javascript,在$\u POST['value']小于100时使用if语句$\u POST['value']执行另一个javascript是我从表单中通过输入获得的vlaue:$\u PHP中的POST指的是通过HTTP POST方法传递给当前脚本的变量的关联数组,在您的示例中,您没有显示任何PHP代码,而是使用javascript getElementById方法访问输入值。这就是为什么我评论说有一些遗漏的逻辑如果你需要的是一个只使用js输入值的if逻辑请看一下这个例子抱歉我的javascript技能不好谢谢你的帮助我想得到值:当我把值放入。。。例:我在用户数量中输入了90,在数量输入中输入了81