Click to See Complete Forum and Search --> : submitting page to itself problem


webtekie
03-22-2004, 10:37 AM
Hi guys,

I know this is a PHP forum, but I need help with a JSP problem. I feel people here are very helpful and since this is more of a how-to-do question rather than language specific I thought to try my luck.
I am trying to write a page that uses DHTML tabs. What I have are two tabs, one has input field and other displays results of database query based on value sumbitted. I am submitting page to itself and getting input parameter from request object. I also have code so that when form on first tab is submitted, tab focus is automatically set to second tab. The problem is that once I submit the page and try to get the value of input field, I can't get the value.
Is what I am trying to do possible? Could it be that when I focus on second tab the value is displayed before it's received from request object that's why I can't catch it?

Here is the code:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<%
String custName = "";
if((request.getParameter("isSubmit") == null)?false:true)
custName = request.getParameter("custLastName");
%>
<html>
<head>
<title>DHTML Tabs using DOM</title>
<script language="javascript" type="text/javascript" src="include/domtab.js"></script>
<link rel="StyleSheet" href="include/basictabs.css" type="text/css" />
<style type="text/css">@import "include/domtabs.css";</style>
<script>
function doQuery(){
if(document.custInfo.custLastName.value == ""){
alert('Please enter customer\'s last name');
return 0;
}
domTab(2);
return false;
}
</script>
</head>
<body onload="domTab(1)"><a name="top"></a><!-- necessary to send Netscape users back to the top -->
<div id="contentblock1" class="tab">
<table width="500" height="400" border="0" align="center">
<tr>
<td align="center">
<form name="custInfo" action="<%=request.getRequestURI()%>" onSubmit="doQuery();return false;">
<input type="text" name="custLastName">
<input type="submit" value="search">
<input type="hidden" name="isSubmit" value="true">
</form>
</td>
</tr>
</table>
</div>
<div id="contentblock2" class="tab">
<table width="500" height="400">
<tr>
<td>
<%out.println("Last = " + custName);%>
</td>
</tr>
</table>
</div>
<a href="#target1" onclick="domTab(1)" id="link1" class="tablink">Info</a>
<a href="#target2" onclick="domTab(2)" id="link2" class="tablink">Customisation</a>
</body>
</html>

Any help is greatly appreciated.

thanks,
webtekie

webtekie
03-22-2004, 11:16 AM
ok, got it.
Need to put document.getElementById('custInfo').submit(); when submitting the page.
Have another question, but it's more of JavaScript issue.

thanks,
webtekie