/    Sign up×
Community /Pin to ProfileBookmark

Displaying textbox values even after doing history.back which takes to the empty form

Hi,

I am having one html form for search utility. Once i do the search by typing some value in the textbox, results are getting displayed.

Now i have one back link which goes back to the previous page. When i click this it is going back to the previous page, but still displays the search text which is not desired. Form should be blank as per the initial state.

This is happening only in IE and NN. Firefox is ok.

Any solution?

Thanks,
Divyesh

to post a comment
HTML

3 Comments(s)

Copy linkTweet thisAlerts:
@gooncorpAug 01.2006 — there is some sort of <body onload="..."> command where you reset all forms, I can't remember what this is but I think I saw it posted in a thread a few days ago.
Copy linkTweet thisAlerts:
@divyesh_82authorAug 02.2006 — Hi Thanks for reply.

I can't do anything which clears the text box. Reason is if i do the two consequtive search then after second search when i go back textbox should display the previous search text. But it shows the second search text only.

Any other solution?

Thanks,

Divyesh
Copy linkTweet thisAlerts:
@AcousticJamesAug 02.2006 — Your best bet is to create some kind of javascript function that is called in the <body onload=""> event that finds the text box (getElementById() function should work) and clear the text from it, if there is any. What's happening is that when you hit the back button, all the browser is doing is recalling the page from the cache, which will contain the search term in the field. Calling a function that clears the form field (setting its value to "") is the best way.

Basically, you want something like this. Let's say your input element has an id of "search_term". Your javascript function could look something like this:[CODE]
function clear_search()
{
var search_box = document.getElementById("search_term");
if (search_box.value != "") // text box has something in it
{
search_box.setAttribute("value", "");
}
}[/CODE]


Then, in the <body> tag, you do this:

<body onload="clear_search();">

Now, that's untested, but it should get you going in the right direction.

James
×

Success!

Help @divyesh_82 spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.24,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...