Solved

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

Posted on 2009-07-04
3
323 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
  • 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

What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
HTML 5 video and audio or Flash 1 30
Menu Inconsistent 3 21
Link SQL table to Webpage 9 38
Bootstrap 3 icons 3 12
Showing your events from Google Calendar in Google Maps Why? I travel all week and I thought it would be ideal if staff in office knew where I was based on my calendar. (OK real reason: my son wanted to see where I would be working, and I thoug…
Use these top 10 tips to master the art of email signature design. Create an email signature design that will easily wow recipients, promote your brand and highlight your professionalism.
The viewer will the learn the benefit of plain text editors and code an HTML5 based template for use in further tutorials.
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 …

757 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

19 Experts available now in Live!

Get 1:1 Help Now