Click to See Complete Forum and Search --> : Global Vars seem to reset upon submit()


breamer
12-11-2003, 01:50 PM
<%@ page import="java.sql.*, oracle.jsp.dbutil.*, javax.servlet.http.HttpUtils" contentType="text/html;charset=windows-1252"%>
<%@ taglib uri="/WEB-INF/tlds/sqltaglib.tld" prefix="sql" %>

<html>
<head>
<script language="JavaScript">
numm = 9;
function get_kit_brand() {
numm = document.TTT.batchBrand.selectedIndex;

var the_selected = document.TTT.batchBrand.options[numm].text;
document.TTT.test_hidden.value = the_selected;
document.TTT.submit();
alert(numm);
}
</script>

And then a bit of jsp code then:

<SCRIPT>alert(numm)</SCRIPT>

And it is back to the original value

Any clues?

olerag
12-11-2003, 01:58 PM
From what you have provided, "numm" will equal "9"
since "get_kit_brand()" doesn't appear to be called.

Also, when you mention that the value resets after a
"submit", do you mean that you are calling the same
page or another page???

Without your html (that your jsp is providing) it is difficult
to determine how you want your JS to behave.

breamer
12-11-2003, 02:21 PM
TD align=left>Batch Brand: </TD>
<TD align=left> <SELECT name="batchBrand" size="1" maxlength="50" onChange="get_kit_brand()">
<sql:dbNextRow queryId="kit_brand_query">
<option>
<%= kit_brand_query.getString(1)
%>
</sql:dbNextRow>
</select>
</TD>
</TR>

it is called on a select(drop down) changing

And I am submitting back to the same form. I am trying to co-ordinate two drop down menus

Second one depends on what was selected on the first one

olerag
12-11-2003, 03:11 PM
OK - since your submitting to the same page, the original
assignment to the global will remain (as is apparently
happening).

To make the "next" page submission change to the value you
prefer, you could create a "hidden" object, set it via the
"kit_brand_query" function (when an item is selected from
the list), and, when the item is re-submitted, its value will
be passed and stored automatically in the "hidden" object.

Consequently, you won't need the global anymore since
the "hidden" object will now service this functionality. If the
"hidden" does not contain a value (as yet, such as the
first-time "call") its value.length() will return 0. Or, if you
prefer, you can set it to another value (such as 9).

breamer
12-11-2003, 03:16 PM
But are hidden fields not reset upon submit as well?

breamer
12-11-2003, 03:27 PM
I created the hidden fields and after the
submit I reset it via:

<input type="text" name="test_hidden" size=10 maxlength=30 value='<%=request.getParameter("test_hidden")%>'/>

So the submit, posts the data and then I get it again via getParameter

Thanks for the help

Man, this stuff is not client server , I'm getting old, I find this stuff kludgy

<sigh>

olerag
12-12-2003, 08:52 AM
Yep - sorry, forgot about telling you how to capture the
passed value. Note also that if you have multiple values
assigned to the same variable (such as multiple entries from
a selection list), you'll capture them in an array via the
"request.getParameterValues()" method.