Meaningless Drivel is fun!*
The moose likes HTML, CSS and JavaScript and the fly likes one submit button two action Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Bookmark "one submit button two action" Watch "one submit button two action" New topic
Author

one submit button two action

Simple Modi
Greenhorn

Joined: Feb 05, 2006
Posts: 1
Hi
I want to submit a form to itself first to search and then after checking business logic (checking the input values by query), I want to submit it to another form on the other frame in the same frameset.
I am using java and javascript to achieve this. Here is my code on the JSP page. It is skiping the search and directily going to ADD form. I will appreciate if you can give me a hint.

jsp page codes:

<input type="hidden" name="hfAction" value="<%=lsAction%>">

if(!lsContainerNo.equals(null)){
if (lsStatus.equals("")) {
lsMessage = "";
lsAction = "add";

%>
<script language="JavaScript" >
ufAdd();
</script>
<% }
And here is the javascript code
-------------------------------
function ufAdd(){
if (ufValidate()){

if (document.frmEquip.hfAction.value == "search"){
document.frmEquip.submit();
}
else if(document.frmEquip.hfAction.value == "add"){
var loForm = document.frmEquip;
document.frmEquip.action="cm_eq_detail.jsp";
document.frmEquip.target="results";
loForm.submit();

}
}
Eric Pascarello
author
Rancher

Joined: Nov 08, 2001
Posts: 15376
    
    6
"Simple Modi",

Welcome to the Ranch. There aren't many rules that you need to worry about here on the Ranch, but one that we take very seriously regards the use of proper names. Please take a look at the JavaRanch Naming Policy and adjust your display name to match it.

Thanks,
Eric Pascarello
Eric Pascarello
author
Rancher

Joined: Nov 08, 2001
Posts: 15376
    
    6
do an alert(document.frmEquip.hfAction.value) inside that form and see what the value is. (Is it what you expect?)

Eric
 
 
subject: one submit button two action