我有一个 html 按钮
<input class="showOptions" type="button" style="width:100%" value="<%= (PRCDMU) %>" onclick="programSelector(this.value)" />
这会调用一些 JavaScript
function programSelector(value){
var origin = document.getElementById('origin').value();
if(origin === ""){
$( "#popup" ).dialog( "open" );
}
if(origin === "Product Specification"){
url = 'http://brmappsvr:7018/Enquiries/CMENPROC.rpgle?ProductCode=' + value;
window.location.href = url;
}elseif(origin === "Future Requirements Forecast")
url = 'http://brmappsvr:7018/Enquiries/CMENPRF.rpgle?ProductCode=' + value;
window.location.href = url;
}
然而,这个过程的一部分是 Jquery 中的弹出窗口。
$(".showOptions").click(function(){
var $self = this.value;
$( "#popup" ).dialog({
modal: true,
width: 465,
draggable: true,
buttons: {
"Product Specification": function() {
window.location.href = 'http://brmappsvr:7018/Enquiries/CMENPROC.rpgle?ProductCode=' + $self;
$( this ).dialog( "close" );
},
"Future Requirements Forecast": function() { //cancel
window.location.href = 'http://brmappsvr:7018/Enquiries/CMENPRF.rpgle?ProductCode=' + $self;
$( this ).dialog( "close" );
}
}
});
});
我遇到的问题是,弹出窗口的显示无关紧要,而它的显示仅取决于原始变量的内容,如果它为空,则弹出窗口应该可以工作
编辑:
原点显示在 html 页面上。
<div align="left">Please click on the<strong> Product Code</strong>, to use it within the <div class="style1" id="origin"><%= (origin) %> program. </div></div>
最佳答案
.value() 中的语法错误
应该是
var origin = document.getElementById('origin').value;
代替
var origin = document.getElementById('origin').value();
关于javascript - 无论如何运行代码都会出现问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28545398/