/    Sign up×
Community /Pin to ProfileBookmark

stop clearing textfield

Hi folks,

I have a quick, hopefully easy question. I have a form with a url field and a button next to it for testing the url. I used an onclick=”testURL(url.value)” to trigger a new window with the url. This works fne, but at some point the text field with the user’s url is cleared, so that when they close the new/test window and come back to the form, their url is gone.

I tried reassigning the value using document.getElementById(“url”).value = url but that didn’t work.

How do I prevent this.

Thanks a bunch!

to post a comment
JavaScript

2 Comments(s)

Copy linkTweet thisAlerts:
@jaffamolApr 23.2007 — This sounds like you have a form tag <form> with one text field and a submit button, but the form does not need to submit anything. By the sounds of it you need to keep the page the same, never change. So remove the form tag and just use <input type="button"> instead of <input type="submit">.

Hope this helps, if not, please post your code.
Copy linkTweet thisAlerts:
@bwalker_lt___gt_authorApr 23.2007 — That was it, thanks!
×

Success!

Help @bwalker_lt___gt_ 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.18,
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,
)...