Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

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

Posted on 2006-10-19
10
Medium Priority
?
517 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 6
  • 3
10 Comments
 
LVL 16

Expert Comment

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

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

Author Comment

by:ly_uwo
ID: 17770945
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
ID: 17770968
Okay,

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

Give me a sec....
0
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 
LVL 16

Expert Comment

by:suprapto45
ID: 17771004
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
ID: 17771464
Thanks. I will try it.
0
 
LVL 16

Expert Comment

by:suprapto45
ID: 17771540
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 800 total points
ID: 17771575
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 200 total points
ID: 17777854
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
ID: 17778573
Thank both of  you!
0
 
LVL 16

Expert Comment

by:suprapto45
ID: 17779128
Glad I could help :)
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

An overview of cyber security, cyber crime, and personal protection against hackers. Includes a brief summary of the Equifax breach and why everyone should be aware of it. Other subjects include: how cyber security has failed to advance with technol…
Tech spooks aren't just for those who are tech savvy, it also happens to those of us running a business. Check out the top tech spooks for business owners.
Video by: ITPro.TV
In this episode Don builds upon the troubleshooting techniques by demonstrating how to properly monitor a vSphere deployment to detect problems before they occur. He begins the show using tools found within the vSphere suite as ends the show demonst…
In this video, Percona Director of Solution Engineering Jon Tobin discusses the function and features of Percona Server for MongoDB. How Percona can help Percona can help you determine if Percona Server for MongoDB is the right solution for …
Suggested Courses

610 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