function submitForm(){
//if find open popup
//else if add continue in the same window
}
<form action="/findNames" onsubmit="return submitForm()">
<input type="submit" value="Add" onclick="submitForm(this)"/>
<input type="submit" value="Find" onclick="submitForm(this)"/>
</form>
我尝试的方法:
我尝试使用onclick来实现,但是当“查找”按钮被点击时,它会打开一个弹出窗口并提交父窗口。我该如何阻止它提交父窗口?
function submitForm(submit){
if(submit.value=="Find"){
find();//opens a popup window
}else if(submit.value == "Add"){
//stay in the same window
}
}
function find(){
var width = 1010;
var height = 400;
var params = 'width='+width+', height='+height;
popupWin = window.open('find.do','windowname5', params);
popupWin.focus();
}
<form action="/findNames">
<input type="submit" value="Add" onclick="submitForm(this)"/>
<input type="submit" value="Find" onclick="submitForm(this)"/>
</form>