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


ADVERTISEMENT

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 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

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

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

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

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 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

AJAX :: Populate A Triple Dropdown Menu Based On Roshans Code ?

Jul 21, 2009

I'm trying to populate a triple dropdown menu based on Roshans code The first dropdown populates the second one fine but when I clidk on the second it populates itself instead of the one below! I thought at first it was a simple problem with the element ID its not and I can't figure it out.

View 9 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

Auto Populate Text Box

Jul 20, 2005

I have a registration form for classes. Each class has a fee. I have a
drop down box whereby the user chooses his class. There is a textbox with
the associated fee. I would like to auto populate the fee textbox depending
on what class the user chooses. In the email, the value of the drop down
box has to be the name of the class and the value of the fee text box has to
be the fee. Can someone please help me in accomplishing this?

View 2 Replies View Related

Populate Form Field Based On Select Option?

Jan 14, 2009

Is there some example js that shows how to populate a text field on a form, based upon what option is chosen in a select form field? The options can be hardcoded and it would be great to also have a default if js is off on the client side.code...

View 4 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

Populate A Dropdown With Text File And Dynamically Update The Second Drop Down

Feb 2, 2011

I created two drop downs, where the second one dynamically updates according to first selection. Now I jus have 2 members in first drop down and 20 in second drop down. I hard coded using javascript. But by the end of this year the number increases to 100's, then we cannot hard code it. I use html,javascript,jsp for the webpage. Is there a way to populate the dropdowns with data in a text file where they can update the text file with new members.

View 5 Replies View Related

Populate Text Field Using Onmouseover

Jun 18, 2010

I have a table where when the cursor passes/hovers over a cell, the current cell, as well as the top cell in its column and the first cell in its row change backgroundColor. I have text fields outside the table which I want to populate with the contents of the cells affected by the mouseover event. So as the mouse moves over different cells, the contents of the text fields changes accordingly. I've got the backgroundColor to change, but when I try to assign the contents of the cells to the text fields, nothing happens. The change of backgroundColor even stops working. This is the code I'm usign to populate the fields.

document.getElementById("tableID").textfieldID.value = Col1Cell[0].innerHTML;
document.getElementById("tableID").textfieldID.value = HeaderCell[n].innerHTML;
document.getElementById("tableID").textfieldID.value = this.innerHTML;

I'm traversing through the <th> and <td> tags to find the header cell HeaderCell[n] and first column cell Col1Cell[0] associated with the current cell. If I leave out these lines the backgroundColor changes, if I use them, nothing happens at all.

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

Dynamically Populate Text Field From Drop Down Box

Jun 20, 2011

The below script is working fine on IE but notin Mozilla

<script type="text/javascript">
window.onload=function() {
if (document.getElementById) {
document.getElementById("country").onchange=function() { switchme(this); }
}
}
[Code]...

View 4 Replies View Related

Populate Text Field With Radio Button Value

Jan 3, 2010

If the user selects the early bird special for member (at 100.00) it populates the text field with the value for that row. Or, if the user selects regular registration for non-member it sets the early bird text field back to 0.00 and populates the text field with he value for the regular expression code. At the same time it populates the total field with the total price. I hope this makes sense. How can I accomplish this using JavaScript or jQuery? The text fields are read only. The table is listed below.

Table code:
Code:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "[URL]">
<html xmlns="[URL]">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>Untitled Document</title>
</head> .....

View 4 Replies View Related

Dynamically Showing Field Based On Text Value From Another Field?

Nov 18, 2009

I have a text field, call it income, that when the input is > 0 I need to dynamically show the next text box, and if it is blank hide the next text box. I would like to use onBlur but can't seem to get it to work.

View 5 Replies View Related

JQuery :: Use Tagify Plug-in To Populate Text Field With Dynamic Labels?

Sep 7, 2011

Have the following code which (resides in a dialog box) and serves as an event listener for check boxes. Am able to populate / de-populate text field with values from check boxby checking or unchecking the individual check boxes:

// Event listener which picks individual contacts// and populates input field.
$('#emailCheckListId_ul input:checkbox').change(function() {
// Declare array
var emails = [];

[Code].....

However, when I use try to use theJQuery Tagifyplug-in it only creates one "tagified dynamic label" inside the text field but doesn't create another label when I click on an additional check box. Also, when I uncheck the original checkbox, itdoesn't remove the original label.

Here's my code using the JQuery tagify plug-in (all I did was keep everything the same as above but called the tagify functionon the text field):

// Add / Remove array from text fieldtextField.value = emails;
// Decorate with dynamic label
$(textField).tagify(emails);

I get this JavaScript error in the browser:

jquery.tagify.js: 'options' is undefined, line 71

In the source code this line reads:

_setOption: function( key, value ) { options.key = value;
},

Its stating that options.key is undefined...

To view the jquery.tagify.js complete source, clickhere.

Is there a way I can create an "else" for example:

// Iterate through each array and put email addresses into array$('#emailCheckListId_ul input:checkbox:checked').each(function(){
// do something
});

[Code]....

View 1 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

Auto-selecting All Text In A Field

Nov 28, 2006

I have a simple form that contains an INPUT element that has an initial value.

<form name="Form">
<input name="Number" type="text" value="Hello">
</form>

When the form loads, I want all of the text in the field to be automatically selected. How can I do this?

Doing a:

document.Form.Number.select();

selects the INPUT element itself, not the text inside of it.

View 4 Replies View Related







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