Sending variable data from one of two text boxes to javascript
Posted
by Enyalius
on Stack Overflow
See other posts from Stack Overflow
or by Enyalius
Published on 2010-06-05T13:16:06Z
Indexed on
2010/06/05
13:22 UTC
Read the original article
Hit count: 172
JavaScript
|html
Greetings, all! I am fairly new to JS (my background is in C++, enterprise languages like assembly and COBOL, and some light .NET), so I was wondering if I could get some advice regarding how to send variable information from one of two text boxes to some javascript and then have the JS do some basic checks and such. Here's the pseudocode for what I am trying to do:
<form = webForm>
<p>
_____________
textboxPeople| searchIcon //a text box to search an online phonebook at my company.
------------- //It has a little "magnifying glass" icon to search
//(onClick), but I would also like them to be able to
//search by hitting the "enter" key on their keyboards.
</p>
<p>
_____________
texboxIntranet| searchIcon //Same as above search textbox, but this one is used if
------------- //the user wishes to search my corporate intranet site.
</form>
So ends the front-facing basic form that I would like to use. Now, onClick or onEnter, I would like the form to pass the contents of the text box used as well as an identifier such as "People" or "Intranet," depending on which box is used, to some basic JS on the back end:
begin JavaScript:
if(identifier = 'People')
fire peopleSearch();
else
if(identifier = 'Intranet')
fire intranetSearch();
function peopleSearch()
{
http://phonebook.corporate.com/query=submittedValue //This will take the person
//that the user submitted in the form and
//place it at the end of a URL, after which
//it will open said complete URL in the
//same window.
}
function intranetSearch()
{
http://intranet.corporate.com/query=submittedValue //This will function in the
//same way as the people search function.
}
end JavaScript
Any thoughts/suggestions would be greatly appreciated. Thank you all in advance!
© Stack Overflow or respective owner