Solved

clear text boxes on web page when hit 'back' button

Posted on 2009-07-04
3
332 Views
Last Modified: 2012-05-07
I have two jsp files. The first jsp accept user input in form and then it calls the second jsp using Form action. And in the second JSP, it passes those two inputs to my Java Bean program, and then accept the output again from java bean and show the result using jstl.

So I input some data in the first html and then after hit the button, then it shows the result in the second page.

What I want to ask is: when I click on the 'back' button of the browser, the value I put in those text boxes are still there, what I want to do is every time I open that page, clear the text boxes and the curso will be in the first text box. How can I do this?

Thanks!!

Here's my two jsp files:
Search-input.jsp
 
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <link href="wixIndex.css" rel="stylesheet" type="text/css">
        <title>Web Index</title>
    </head>
    <body>
 
		<%@ include file="header.html" %>
 
        <form name="Name Input Form" action="search-result.jsp">
        	<br> &nbsp;
            <font color="0066CC" size="2"><b>KEYWORD</b></font>  
            &nbsp; &nbsp;
            <input type="text" name="keyword" size="80"/>
            <br><br> &nbsp;
            <font color="0066CC" size="2"><b>CONTENT</b></font>  
            &nbsp; &nbsp;
            <input type="text" name="kwinfo" size="80"/>
            <br><br>
 
            <input type="submit" value="SEARCH" class="button"/>
            <br><br>
 
        </form>
 
    </body>
</html>
 
...................................................................................................................................
...................................................................................................................................
 
Search-result.jsp
 
<%@ taglib prefix="fm" uri="/WEB-INF/matcher.tld"%>
 
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
 
<jsp:useBean id="matcher" scope="request" class="com.webIndex.match.FindMatch"/>
 
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <link href="wixIndex.css" rel="stylesheet" type="text/css">
        <title>Web Index</title>
    </head>
    
	<body>
	
		<%@ include file="header.html" %>
		
	   	<jsp:setProperty name="matcher" property="*" />  
	
		${fm:funMatcher(matcher, matcher.keyword, matcher.kwinfo)}
    	
	</body>
</html>

Open in new window

0
Comment
Question by:Juuno
[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
  • 2
3 Comments
 
LVL 12

Assisted Solution

by:Chad Haney
Chad Haney earned 500 total points
ID: 24778843
Try this:

<body onLoad="javascript:document.forms[0].reset()">
0
 

Author Comment

by:Juuno
ID: 24778861
Yes!!
It works to clear the text boxes. Thanks.
But how can I set the cursor in the first text box in every onLoad?
Thanks!!
0
 
LVL 12

Accepted Solution

by:
Chad Haney earned 500 total points
ID: 24778865
<body onLoad="javascript:document.forms[0].reset();document.forms[0].keyword.focus()">
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Is your Office 365 signature not working the way you want it to? Are signature updates taking up too much of your time? Let's run through the most common problems that an IT administrator can encounter when dealing with Office 365 email signatures.
Today, the web development industry is booming, and many people consider it to be their vocation. The question you may be asking yourself is – how do I become a web developer?
In this tutorial viewers will learn how to embed an audio file in a webpage using HTML5. Ensure your DOCTYPE declaration is set to HTML5: : The declaration should display (CODE) HTML5 is supported by the most recent versions of all major browsers…
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

728 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