At 1:02 PM -0800 11/8/04, Srilatha Salla wrote:
Hi,

In my application there is a jsp page

for example menu.jsp which has
<html:form action="/nfoSave">
there is a link <html:link page="/HoursMenu.do" >Menu Hours</html:link> in the menu.jsp which goes to the hours.jsp


I want to submit the form when i click the link, so that I can access the values entered in the menu.jsp. in HoursMenuAction.

I tried <html:link page="/HoursMenu.do" onclick="document.menuForm.submit()">
but i couldnot access the form properties. I get null values. So, how can i submit the form and access its properties.



I'm not entirely sure which values you mean when you say "I get null values." but I suspect that one problem you'll have, on some browsers at least, is that your link onclick handler doesn't return false. This is likely to result in the browser attempting to fill an HTTP request from ..../HoursMenu.do in addition to any form submission.


I would start by recommending you call a JavaScript method in your onclick handler rather than directly submitting the form, because I think that's more maintainable over time. Then in that method, you could also invoke any client-side form validation code before returning. something like this

<script>
function hoursMenuClicked() {
  var form = document.menuForm;
  if (form && validateForm(form)) form.submit();
  return false;
}
</script>
<html:link page="/HoursMenu.do" onclick="return hoursMenuClicked();">

Perhaps this isn't addressing your main issue, but in general, we have lots of apps that use a javascript handler to submit a form without any hitches, so I'm suspecting it's something else you're overlooking.

joe


--
Joe Germuska [EMAIL PROTECTED] http://blog.germuska.com "In fact, when I die, if I don't hear 'A Love Supreme,' I'll turn back; I'll know I'm in the wrong place."
- Carlos Santana

Reply via email to