aspose file tools*
The moose likes Struts and the fly likes Problem to submit form using javascript in struts Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Problem to submit form using javascript in struts" Watch "Problem to submit form using javascript in struts" New topic
Author

Problem to submit form using javascript in struts

johny sil
Greenhorn

Joined: Jul 11, 2006
Posts: 13
Hi,

I have a jsp page



Here is my Admin.js



when the aboue jsp is submitted it goes to the saveStatusSetup() in Admin.js, In this saveStatusSetup function is not accepted morethan two spaces in statusName property,It works fine.

But if i give morethan two spaces control will come to this function and then goes focus to the statusName property then immediatly form is submitted ,

How to stop this submission when i give morethan two spaces in statusName property

Help me,

Thanks in advance
Purushoth Thambu
Ranch Hand

Joined: May 24, 2003
Posts: 425
First I think this is not really a struts question. Second, your form is not being submitted. On the button click your calling the javascript function which returns false string which is ultimately being written as the output.

You must write as below


You may want to change the cursor style on mouseover to the image.
[ August 11, 2006: Message edited by: Purushothaman Thambu ]
Souvvik Basu
Ranch Hand

Joined: Apr 05, 2010
Posts: 96
Hi All,

I'm re-opening this discussion, as I got stuck in something very similar. I see the code snippet here shows an attribute 'name' for the <html:form/> tag. But I checked the tag details, and there doesn't seem to be an attribute called name.
Struts Tags - form
My actual problem is this. I have a jsp page that I am submitting using an <html:button/>. On clicking the button, a javascript function gets called, which checks for empty fields. If there are any empty fields, it gives an alert. This part works fine. But when there are no empty fields, I have written a

This function is not working. The form doesn't get submitted.
Can anyone please point out my mistake here?

doesn't seem to be working, because using a name attribute in the form element gives me an error.
Yogesh Lonkar
Ranch Hand

Joined: Jul 17, 2012
Posts: 94

If you are using jQuery then you can probably do as following code


Learning some thing New Every Day
Souvvik Basu
Ranch Hand

Joined: Apr 05, 2010
Posts: 96
I got this. It can be achieved by document.forms[0].submit()
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Problem to submit form using javascript in struts