Win a copy of Modern JavaScript for the Impatient this week in the Server-Side JavaScript and NodeJS forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Bear Bibeault
  • Junilu Lacar
Sheriffs:
  • Jeanne Boyarsky
  • Tim Cooke
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • salvin francis
  • Frits Walraven
Bartenders:
  • Scott Selikoff
  • Piet Souris
  • Carey Brown

Re: using javascript in jsp's

 
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
how's things,

I'm having trouble with a jsp where I want to determine which button was selected on a logout confirmation form I have, at the moment I'm trying to do this by using a javascript function to determine a string value " onClick ", and the pass this value to the corresponding actionform(i'm using jsp's with struts,tomcat,java) as a hidden field, but the value been passed is null, I've tried to get this working for a couple of days now, I�m sure its something small, I just can't see it so any help would be appreciated, nice one, here's the jsp:

<title>Logout Confirmation</title>

<%@ taglib uri="/WEB-INF/struts-html.tld" prefix="html" %>
<%@ taglib uri="/WEB-INF/struts-bean.tld" prefix="bean" %>
<head>
<script type="text/javascript">
function set(target)
{
document.forms.dispatchForm.dispatch.value=target;
<!--document.forms.DispatchForm.submit();-->
}
</script>
</head>

<body>
<html:form styleId="dispatchForm" action="/confirmLogout">
<input name="dispatch" type="hidden" property="dispatch" value="ok"/>
<!--<html:hidden name="dispatch" property="dispatch" value="target"/>-->
<!--<input type="hidden" name="dispatch" value="target">-->
<table class="tborder" width="50%" cellspacing="1" cellpadding="3" align="center">
<tr>
<td colspan="2"> Are you sure you would like to logout?</td>
</tr>
<tr>
<td>
<html:submit property="action" value="OK" onClickage="set('ok');" />
</td>
<td>
<html:submit property="action" value="Cancel" onClickage="set('cancel');" />
</td>
</tr>
</table>
<br/>

</html:form>
</body>

wasn't allowed to post topic without changing to onClickage,
 
permaculture is largely about replacing oil with people. And one tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
    Bookmark Topic Watch Topic
  • New Topic