473,387 Members | 1,678 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

using onchange to insert text variable into url?

Hi there,
I am trying to get a zip code lookup script to work. Basically, I want the user to input a zip code and the city and state are displayed without using a button to find it. I already have a zip code table in mysql. if i manually enter the ?zip= into the url, the city and state are displayed. my problem is getting the input into the url.


any suggestions on where to look for solutions?
here is my javascript function (which is probably where my problem is...i'm not well versed in js)
Expand|Select|Wrap|Line Numbers
  1. function checkZip() {
  2. var url = 'ContactEntryForm.php?zip=';
  3. var search = form.contactEntry.getElementById('zip').value;
  4. window.location.href='url+search';
  5.  
here is the code for the input
Expand|Select|Wrap|Line Numbers
  1. print "<tr><td>Zip</td><td><input type='text' name='mzip' id='zip' onchange='checkZip();' /></td>";
  2.  
Thanks!
Mar 19 '08 #1
3 2152
ok, i knew it would happen that I figure it out AFTER i post something. Anyway, if someone else has this problem, i found a solution here:


I had to tweak it a bit (i erased the control.value+=control.value in the reallySetValue javascript function) because it was entering the input twice and therefore not searching the mysql database correctly.
Mar 19 '08 #2
http://ewbi.blogs.com/develops/2004/...nging_a_t.html

sorry :( forgot to put in the url!
Mar 19 '08 #3
acoder
16,027 Expert Mod 8TB
Was that the only problem?

Surely,
Expand|Select|Wrap|Line Numbers
  1. window.location.href='url+search';
should be
Expand|Select|Wrap|Line Numbers
  1. window.location.href=url+search;
?
Mar 20 '08 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: kie | last post by:
hello, when i create elements and want to assign events to them, i have realised that if the function assigned to that element has no parameters, then the parent node values can be attained. ...
1
by: Young-Soo Roh | last post by:
Hi. I need to get simple script working. I have many select object. When I select a different option, I would like to change the value of corresponding text input field. How can I do this using...
8
by: Mattias Campe | last post by:
Hello, On http://student.ugent.be/astrid/bewoners.php I got the problem that I want Javascript to let my browser go to http://student.ugent.be/astrid/bewoners.php?beginAcjaar=2002 when I select...
4
by: Omar | last post by:
Hi, Could you please tell me what am I doing wrong in the next sentence? <select name='id' onChange="window.location='dePaso.jsp?nombre=id&valor="+this.options.value+"'"> TIA
0
by: amrhi | last post by:
Hy Guys , Can anybody help me ? I try to make small web database in my unit. Some of fields have on change behaviour to get other data that automatically filled other text field. But when i try to...
4
by: J MCallister | last post by:
Hello, I am working on a shopping cart where the viewer sees a dropdown with shipping options, each with a price. Elsewhere on the page is a display of the total. I am working on having the...
2
by: shivendravikramsingh | last post by:
hi friends, i m using a ajax function for retrieving some values from a database table,and display the values in required field,my prob is that the ajax function i m using is working f9 once,but if...
7
by: TriAdmin | last post by:
I am working with a system that allow me to add custom fields but I can not add OnChange() language to the custom fields. So I want to have a function in the header that recognizes when fieldx is...
5
by: thatcollegeguy | last post by:
Below are my 3php and 2js files. I create a table using ajax/php and then want to change the values in the tables add(+ number for teamid) id's for each specific td in the table. I don't know...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.