Sometimes you need to allow users to choose a value from a select box (pull down menu) and
have the value they chose show up in another input field of type text (for example).
Here is how to do it :
Add this Jscript function to your page.
<SCRIPT LANGUAGE="JavaScript">
function UpdateField(index) {
form=document.FormName;
form.TextFieldName.value = form.SelectFieldName.options[index].text
}
</SCRIPT>
o FormName is the name of your <FORM>
o TextFieldName is the name of the field you want the Selected text to be in.
o SelectFieldName is the name of the Select field you are choosing from.
The call to the function should be like this :
<SELECT onChange="UpdateField(this.selectedIndex)"; NAME="SelectFieldName">
In case you want the value of the field and not the text that is shown in the pull down menu,
all you need to change is the next line in the function :
form.TextFieldName.value = form.SelectFieldName.options[index].text
to
form.TextFieldName.value = form.SelectFieldName.options[index].value
Java Script which implements a Clock (Client Side) Categories : Java Script , Date Time Email Address Protection (Avoide SPAM) Categories : Java Script , Email , Encryption Check if Javascript is Enabled or Disabled - Works in all Browsers Categories : Java Script , HTML , Web Browsers Page Loading Message shown during the time your site's page is being loaded. Categories : HTML , CSS , Java Script Alert in JavaScript and Trace in Flash Action script are two commands that I find very much useful for tracking and debugging errors in my scripts. Unfortunately, there is no such option in PHP. Categories : PHP , Java Script , Debugging Builds JavaScript that updates the contents of one selector based on another. Categories : HTML , Java Script , PHP , Complete Programs , General Javascript Background Scroller Categories : Java Script , CSS , HTML Clock at Status Bar Categories : Java Script , HTML , Date Time Get your browser details using javascript Categories : Java Script , Beginner Guides , Browsers Remote Scripting: send form POST data to a script and insert the results into a page without refreshing the page. Categories : PHP , AJAX , HTML and PHP , Java Script Linked comboboxes with php-mysql & javascript Categories : PHP , Java Script , Databases , MySQL PHP3 generated gif / javascript mouseover. Categories : PHP , Java Script , MySQL Store, retrieve and delete cookies using JavaScript. Categories : Java Script , Cookies , Beginner Guides , Cookies JAVASCRIPT interface class to the eBusiness Charts generatation remote service. Categories : Java Script , Graphics , Charts and Graphs Show hide table rows to make dynamic forms Categories : Beginner Guides , Java Script , Form Processing , HTTP