Auto-Populate Text Field Based On DropDown List Selection

Dec 3, 2009

I have set up my website quite some time ago that has served its purpose very well, however I will now be adding an order form functionality. So far, by reading books and traversing forums, I have been able to develop a page where the user
1.Enters data into the required fields, that is then submitted to a MYSQL database via PHP,
2.Can retrieve orders that are stored in the database,
3.Delete orders that are stored in the database.

I have wamp installed on my computer as the webserver. I have also incorporated two drop down lists that both retrieve their values from tables within the database. The first drop down list retrieves the Australian States that I have stored in a table, and once the submit button is pressed, it stores the State that is selected to a separate table. This drop down list functions as it should. An extract from "From Place an order.php"

<?php
$dbcnx = @mysql_connect('localhost', 'root', 'tingling');
if (!$dbcnx) {
exit('<p>Unable to connect to the ' .
'database server at this time.</p>');
} .....

The second drop down list retrieves product names from a table that contains products and their prices. What I would like to happen, is that when the product is selected from this drop down list, a text box is automatically filled with its corresponding price. I had this drop down list working as per the "States" drop down list, but could not get it to auto populate the text field. I got some assistance from a friend and was able to get the text box to auto populate with its corresponding price, however when the page was submitted to the database, the "id" number of the product name from the drop down list was stored, and not the product name.

<select name="productSelection" onchange = "getProductDetails(this)">
<option selected value="1product">Select Product</option>
<?php
$products1 = @mysql_query('SELECT * FROM products');
if (!$products1) {
exit('<p>Unable to obtain author list from the database.</p>'); .....

View 9 Replies


ADVERTISEMENT

Auto Text Field Populate Based On Dropdown

Feb 22, 2011

I've looked around and from what I can tell, the code seems right. Basically crating a JS array and passing PHP values to it to use in an onChange to fill a text field. The dropdown gets populated fine but the text field does not autopopulate onChange. I'm not too fluent with JS but have a good analytical mind and from what I can see, the logic seems right.

<?php
include('connectdb.php');
$CENTRE = $_SESSION['centreAFB'];
$qryFormList = mysql_query("SELECT * FROM tblLogin WHERE ACCT_TYPE = '2' AND loginCENTRE = '$CENTRE' ORDER BY loginNOM");
echo "<script type='text/javascript'> var formCourriel = new Array()";
while($resFormList = mysql_fetch_assoc($qryFormList))
[Code]....

View 7 Replies View Related

JQuery :: Populate A Dynamic Dropdown List Based On Another Dynamic Drop Down Selection?

Jun 29, 2010

how to populate a dropdown based on Another dropdown selection. This all should be a dynamic. Eg: I have two text boxes one is TechID and other is JOB ID. When I start typing Tech ID it suggests me the list of IDs which start with the input string i have put in Tech textbox. When i select the Tech ID the jobs associated to that Tech ID should be displayed in JOB ID text box as a dropdown list.

View 1 Replies View Related

Disable Text Field Based On Dropdown Menu Selection

Feb 18, 2009

I have a simple form - I want to disable the text field if Choice 2 from the dropdown menu is selected. I have this working with the code below, but for some reason if I go back and select choice 1 after selecting choice 2 the text field remains disabled. I only want it to be disabled if choice 2 is selected.

View 5 Replies View Related

AJAX :: Populate An ASP List Box Based On Selection Of A Previous List Box?

Mar 7, 2011

I have 3 ASP list boxes. I would like to populate the second list box based on the selection in the first list box and based on the selection in the second list box, populate the third. I would like to do this using AJAX. How can I do it? Can someone please give me the code snippet as I am a complete noob when it comes to AJAX and I kinda am running outta time to finish implementing it. Additionally, should I use ASP boxes or HTML <select> tag?

View 4 Replies View Related

Populate Checkboxes Based On The Dropdown Menu Selection?

Jun 29, 2011

how to populate checkboxes based on the dropdown menu selection

View 2 Replies View Related

JQuery :: Populate Textbox Based On Dropdown Selection Index Change

Jun 26, 2011

based on dropdown selection i need to fill two text box in sharepoint 2007 using jquery.

View 1 Replies View Related

JQuery :: Populate Textbox Based On Dropdown Selection Index Change?

Jun 28, 2011

populate textbox based on dropdown selection index change. populate two text box on the dropdown box value selected index change dynamically.

View 2 Replies View Related

Disable A Dropdown List Based On Selection In Another Dropdown List?

Apr 20, 2011

I have two dropdown lists with the second one being dependent on the selection in the first.

Options in list 1: 1,3 or 4

List two should be enabled when 3 or 4 is selected in list 1.

So far so good, managed to get it to work with only one set of lists, but I actually have 18 of those sets in this form:

<select name="fw[$i]" id="fw[$i]">
<option value="1">FWH</option>
<option value="3">links</option>
<option value="4">rechts</option>

[Code]....

I'm not that adept in javascript programming, more like a trial and error guy, how has hit the wall with this problem.

View 20 Replies View Related

JQuery :: (.) Period In Value Field - Show/hide A Div Based Based On The Selection Made Via A Dropdown

Apr 9, 2010

Im using a jQuery script to show/hide a div based based on the selection made via a dropdown.

<script type="text/javascript" src="jquery-1.3.2.min.js"></script>

The problem im having is that the value used in the dropdown lists are price values eg 10.00

Consequently jQuery seems to interprit these as css notations, meaning the code doesnt work.

View 4 Replies View Related

Update A Dropdown List Based On The Selection Of A Previous List

Aug 16, 2010

i am writing a script that will update a dropdown list based on the selection of a previous list. the script is run by a PHP script, so instead of posting the PHP, i will post an example client-side script. the hierachy is: category, sub category, brand (but sometimes there exists no sub category and the PHP script queries and adds brands instead) everything works correctly, except for one major issue: you can not change the selection of the third (brand) box this could be an easy fix for some coders, but i am not experienced in javascript and could really use some help. here is an example script, sorry it is so long

[Code]...

View 4 Replies View Related

PHP Drop Down List Selection Populates Second Dropdown List Or Text Box?

Jul 13, 2011

I have been struggling on a bit of code for a while now. I need to populate a second drop down list (Region) based upon the selection of the first (County).I have found a piece of code that works on its own and have adapted to suit my needs - see below. However, when I drop it into my main page the javascript is not working. It's because of the formObject but I just don't know enough to resolve this! Furthermore, I need the textboxes the user has already completed in the form to retain their value once the javascript kicks in as the completed form will submit to a database.This piece of code is working well . . . .

<?php

$link = mysql_connect('myhost', 'myusername', 'mypassword') or die('Could not connect: ' . mysql_error());
mysql_select_db('mydatabase') or die('Could not select database');[code]......

View 2 Replies View Related

Appear / Disappear Text Box Based On Selection From A Dropdown

Mar 25, 2011

I have a page on which I have 2 dropdowns. Both are similar. I have a piece of code that whill make a textbox appear if we select "list Box" as the option in the drop down. But for some reason, the first dropdown works fine, but for the second dropdown, the textbox is always there on page load. The code that I am presenting can be copied as a HTML page and you will know what I am referring to.

<html>
<script type="text/javascript">
function showfield(name){
if(name=='lstbox')document.getElementById('div1').style.display="block";
else document.getElementById('div1').style.display="none";
}
function hidefield() {
[Code]...

View 2 Replies View Related

Appear / Disappear Text Box Based On Selection Of Dropdown Menu

Apr 12, 2011

I have a Javascript function that allows the display of a textbox upon selecting an option from a dropdown menu. In my case when a user selects listbox as the option, the text box appears. I want the same thing to happen when another option (checkbox) is selected. when I repeat the JAVAscript code, the first textbox(listbox's textbox) appears irrespective of which option(listbox, checkbox) I select. I want to be able to appear/disappear only the respective textbox. Here is my code.

<html>
<script type="text/javascript" >
function showfield(name){
if(name=='lstbox')document.getElementById('div1').style.display="block";
else document.getElementById('div1').style.display="none";
}
function hidefield() {
[Code]....

View 2 Replies View Related

Populate Text Field From Drop Down List

May 1, 2009

how to create a somewhat simple form. The form will have text fields for 'Name', 'Phone', etc. What I want is to have a drop down list, which has different insurances to choose from (i.e. Medical Insurance, Dental Insurance, Senior products), and say when I choose 'Senior Products', new text fields pop up within the form to add their 'Address' and click a checkbox that states they authorize to be contacted. These new fields aren't visible unless they choose 'Senior Products' from the drop down list.

View 6 Replies View Related

Pre Populate Text Field Based On Another Text Field

Jan 23, 2010

I'm developing a web page. It includes 2 text boxes. One text box for city and another text box for std code. I wrote the code for auto suggestion to city. Now i want to pre populate the STD code when ever a known city is selected (when city is selected from the recommendations displayed for city field).

View 8 Replies View Related

Fill Value Of Text Field Based On Dropdown?

Sep 25, 2010

What im trying to do is for each item selected from the drop down, display its value in a text box (GAC). I have attached a picture of the image to clarify.

The drop down items are populated from a database, and each item has an associated GAC value. The remaining inputs are user supplied and all the inputs including the drop down item and its value are is stored in a different table in the database.

View 1 Replies View Related

Show/Hide Text And Form Field Based On Drop Down Selection

Jul 20, 2005

I'm trying to show/hide a simple piece of text and a text field on a
form based on what choice is made from a drop down box.

<select name="dropdown" size="1">
<option selected value="">Please make a selection</option>
<option value="1">Choice 1</option>
<option value="2">Choice 2</option>
<option value="3">Choice 3</option>
<option value="4">Other</option>
</select>

i.e. if Choice 2 is selected I'd like to display a new <tr> with the
following:

<tr>
<td>New text field:</td>
<td><input name="newField" type="text size="20"></td>
</tr>

if any other choices are made, I don't want to display anything.
I've tried several onchange() functions but can't achieve what I'm
looking for.

View 6 Replies View Related

How To Auto Populate A Dropdown Tab.

Oct 5, 2005

I am creating a site that has to do w/ pets. I want users to be able to select the type of pet they have from the first dropdown and then select from the second dropdown from choices dependant upon what they chose in the first dropdown.

So if they choose 'dog' as a pet type in the first drop down. I want the second drop down to display 'dog breeds'. If the choose 'cat' as a pet type I want the second drop down to display 'cat breeds'. This is what I have thus far.

My data table: Contains PetType(Column 1) and BreedType(Column 2)

My page form calls these two criteria Pet Type and Breed

I want to be able to insert this script into my form's HTML footer. Code:

View 1 Replies View Related

Auto Populate Textfield Via Dropdown Box?

Feb 11, 2009

What I'm trying to do is auto populate the foreign key with help of dropdown box that contains names of clients so if i select a name from dropdown box a textfield above should populate with it's ID(primary key).

Code:
<td>Client ID : </td>
<td><input type="text" id="cl_id" name="cl_id" value="<?
$query = "SELECT * FROM client ";[code]......

View 7 Replies View Related

JQuery :: Replace Dots And Commas In A Field And Then Use That Value To Auto Populate Another Field?

Oct 27, 2010

I'm using Google Maps to calculate distance between cities. I need to use that distance value for some basic calculations. Distance has to be in "Angloamerican" format (1,234.00) but in metric system. So, Google Maps answer for Madrid - Berlin query will be one of these two:

a) <span jscontent="distance['text']" jsdisplay="distance" jstcache="7">2.320,1 km</span>
b) <span jscontent="distance.text" jstcache="23">2.320,1 km</span>

notice the differences in span "classes" (jstcache is 7 or 23) and lack of any "id" or "name" attributes.

What I want to accomplish is:

1) Convert these Google Maps distance values to "Angloamerican" format (2,320 km) or (even better) format without thousands separator which would only use dots as decimal separator (2320.1 km)

2) Use that filtered value to populate a text field called distance

Populate hidden form element value with the value of a text field on form submit (jQuery)

It helped me a bit with the auto-populate part, but I can't make it work in combination with this Google Maps code. Here is my current code:

<head>
...
<script type="text/javascript">
function submitMyForm(){

[Code]....

View 3 Replies View Related

Dynamic Drop Down List Based On Text Field Value

Nov 25, 2009

I have a form that has a pretty complicated combo box - a user starts typing text, it queries a database for matches, and displays the results to the user. The user can then select the match they desire and it has a value id, which I am currently sending to a hidden field in the form. So, for example: user starts typing in a movie name, Seven - it returns Seven and user selects it. The form submits the id of the movie seven (say 12) to a hidden field.

Where I am stumped: Once a user selects a movie title, I have another drop down select box that is to display the available formats of the movie by querying my database based on the product id (12) and returning the available formats in the list:

DVD
BLUERAY
VHS

I am pretty good at programming, but I cannot figure this out - how to make the select box fire and return results once the value for the textbox has been captured.

View 1 Replies View Related

Populate Multiple Text Boxes From A Dropdown (can Populate 1 Text Box)?

Mar 19, 2010

Below is the code I use to populate a textboxes (compaddress) when I select the compname from the dropdown. I would like to be able to populate other textboxes such as the compdescription, compmaincontact and others when I select the compname from the dropdown. I think that I need an array but I really would like some advice on how to do it as all of my attempts have failed so far

Code:
<script type="text/javascript">
function showname(what)
{
what.form.textfield.value=what.options[what.selectedIndex].title
}
window.onload=function() {
showname(document.form1.number)
}
[Code]...

View 3 Replies View Related

Populate Textarea Based On Radio Button Selection?

Aug 24, 2010

how to get contents into a textarea based on a radio button selection.

Code:
<script>
text = new Array()
text[0] = Array('Saab','Volvo','BMW');
text[1] = 'second list';

[Code]....

View 3 Replies View Related

Can I Populate A Dropdown List?

Sep 13, 2004

I have 2 dropdown list in my html. Is possible for me to populate the option values in the second dropdown list depend on what I select in the first one?

View 3 Replies View Related

JQuery :: Tutorial - Create/populate A Selection List

Feb 6, 2009

I'm looking for a tutorial type of help on using JQuery to create/populate a selection list. I've looked at their site (and searched on their site/google) and although there is tons of stuff there, I can't find what I need.

View 5 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved