/    Sign up×
Community /Pin to ProfileBookmark

New to JavaScript, need help with very basic script

I’m very new to javascript & just starting to learn. In my company I created a small web page for our “Active Desktop” on our PCs that has links to common used programs & web pages.

We have a Intranet for our Staff Directory. What I’d like to do is create a small form on there that they can enter somoene last name & click submit & takes that & places it within a string to be searched. For example here is a search string.

[url]http://www.host.com?search=nametosearchhere%jklejleee[/url] (as you can tell I made that up)

I want to have “http://www.host.com?search=” as a constant variable & “%jklejleee” as a constant variable & have the ability to enter in text to replace “nametosearchhere” then when you click submit it adds them all together & takes you to that link. I understand part of it but can’t figure out quite how to do this. Any help at all would be fantasitc.

Here is what I have, found the script that used check boxs to select a few choices to take you to right spot, I tried to edit it but not doing it right.

[QUOTE]

<!DOCTYPE HTML PUBLIC “-//W3C//DTD HTML 4.01 Transitional//EN”>
<html>
<head>
<title>Untitled Document</title>
<meta http-equiv=”Content-Type” content=”text/html; charset=iso-8859-1″>
<SCRIPT LANGUAGE=”JavaScript”>
site1=”https://statusone.intranets.com/dbapp/dbapp.aspx?_command=list&_appid=206762&_clientInfo=%3cclientInfo%3e%3cViewID%3e1539%3c%2fViewID%3e%3cSubSearch%3e“;
site2=”%3c%2fSubSearch%3e%3c_appid%3e206762%3c%2f_appid%3e%3c%2fclientInfo%3e”;
function combineMenus(frm, menu1) {
with (frm) {
for (var i = 0; i < document.menufrm.menu1.length; i++) {
if (document.menufrm.menu1[i].checked) {
str = document.menufrm.menu1[i].value;
break;
}
}
url = site1 + str + site2;
window.location.href = url;
}
}
// End –>
</script>

</head>

<body>
<FORM NAME=”menufrm”>
<INPUT type=”text” NAME=”menu1″>Name
<P>
<INPUT TYPE=”button” VALUE=”Select” onClick=”combineMenus(this.form, this.form.menu1)”>
</FORM>
</body>
</html>

[/QUOTE]

to post a comment
JavaScript

5 Comments(s)

Copy linkTweet thisAlerts:
@AdamGundryJun 16.2004 — Try something like this:

<form name="menufrm" onsubmit="location.href = 'http://www.example.com/example?search=' + document.menufrm.menu1.value + '&foo=bar'; return false;">

<input type="text" name="menu1">

<button type="submit">Lookup</button>

</form>

Adam
Copy linkTweet thisAlerts:
@sphillipsauthorJun 16.2004 — Absolutly perfect, I was thinking way to hard about that, way simplar than I thought. One more thing. I tried making it so it would open other webpage when you click "Look Up" I added a target="_blank" but that didn't seem to make a difference. Any idea.
Copy linkTweet thisAlerts:
@FangJun 16.2004 — Did you put the [I]target="_blank"[/I] in the form element?
Copy linkTweet thisAlerts:
@AdamGundryJun 16.2004 — Do you mean open the results in a new window? If so, replace this

location.href = 'http://www.example.com/example?search=' + document.menufrm.menu1.value + '&foo=bar';

with this

window.open('http://www.example.com/example?search=' + document.menufrm.menu1.value + '&foo=bar');

Adam
Copy linkTweet thisAlerts:
@sphillipsauthorJun 16.2004 — PERFECT !!!!! I can't thank you enough.
×

Success!

Help @sphillips 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.19,
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,
)...