Forum Moderators: open

Message Too Old, No Replies

Trouble getting parameter value

         

quasi

5:23 pm on Feb 13, 2007 (gmt 0)

10+ Year Member



Here is a code snippet from a jsp file on a client's site.

Basically the user selects the failover button from the form, it calls the failover function that kicks off a confirm and populates var accordingly then the getParameter call gets the CNFRM val and acts accordingly. The client always gets 'false' for the value. We cannot reproduce this behavior.
We see the correct value of CNFRM in the http string window in the browser.request. It seems getParameter is not getting the value.

I am new to javascript and the people that wrote this are no longer here. I was hoping someone could see something incorrect or unstable in this logic.

Thanks

....function.....

<script type="text/javascript">
<!--
function Failover()
{
if( confirm('Are you sure you want to failover?') == true)
{
document.myForm.CNFRM.value = "true";
return true;
}
else
return false;
}
-->
</script>

....form.....

<table width="750" cellpadding="0" cellspacing="0" border="0">
<tr>
<form name="myForm" action="thisFile.jsp">
<td> <input type="submit" name="SUB2" value="<%= pt2 %>" class="yellowbutton" onclick="Failover()"></input></td>
<input type="hidden" name="CNFRM" value="false"></input>
</form>
</tr>
</table>

....after submission.....

<%
String cnfrm = request.getParameter("CNFRM");
if(cnfrm.equals("true"))
{
...do stuff...
}
%>

quasi

5:34 pm on Feb 13, 2007 (gmt 0)

10+ Year Member



BTW
Windows XP with IE

mrhoo

6:33 pm on Feb 13, 2007 (gmt 0)

10+ Year Member



Could be the form is being submitted before the confirm returns its value.
I'd take the failover function out of the submit button and attach it to an ordinary button;
and submit from the function.

function Failover(){
if( confirm('Are you sure you want to failover?') == true){
document.myForm.CNFRM.value = "true";
document.myForm.submit();
}
else return false;
}

<td> <input type="button" name="SUB2" value="<%= pt2 %>" class="yellowbutton" onclick="Failover()"></input></td>

quasi

7:28 pm on Feb 13, 2007 (gmt 0)

10+ Year Member



I'll try it, however we are able to see the correct CNFRM value in the http string.

quasi

7:40 am on Feb 27, 2007 (gmt 0)

10+ Year Member



Didn't work.

The CNFRM value is correct in the Failover function (printed it out) but is set to false after the form is submitted.

Is there a trick to dynamically setting a hidden form variable as I'm trying to do here?