473,714 Members | 2,605 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Dynamic Input Box

107 New Member
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 2371
Dormilich
8,658 Recognized Expert Moderator Expert
@raamay
not at all.

maybe the programmer wrote a fallback routine using page reloads.
Mar 17 '09 #2
raamay
107 New Member
your help is always appreciated?
Mar 17 '09 #3
Dormilich
8,658 Recognized Expert Moderator Expert
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 New Member
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 Recognized Expert Expert
@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 New Member
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 Recognized Expert Top Contributor
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
2149
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 "TAG#") when more than 1 number (see "VLANS") is inputed into my form. QUESTION: How do I make my dynamic form have a dynamic input box(which is created by checking the checkbox and calling the functionC1) inside it and still be able to pass the...
0
1976
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 fields. I'd like to create a page in which all of this is stored as you move along as hidden variables, until the end, when the user submits. I can't figure out one thing: I have dynamic form elements (dropdowns), that I'd like to use instead of...
3
9641
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 see no problems and think the app is running okay. I turned a database monitor on the app and see that the database is getting SQL return coes of -301 for a variety of database accesses (some times the same access works, okay other times -301)....
3
3980
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 step you're on. This all works fine, but I ran into some trouble when I started creating controls dynamically in my code-behind file. Each panel contains a table which is filled with various radio buttons, text fields and the such which are...
7
3388
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 either AND or OR but never mixed together. We can use Northwind database for my question, it is very similar to the structure of the problem on the database I am working on. IF(SELECT OBJECT_ID('REPORT')) IS NOT NULL DROP TABLE REPORT_SELECTION
2
7052
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, input box for units of service, description of the service and each row has its own dropdown list of unit fees that apply. Each dynamically created row will return 3 values fee1_choice, fee1_unit and fee1_money. Note The above informaton is...
13
2030
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 specify the the size, but rather keep him/her typing and after each keyboard hit, the function getch() determines whether he/she entered the ENTER key to end the process; otherwise, increases the dynamic size or also decreases it if the back key was...
0
3389
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 within options. I have everything being dynamically named from the previously dynamically named element. (I hope this makes sense.) I am not able to retrieve any of the dynamically created values. I can view them on the source page but can't pull them...
21
2906
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 containing a *single* word made of 25525500 letters and this program works fine on it. I will welcome any suggestions for improvement. /* * A program that will ask the user for input and then will print the words on stdout * and will also...
2
3328
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 code. <HTML> <HEAD> <TITLE> Add/Remove dynamic rows in HTML table </TITLE> <script type="text/javascript" src="script.js"> // JavaScript Document var c=0;
0
9171
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
9073
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9013
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7947
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
4463
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4719
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3156
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
2518
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2108
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.