473,396 Members | 1,743 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,396 software developers and data experts.

Dynamic Input Box

107 100+
I have often seen in various sites where if we select a state in US from a dropdown list, a dynamic input box for postal code is displayed in the form for entering the postal code. How is this achieved? I feel it is done using AJAX but i also would like to know how AJAX works if javascript is disabled in the client's browser. A link to a good tutorials how to achieve this whole process would be a great help.
Mar 17 '09 #1
7 2355
Dormilich
8,658 Expert Mod 8TB
@raamay
not at all.

maybe the programmer wrote a fallback routine using page reloads.
Mar 17 '09 #2
raamay
107 100+
your help is always appreciated?
Mar 17 '09 #3
Dormilich
8,658 Expert Mod 8TB
in what respect? I'm not familiar with postal codes and haven't yet programmed a dynamic drop down box (personally I'd try to google the solution, since it is often done).

I can help you regarding fallback routines (that stuff I have done). further I can tell you to have a look at the Javascript code of those sites, they may give you a hint how to start (though most of the code should be standard AJAX procedure). Even the Javascript Frameworks offer easy-to-use AJAX (helper) functions, so you might have a look there.
Mar 17 '09 #4
raamay
107 100+
i did google the topic but could not find one. so i thought to get a help. Anyway i will see to it. Again thankyou.
Mar 17 '09 #5
Atli
5,058 Expert 4TB
@raamay
There are several ways to achieve something like that, but the simplest way would probably be to just create a JavaScript array of possible values and have the onchange event of the <select> box swap out the postal-code value.

Using AJAX isn't really necessary when dealing with static data like that. At least not when it's a relatively small amount of data.

No JavaScript / AJAX solution will work if the client elects no to allow JavaScript, obviously.
Mar 17 '09 #6
raamay
107 100+
I am in a bit of a puzzled state because some says it wont work while some says it will work irrespective of javascript enabled or disabled in the client's browser. So which one is true.

And Mr Atli, i need your guide to perform the operation as you said using javascript. But i am quite against the idea of using javascript because again if the script is disabled in the client it may loose the purpose and i dont want it to happen. So, how to go about in this case?
Mar 18 '09 #7
TheServant
1,168 Expert 1GB
To answer your first question I think a recap of programming languages is required:
PHP is server side, so once sent it cannot change any page content.
Javascript is client side which can change content (and display of content) after the pages has been sent.
AJAX is basically javascript that can access the server.
Any javascript code must be wrapped in a <script type="text/javascript> tag or else it will not be treated as javascript and therefore not work. If you turn off javascript from your browser, it effectively ignores any code found in those tags.

The only other common way that I know how to dynamically change display of content is via CSS pseudo-classes (like hover). I have not found one for select, but there might be one. You could have in your css:
Expand|Select|Wrap|Line Numbers
  1. input.dynamic_input { display: none; }
  2. form:hover input.dynamic_input { display: block; }
This too is shakey because css is not designed for this and so in this example, your input MUST be within your form tag. You will also need an extra file in the folder that your stylesheet is kept. If you're interested in the hover class, google: csshover3.htc

Long story short, you need to decide if the ~5% of users are worthwhile enough to not use javascript, and work hard to have a nice page with no necessary javascript, or if you can live with slightly fewer visitors and no mobile phone access, to make a javascript required site.
Mar 18 '09 #8

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

Similar topics

4
by: pizzy | last post by:
INTRO: I tried to clean it up for easy reading. I hope I didn't make any mistakes. PROBLEM: WOW, this is some crazy sh!t. I can't get my checkbox (see "TAGSELECTED") to print my textboxes (see...
0
by: Pat Patterson | last post by:
I'm having serious issues with a page I'm developing. I just need some simple help, and was hoping someone might be able to help me out in here. I have a form, that consists of 3 pages of...
3
by: JDPope | last post by:
I have a situation which I cannot get a good lead on how to resolve. One of the applications I support uses the Hibernate software to generate SQL. The app is JAVA with JDBC. In testing the users...
3
by: Leo J. Hart IV | last post by:
OK, here's another question for the experts: I am building a multi-step (3 steps actually) form using a panel for each step and hiding/displaying the appropriate panel/panels depending on which...
7
by: serge | last post by:
How can I run a single SP by asking multiple sales question either by using the logical operator AND for all the questions; or using the logical operator OR for all the questions. So it's always...
2
by: assgar | last post by:
Hi Developemnt on win2003 server. Final server will be linux Apache,Mysql and PHP is being used. I use 2 scripts(form and process). The form displays multiple dynamic rows with chechboxs,...
13
by: coosa | last post by:
Dear all, Using the conio implementation i wanted to create a dynamic string, whereby its size would be determined after each keyboard hit; in other words, i don't want to ask the user to...
0
bmallett
by: bmallett | last post by:
First off, i would like to thank everyone for any and all help with this. That being said, I am having a problem retrieving/posting my dynamic form data. I have a form that has multiple options...
21
by: arnuld | last post by:
I have created a program to print the input words on stdout. Input is taken dynamically from stdin. In each word, each input character is allocated dynamically. I have ran this program with a file...
2
by: yomadhu | last post by:
I created a dynamic form in javascript. Am unable to get those values in to php to display. I need all details. If i add 10 rows the i need to display those all values. Can any one help me for that...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

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.