Tracking Forums, Newsgroups, Maling Lists
Home Scripts Tutorials Tracker Forums
 
  HOME    TRACKER    PHP




Dynamic Fill Form Fields Depending On Dropdown Box


This question has probably already been asked, but let me ask again

I have a mysql database to which I connect with my php scripts. The
database contains articles. Name, Unit_Price and Reference

Now my client needs to order 5 items, click a button and a table with 5
lines and 3 columns appears (until now easy)

In the first column is a drop down box with a <select > and <options> in
which I store all possible names.

I would like than whenever the client changes one of the boxes (in my
case there are 5) the Unite_Price column and Reference column in the
line he just choose get automatically updated




View Complete Forum Thread with Replies

See Related Forum Messages: Follow the Links Below to View Complete Thread
Fill In Form Fields On PDF
Looking for classes or libraries which allow you to fill in form
fields on a PDF document.

Dynamic Dropdown And Hardcode Dropdown In Select Form
I have plenty of examples of dynamic dropdown choices but none of hardcoded dropdown choices. The ultimate goal is to have a job with various tasks and to track the status of those tasks for a given job. I've used one of the tutorials here to begin the process. Below is the code I have to add work on a given task. Perhaps I actually need to "Update" a job as opposed to "add".

But the problem of the moment is I can't seem to hardcode one set of my options. This is the code I have: PHP Code:

Dynamic Form Fields/multiple Page Form?
It is for a friends out of print booksite, where visitors can request multiple books to be searched by adding one at a time to a cart (javascript), then once all added they submit to another form where they enter their personal details and all is sent through. The problem is at the moment they cannot change whats in the cart without refreshing the browser window and losing everything.

1) present for asking how many books they want to search for
2) display multiple rows of the same input fields depending on how many books they say they want to have searched for?i.e

title|author|publisher|etc
title|author|publisher|etc
title|author|publisher|etc

3) when these are submitted they could see these above the next part of the form where they enter their details with the option to go back and delete/amend.
4) send all the info to my colleague.

if so has anyone seen a similar script that I could take a look @ to see if I can hack it to suit my needs?

Dynamic Form Fields
I want to have it setup so when the user clicks this link a value is sent via get and that value is put through a for loop to generate an additional form field: Code:

Identifying Dynamic Form Fields
User goes to page which is a form that asks for some basic info regarding returning products for credit/exchange, and also asks for how many products are going to be returned. Upon submitting, a return authorization form is presented to them with the specified number of product fields. I now want to take the input from this form and email it to myself, as well as, display a confirmation page to the user. The problem I have is a can't say, for instance, echo "$field_name"; because field_name will get created dynamically after the user specifies how many products to return. For example, say the user says 5 products, this will generate a form with field names like:

return_code0 inv_num0 qty0 product0 cre_exch0 stockout0
return_code1 inv_num1 qty1 product1 cre_exch1 stockout1
return_code2 inv_num2 qty2 product2 cre_exch2 stockout2 and so on....

These get created with a for() loop. Once this form is submitted, how can I address the field names? Code:

Script To Automaticly Fill In Fields On A Website
I have a website that me and my friends need to vote on every day.  It has one field, the email field, and one field a image verification that you have to type in.  What I would like to do is have a script that looks opens the webpage in a new window, populates the email address from a database, then repeats for each name in the database.

That is really all it has to do, I can go and do the image verification myself, it would be nice to have something that can do that too.

Best Way To Change Values Of Fields Depending On Page Function.
I have at the moment a create_user.php and edit_user.php

they are the same, create has <input type="text" value="" name="xx"> for a field, and edit has <input type="text" value="<?=$row['rowhere']?>" name="xx"> - I would much rather have just the one page where if page function was edit then it calls in the row otherwise leaves value blank. How can I do this other than

if ($pagefunction == "create") {
echo "<input type="text" value="" name="xx">";
}
elseif ($pagefunction == "edit") {
<input type="text" value="<?=$row['rowhere']?>" name="xx">
}

on every field!?

Dynamic Dropdown?
I am posting a code for dynamic dropdown by Leon Atkinson, it works fine but i have a doubt: I tried to add another functionality to it where i got stuck! Once the city also gets selected from the second drop down i wanted that on clicking the submit button it should go to some html page wrt to the city choice. Code:

Dynamic Dropdown Box
im looking to have two drop down boxs one with makes of car and
the second drop down box to automatically populate with all the model
of that particular make of car. there are about 50 makes and upto 50
models per make.

I just would like to know the best way to do this - javascript or use
a database? it would be a lot of code todo it in javascript wouldnt
it?

Dynamic Dropdown Lists
I am recoding a greeting card website.

I am using dropdowns as filters for items in a DB, so when the user picks "animals" from the "theme" dropdown, the returned cards all feature animals, and when the user picks "birthday" from the "message" option, the returned cards all feature birthday cards.

However, there are some combinations that don't return any results, for example "get well" "floral" cards. Code:

Fdf Fill Out A Form
I followed the instruction of http://fooassociates.com/phpfer/html/rn20.html

I know how to fill in the data into a form on the browser of the client.
Is it possible to fill out the form on the server and to send this as a
pdf file to the client?

Fill Fields When User Selects User From DB
I have a field with a selectbox which contains a list of client names and several other fields which display information from the DB.

I need to be able to make the fields change to the appropriate information when a user is selected from the select box. Can anybody please give me an example of a bit of code that will do this?

Autmatic Form Field Fill
I have two fields in a form. The first is the email field the second is the username.
Now I want the username field to be filled automatically with the part before "@" of the first field.
So if someone fills in "brain@domain.com" the second field has to be filled with "brain".

Create And Fill-in Form From MySQL
I am working on an admin page where a user can input data into two text fields. When the the form is actioned the two fields are inserted into a table as a row.

What I want to do is when the user calls up the form, any rows that exsist in the table are inserted into the text fields. So the user will see x number of rows with the text fields on the form (x number being number of rows in table). The data is listed in order as determined by the MySQL query. At the end I want to add two blank text fields.

The user can then edit the data in the text fields which updates the appropiate row or enters data into the bottom (blank) text fields which adds a new row.

This is the query I have to call the data PHP Code:

Fill A Form Authenticated HTTPS
I'm searching all around the web without any good answer, maybe you have
the right one.

I'm trying to fill&send a form on a site authenticated https via curl.
The problem is simply that it doesn't arrives to authenticate..
It returns id error1 -> unsupported protocol.

The code is the following:

<?php
$user_agent = "Mozilla/4.0 (compatible; MSIE 5.01; Windows NT 5.0)";

$login_url = "https://www.my_site.com/login";
$login_data = "username=my_user_name&password=my_pass";
$form_url = "https://www.my_site.com/form";
$form_data ="input1=walla&input2=test";

$ch = curl_init($login_url);

curl_setopt($ch, CURLOPT_SSLVERSION, 3);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 2);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_VERBOSE, 1);
curl_setopt($ch, CURLOPT_USERAGENT, $user_agent);
curl_setopt($ch, CURLOPT_COOKIEJAR, "curl_cookies");
curl_setopt($ch, CURLOPT_COOKIEFILE, "curl_cookies");
curl_setopt($ch, CURLOPT_POSTFIELDS, $login_data);

$body = curl_exec($ch); // login

curl_setopt($ch, CURLOPT_POST,1);
curl_setopt($ch, CURLOPT_URL, $form_url);
curl_setopt($ch, CURLOPT_POSTFIELDS, $form_data);

$body = curl_exec($ch); // get form results

echo "error curl_errno ($ch) <br>"; //it return error id1
curl_close($ch);
?>

Passing Variables To Fill A Form
how can I send variables from a php page to a form - i need to fill the form with these variables? maybe using (the process of passing variables to other pages - through url) but how can i assign them to form variables ?

If 10 Clients Fill Out A Form On My Page Simultaneaously And Hit Submit
If 10 clients fill out a form on my page simultaneaously and hit submit, how
does my (Apache2.0.50/PHP4.3.8) server exactly ensure each gets 'their own'
completed form returned ? Or is it possible the clients get mixed up under
some conditions?

Having A Form Submit To A Different Place Depending On A Variable..
I am trying to have a form submit to another source depending on a certain variable. Only problem is that the variable is not defined untill after you submit the form. Basically if a certain text field in the form is left blank i want it to be posting to a different place.

How To Perform IF Stement Depending On Value Of Form Radio Button
I have a form with a radio button and depending on the value of it's 'yes' or 'no' I want to perform 2 differnet SQL queries. Code:

Problem With Dynamic Text Fields
My goal is this: A user logs into the site and is presented with a directory listing (this is done, check). He then clicks on the directory, each which has their own amount of text files within them, and a page loads up presenting either text areas or text fields depending on the type of text file (some only hold one number, others just hold text). The text will already be entered into the text field, so no re-typing will be necessary, and if editing needs to be done, it can be. There is currently a map made in Macromedia Flash which relies directly on these text files to output certain information. I want to be able to alter the text files, and in turn, alter the Macromedia Flash. I understand that all of this can be done easier with databasing, but that's not the goal.

A word on the directories and text files: There are the same number of directories as there are buildings on the map. Each building has 2 text files, some have 4 if there are two buildings too close together to tell them apart. The first text file is totalBuildingName.txt, and this holds the number of pictures there are of that building, just one number. The second file holds text, and is just BuildingName.txt, and it holds the description of the building. The main directory where ALL of the PHP files are stored is called final. it then goes up to directories, then up to the building name. So if you're in admissions, the directory is: ./directories/admissions/

As for the code: It all works fine. Of course it doesn't work completely fine, or I wouldn't be posting here. It does everything I want it to do, and possibly more, however, I can't seem to open the text files within the directory. No matter how hard I try. The permissions ARE set on the folders and files, so that shouldn't be an issue, and if placed in the same directory as the text file, fopen can be used to file the text file, and then implode it to print it out. This leads me to believe that $TheFile isn't looking in the right place, but to be honest, I can't figure out what is the correct direction. I'll be extremely thankful to anyone who can point me in the remotely correct direction. Thank you so much.

Insert/Remove Portion Of Query Depending On Form Field
I have a form that updates an employee's information including a password for that employee. The form has a password field and what I would like is if the admin leaves that field empty, the users password remains unchanged in the database... but if the admin enters text into the password field then that text should update the database as the employees new password.

The problem is to do this I need to either insert or remove a portion of the sql query. (There's probably an easier way to do this that I'm not seeing at 5:30AM.) But I don't know how to store the query portion outside of the actual query and then insert it when needed.

So let's say this is the basic query. This is what I want if the password FORM field is EMPTY: ....

Empty Value In A Form Dropdown
Think that we have one dropdown form where we can choose countries from like this.

<select name="country" id="dropdown">
<option value="Choose country">Choose</option>
<option value="USA">USA</option>
<option value="CANADA">CANADA</option>


IF I have an SELECT I can easily set country = '$country' IF user have choosen some country, but when user not choose any country the selected one is "choose", is it possible do add All countries to $country so the SELECT formula include all countrys and not just get empty? 

Adding A Dropdown To A Form From A Db Table
What i'm trying to accomplish is to have my html form have an element that includes a dropdown menu that's fed from a list of names from an existing mysql db table. Code:

Process Form Fields
Hi, I need to process a generic html-form. Is there any way to access to the form elemts as an array?

Trying To Duplicate Form Fields.
What I would like is to when someone writes in one field. The same text is written in a seperate field. But without sending anything. all internally. Anyone have a clue?

Form Validation- One Of Three Fields
I've been looking for a PHP script to accept a search form for either the name or town or postcode fields to search a MySQL db. I would like the user to put in any one search field but not none.

Also I am trying to figure out a select statment to select one item on a drop down form list or any item on the list eg the list would be dog, cat, horse, fish or all, the column would be pets. The search would pull out any single pet or all pets.

Populate In To The Form Fields
i worked on some programs that gets the datas from the user and insert them in to the database.now i want to retrieve the data from the database
and i want them to populate in to the form fields.

Parse PDF Form Fields In PHP
I am trying to find out if it is possible to open a pdf file from
within PHP, and parse its contents in order to extract all form
fieldnames that might have been previously setup within the pdf
itself.

I want to find this out so that I can then generate a HTML form with
all required questions, which when submitted, will generate a fdf /
xfdf file, using the techniques from the following tutorial
http://koivi.com/fill-pdf-form-fields/tutorial.php

Posting Form Fields
I have a form like the one below. Upon submit I would like to self post
to the same page but have the original $_POST data( which was posted to
this page from another ) also be sent along with the new form field
data. How can I achieve that? Thanks.

<form name="form1" method="post" action="<?php echo
$_SERVER['PHP_SELF']."?".$_SERVER['QUERY_STRING']; ?>">
<table>
<tr>
<th><input type="text" name="fields[]"</th>
....
<th><input type="text" name="fields[]"</th>
<th><input type="submit" value="Add" name="add"</th>
</tr>
</table>
</form>

Empty Form Fields
I have a simple HTML form, which when submitted I want to check whether he fields have been completed. If everything is complete, I want to process the form....No problem with this bit.

If any of the fields are not complete however, I want to indicate this......for example by placing a * character next to the field which is empty i.e.

echo "<TR><TD>Username</TD><TD><INPUT TYPE=text NAME=username></TD><TD>*</TD></TR>";

I am guessing that the best way to do this is submit the page to its self, and check for any empty fields, then display the form again. What would be an efficient way of doing this, given that I have to check about 20 fields?

Form Fields And Verification.
suggestions to with keeping data entered into form fields in place after verification fails and the user is requested to re-enter some missing data. Is there a smooth way to do this with PHP and forms, or would it be best to try and use javascript for a form, so when the "back" button is hit the data is remembered?

Hidden Form Fields
i want to output the value of the "hidden form field". When I hit submit, the the value is put to the hidden form field. when I hit the submitbutton a second time the value of the hidden field is dispalyed. Is there a way to display the value on the first submit
Code:

Getting HTML Form Fields
I'm trying to figure out a way to get the values of input fields from a HTML form, and place them in a database. For example if a html form had 3 text boxes one for "name" one for "email" and one for "url" how would I go about getting those values? I also need it to grab the values from hidden form fields, is there such a function or class?

I know it will prob have to entail some regular expressions, but as I'm not too familiar with regxep could someone take a stab at it? Also any good tutorials on regexep would be nice too.

Validating Form Fields
I would like to create a php script that can validate all of the required elements in the form. I'm not sure the best way to do this, but I know it's a smart idea to have good validation in place before there is a problem.

There are a few pages involved here, and the ACTION tag in the form is sending it to an email delivery script, so it needs to be as error free as possible. In this case would it be smarter to create inlined code that will validate the fields based on an if/else statement before the form is posted?

If someone could give me a sample code of what a simple form field validation would look like that would be great. PHP Code:

Add Fields To A Form Dynamically On The Fly
I'm looking to create a form the allows the user to input a simple list item by item. However I am not sure how to implement a form that allows the user to add as many fields as the need on the fly.

Want To Autopopulate Form Fields From Database
I have a working form that submits info into a database.

I want to take a few fields about the poster (name, email) and hide them and have them filled out from my user table, which is the same database but different table then where the form data is being sumbitted.

I must be searching for thr wrong thing cause i am not finding any information on it.

Form Fields Not Carrying Data
I'm having a problem with the following form; Code:

POST Blanks Out Form Fields
I have a form that POSTs to itself and validates data entered into the form.
If all is well the form performs a header location command to move to the
next input form in the series. If the user has entered an error within the
form the user is NOT redirected to the next page and error messages are
displayed indicating the fields that are in error. So far so good. The only
problem is that all the input fields are now blanked out after the post.
These fields must display all the values that were inputted before the post
was executed.

I have tried the following to no avail......

reassigning values like this after the post => $zip=$_POST['zip'];

reassigning values like this after the post =>
$fullname=$_SESSION['fullname'];

Utilizing this Meta Tag => <META HTTP-EQUIV="CACHE-CONTROL" CONTENT="CACHE">

How can I keep the data that was entered into the form fields before the
post was executed?

Form Fields Not Submitted In Php. Any Gurus?
None of the variables passed thru the HTML files once filled are displayed in the process.php

I checked my PHP.ini file it says register_globals=On ....

Hey Need Help With PHPMailer And Checkbox Form Fields
I need to be able to send an attachment for each checkbox the user
checks. like this: <input type="checkbox" name="file" value="bob.amr">
I need to have multiple checkboxes! and if they are checked the user
gets an attachment for each? I am using the popular PHPMailer!

How Could I Get The Form Fields Filled From A Database?
One idea I have is to do a redirect, but it doesn't quite
work because it ends to an infinite loop cause the page
is redirecting to itself:

header("Location: " . $_SERVER['PHP_SELF'] .
"?field1=something&field2=something else");

That would bee neet. I just would create a string from the contents
I receive from the db and just redirect, but as I said, it doesn't
work easily. You have to use the apache rewrite, but I didn't quite
get it.

Another solution is to check if the request is not empty for the
particular field.

Spell Form Fields Using Google API?
has anyone produced spell checker code for forms fields that uses the google
API?

WHat about any GNU spell check that does NOT use aspell/pspell/ispell?

Duplicate Input In 2 Form Fields
Hope to check the input in two form fields:

input in "emailto" form field: a@a.com
input in "emailfrom" form field: a@a.com, b@b.com, c@c.com

I hope to remove the duplicated input "b@b.com" in "emailfrom" form output and then keep only the remaining part of the string. How can I do that? I have though a way in combining the two fields input as an array and then use "array_unique" to check the duplicate. And then, to separate the two fields input again.

Having Dependant Form Fields (comboboxes) From Each Other?
I am currently programming on a form with 2 combo-boxes for input. But I need the box 2 output be dependand on box 1 input. I will explain in more detail: I have a SQL table that has 3 columns. One for type, second for motor and third for defining.

By PHP I have output all types (cars and bikes) in the first combobox.
Now what I need is, how can I manage, that when a person chooses e.g. in box1 Mercedes (which is defined in the 3rd sql column as a car) it would only show in the combo-box 2 of my form those motors that fit a car WITHOUT reloading?

I kinda simplified things here a little, but what I described above is the main problem I have. Somehow it must be possible through javascript I guess to check the value in combobox1 get the 3rd columns value of the mySQL table probably by PHP before, and then check IF that value is car then show only certain motors and IF that value is bike show other motors.

Checking For Required Form Fields
i have written the script to check for blank form fields (all fields are required)
on my registration form using :

if (ereg(".", $first) == 1){
$verify = "OK";}
else{
print ("<b>ERROR:</b> A first name is required.");
$verify = "bad";}

my question is, although this script works to verify a form field, it doesnt prevent the incomplete form from being sent to the database. can someone tell me how to stop the form from being sent if it is incomplete, and should this script be included on the form page(html page) or the php page that submits the data to mysql?

Defaulting Data In Form Fields
in a lengthly form, is it possible to use PHP3 to automatically fill form fields with data that has already been entered into a previous place on the same form?...or from a previously filled out form?..likewise, is it possible to perform a math calculation on a number entered into a field and have the result automatically defaulted to another subsequent field?

Omitting Form Fields If Empty
I have a form I'm putting together. The processing will be on a PHP
script that will take all the field names and print them out on the
email it sends to me. No problem there. But what I'd like to do is have
it exclude printing the field name and value when there are any blank
values in the field.

The processing part of the script is this:

if (is_array($val)) {
for ($z=0;$z<count($val);$z++) {
$content .= "$key: $val[$z]
";
}
} else {
$content .= "$key: $val
";
}

How would I adapt this to not print a field name with a blank value?

Sticky Form With Multiple Fields
how do i create a sticky form with multiple fields? say
i want a form with:

name: [input field name]
address: [input field address]
country: [input field country]

[submit button]

and if a user presses the submit button it will show
exactly the same page with the fields that the user
has entered filled in with the values (s)he entered
(validation of the values will come later), and the
info of the form sent.

should i name all the values in the form separately
or should i use an array?

Enter Data Into PDF Form Fields
Is it possible to use PHP to fill in fields in a PDF form? The form can be found at :PDF form The background to the question is that I have a client who has a debt collection database system written in DataEase that ouputs County Court Summons data on to Court Summons Stationary. This is hit and miss on the printing margins depending on OS system or printer.

The system is being written in PHP so the summons forms could be produced in HTML if the existing PDF form isn't a viable solution.


Copyright © 2005-08 www.BigResource.com, All rights reserved