Cmdr_Raptor
asked on
JSP, Servlets and links
On a JSP website I'm developing, I got code looking like this:
<form method='post' action='../servlet/Navigas jonServlet ' target="main">
<input type='hidden' name='doThis' value='start' />
<input type="submit" value="Hjem" />
</form>
This is one of several buttons on a menu. So depending on what value this button has, the servlet (NavigasjonServlet) find the proper .jsp page yo display in the i Frame (target="main").
How can I make the servlet still decide what page to display, but by using links instead og buttons?
<form method='post' action='../servlet/Navigas
<input type='hidden' name='doThis' value='start' />
<input type="submit" value="Hjem" />
</form>
This is one of several buttons on a menu. So depending on what value this button has, the servlet (NavigasjonServlet) find the proper .jsp page yo display in the i Frame (target="main").
How can I make the servlet still decide what page to display, but by using links instead og buttons?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
thanassis : I can't seem to get that to work. Could you describe it abit more?
umangjoshi : I was trying to avoid using buttons...
umangjoshi : I was trying to avoid using buttons...
ASKER
thanassis : My bad. I got it to work on one link now. However, the moment I create a second link, there is created an error. Is it nessecary to make one function for each link?
Write:
<a href="#" onClick="go()"><img src="..."></a>
instead of:
<a href="#" onClick="go()">Go back <img src="...">go</a>
Did you give a name to your form e.g "form1"?
<form method='post' name = 'form1' action='../servlet/Navigas jonServlet ' target="main">
what was your problem, explain a little
<a href="#" onClick="go()"><img src="..."></a>
instead of:
<a href="#" onClick="go()">Go back <img src="...">go</a>
Did you give a name to your form e.g "form1"?
<form method='post' name = 'form1' action='../servlet/Navigas
what was your problem, explain a little
Yes, every link different function
ASKER
Created a go1(), go2() etc function for every link. Got it working now. Tnx :)
-------------
<head>
<script language="JavaScript">
function call1(f)
{
f.action = 'path of jsp1 or servlet1';
f.submit();
}
function call2(f)
{
f.action = 'path of jsp2 or servlet2';
f.submit();
}
</script>
</head>
<body>
<form name="f" method="post" action="../servlet/Navigas
<input type="button" onClick="call1(f)" value="Add">
<input type="button" onClick="call2(f)" value="Edit">
</form>