Solved

In struts jsp page, how to use javascript to reset all the fields in the form

Posted on 2006-10-19
10
462 Views
Last Modified: 2010-04-01
Hi, how to use javascript to reset all the fields in the form? I have three selection list and one text field. I am using <html:form> tag. How can I use javascript to clear them?
0
Comment
Question by:ly_uwo
  • 6
  • 3
10 Comments
 
LVL 16

Expert Comment

by:suprapto45
Comment Utility
No need to use JavaScript. You can use <html:reset />

http://www.roseindia.net/struts/strutsHtmlTags.shtml
0
 

Author Comment

by:ly_uwo
Comment Utility
looks good. However, the selections can't be changed. They are defined by struts code like <logic:equal> <option value=** selected > <logic:equal> <logic:notequal> <option value=** > </logic:notEqual>.

Any other ideas? Or somehow similar examples? Thanks.
 
0
 
LVL 16

Expert Comment

by:suprapto45
Comment Utility
Okay,

If that is not possible then you have to use JavaScript.

Give me a sec....
0
 
LVL 16

Expert Comment

by:suprapto45
Comment Utility
Can you try to add the <html:button> that has the onClick attribute to execute some JavaScript? Because I am not using Struts at the moment.
0
 

Author Comment

by:ly_uwo
Comment Utility
Thanks. I will try it.
0
Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

 
LVL 16

Expert Comment

by:suprapto45
Comment Utility
Sure,

Sorry that I do not have Struts now. If you are in trouble again, please let me know.
0
 
LVL 16

Accepted Solution

by:
suprapto45 earned 200 total points
Comment Utility
Just a thing that I normally do. I am not sure whether it works or not.

<script language="JavaScript" type="text/JavaScript">    
    function resetForm() {
         alert('coming here');
         // resetting here but not sure how to get the
        document.getElementById("test").value = '';
    }
</script>

<%-- name may be useful here --%>
<html:text property="test" size="10" name="test" />
<html:button property="submit" value="Submit" onclick="return resetForm();" />
0
 
LVL 10

Assisted Solution

by:jaggernat
jaggernat earned 50 total points
Comment Utility
suprapto's code should help. Although , if you want to reset a few selected fields without reseting the entire page, you can do that by getting the value of each field from the form-bean and reseting them in javascript.
0
 

Author Comment

by:ly_uwo
Comment Utility
Thank both of  you!
0
 
LVL 16

Expert Comment

by:suprapto45
Comment Utility
Glad I could help :)
0

Featured Post

Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

Join & Write a Comment

Suggested Solutions

Describes a method of obtaining an object variable to an already running instance of Microsoft Access so that it can be controlled via automation.
Veeam Backup & Replication has added a new integration – Veeam Backup for Microsoft Office 365.  In this blog, we will discuss how you can benefit from Office 365 email backup with the Veeam’s new product and try to shed some light on the needs and …
Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the file…
This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're looking for how to monitor bandwidth using netflow or packet s…

771 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now