Dynamic Form Items
I am trying to create A form that its fields will depend on a
form menu.
for example.
/***********************************************/
<form name="form1" method="post" action="">
<select name="select">
<option value="1">option 1</option>
<option value="2">option 2</option>
<option value="3">option 3</option>
</select>
Text field 1<input type="text" name="textfield">
Text Field 2<input type="text" name="textfield2">
Text Field 3 <input type="text" name="textfield3">
Text Field 4 <input type="text" name="textfield4">
<input type="submit" name="Submit" value="Submit">
</form>
/***********************************************/
When the option 1 is selected only the textfields 1 and 2 to appear,
when option 2 is selected only textfields 1 and 3 to appear and so on... any
combination I would like.
I tried puting the textfields in "if" statments but i don't like it. its too
messy PHP and HTML code.
Any Ideas of how this could be done better ? If someone did something
similar before and has a relative link it would be good as well.
View Complete Forum Thread with Replies
See Related Forum Messages: Follow the Links Below to View Complete Thread
Dynamic List Items Repeating Themselves
I'm working on this online magazine, and each page (well, other than the front page) has a menu included on the right-hand side consisting of articles divided into three sections: articles, columns, reviews. For some reason, whenever I click on one of these article links, that link takes the place of the first link in the section. You can see what I mean here: PHP for the included right_menu.php PHP Code:
Updating Multiple Items With One Form
I am using a do while loop to run through a list of items on my page. Say I have 5 items on the page and each has one field that the user can input information to. Is there a way to do an update where it will update all records on the page with one submit form?
Setting Variables For Only The Selected Items In Form
when a form has a question where the response can be one or more selections either from a series of chech box inputs or a selection list, how would i set into variables only the responses that are checked or selected so that only these values are available for exporting to a mySQL database?
Only Email Items Ordered (order Form)
I have a simple php script that send form variables to an email address. The current scripts sends everything as it is suppose to, but I need to change the script to ONLY email the items with qty > 0. As you can see, this sample collect 3 items from the order form, then sends them through email. 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
I have one user table in my MySQL database and this is linked to a user type table containing 3 types of user. Each type of user will be required to give a different amount of data when registering. Basically I want to create one registration form for all types of users but only show the form fields that are relevant to the individual user type. The user type will be selected from a pervious page containing a list menu with the 3 user types that is sent via GET to the registration page.
Dynamic Form
I need to create a form that takes a number that the user enters, and duplicates a question the number of times the user entered. For instance, if the customer enters 5 on the first page, when they press next the form generates "How old are you?" 5 times on the page. The customer will answer all 5 questions then press next. Finally, all the local variables get dynamically created and written to a database. I have already taken care of dynamically creating the question five times. Using a simple WHILE clause, this generates the correct number of questions. What I am having an issue with at this point, is how to dynamically create the local variables.For instance, for the question "How old are you?" I would need a unique variable for each instance; using something like $Age(n). So that for five times, it would automatically created variables $Age1 through $Age5. I have carried over the number to the submit page by creating the variable $Number and passing it along as hidden button on the form. $Age'$Number' seemed to work for creating the variable, but $_post["Age'$Number'"] doesn't work for referencing the global variable. I would need some way of looping through and dynamically creating the variables.
Dynamic Form
I had to make a form for someone, with 42 questions each question had different form-elements. I was typing and coding for almost 3 hours..!! lets say we would make a form (formmaker.php) to dynamicly create a form with multiple questions: on the formmaker : -first we have to enter the number of questions (max 100) -then we have to type the question(s) in (an) input field(s) -then we would have to select a type of answering field (textbox, checkbox, radiobuttons, file, dropdown etc. ) -it would be nice if we could select to make the question mandatory or not. -if we choose for checkboxes or radiobuttons , it would be nice to know how much of them (no limits here !) ok..limit it to 30 -when we have selected...for example..15 checkboxes, they have to dynamicly appear on the formmaker. -for each checkbox or radiobutton, we have to enter a value. -finaly we have to add an email adres to each question !!! (and a BCC field) (this way, we can use one form and split and send the data to multiple recipients..!!) -also we have to be able to dissable or enable a question. (if dissabled, it wont show on the created form.. A nice template to show a filled in form is preferable.. It would be nice to store everything in a database tabel. (for each new form a new tabel in the database) question1 id active(yes/no) questiontext fieldtype mandatory(yes/no) radio_or_checkboxvalue1(rocv1) rocv2 rocv3 rocv4 rocv5 etc.... sendto_email bcc_email I started with the code already...here it is: Code:
Dynamic Form Value Modification
I was wondering if and then how to dynamically update form variables without having move between webpages I am developing a print quoting system for a company and I want the options in list boxes to adapt based on the values of previous selection in the form. However it must happen immediatly without the whole page having to refresh. For example if a person chooses paper size to be A4 then the next drop down list must only have options available for A4 pages. I thought I would need to use Javascript for this but I can't find out how to access the server side mysql database so I get the feeling Javascript is the wrong option. The whole site is programmed in php but php is server side so I don't don't think its possible using php specifically.
Dynamic Form Selects
How do you make dynamic for selects in php? It is in regards to a modify type scripts im writing in php/mysql. So regular select drop downs look like so: <select name=genericselect> <option value="1" selected>1</option> <option value="2">2</option> <option value="3">3</option> </select> right, well if I was pulling info from a database, how would I make is so that the 'selected' value is dynamic and comes from the database? Im sure theres a simple way of doing this.
Getting Info Out Of Dynamic Form
I am using the following code to produce a dynamic form. $result = mysql_query("SELECT id,weight,date FROM weekly_data WHERE weight IS NULL AND subscr_id = '$toss' AND date <= now()"); if (!$result) { die('Invalid query: ' . mysql_error()); } print"<table width=ï`%' id='catchup' border=Ɔ' cellspacing=Ɔ' cellpadding=Ɔ'>"; print "<form name='form1' id='form1' method='post' action='catchupprocess.php'>"; print"<tr>"; print"<td></td>"; print"<td>Weight</td>"; print"<td>Date</td>"; print"<td>Waist</td>"; print"<td>Measure</td>"; print"<td></td>"; print"</tr>"; while ($row = mysql_fetch_array ($result)){ //echo $result; print"<tr>"; print"<td>"; print"<input name='".$row['id']."' size=Ɗ' type='text' value='".$row['id']."'/>"; print"</td><td>"; print"<input type='text' size=ƌ' name='weight".$row['id']."' value=''/>"; print"</td><td>"; print"<input type='text' size=ཆ' value='".$row['date']."'/>"; print"</td><td>"; print"<input type='text' size=Ɖ' name='waist".$row['id']."' value=''/>"; print"</td><td>"; print"<input type='text' size=ƌ' value='$measure'/>"; print"</td><td>"; print"<input type='hidden' size=ཆ' value=''/>"; print"</td>"; print"</tr>"; } print"<tr>"; print"<td> </td>"; print"<td><input name='Reset' type='reset' value='Reset'></td>"; print"<td> </td>"; print"<td><input name='submitcatchup' type='submit' value='Submit'></td>"; print"<td> </td>"; print"</tr>"; print"</form>"; print"</table>"; ?>
Form With Dynamic Questions
I've a mysql table where i stored a list of questions. My php script executes a query which yields a different number of questions every time; i used the loop function to create an input field for each question in the form; and dynamically referencing each input name with the question number i.e. question 1 is called q1, question 2 named q2, and so on. The data is submitted using POST. I then try to retrieve all the answers by doing a loop and using something like echo '$_POST['q'.$n.'']' except the syntax doesnt seem to work.
Dynamic Form Update
I have the following form in which i need to updateitems. The problem is that i do not know how many elements will be in the form (generated dynamically) eg <input type = "hidden" name ="id1" value="1"><input type ="qty1" value ="1"> <input type = "hidden" name ="id2" value="2"><input type ="qty2" value ="1"> <input type = "hidden" name ="id3" value="3"><input type ="qty3" value ="5"> <input type = "hidden" name ="idn" value="n"><input type ="qtyn" value ="1"> how do i generate an array for a foreach loop to update the values in PHP so that i can use it to create a Update query eg ///begin loop $sql = "UPDATE `table` SET `qty` = `$qtyn` WHERE `id` = `$idn`"; // end loop
Dynamic Form Pulldown
I'm building a form and need to have the options in a pulldown menu pulled from a mysql database, i understand the basics of sql and have used forms before, i just need to see an example to get me on my way.
Dynamic Form Processing
Im writing a script for processing a form created by a csv file. this form is created through a loop, where $num is the place in the loop. Code:
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:
Dynamic Form And $_REQUEST
My current project needs to run on both windows and linux. I figured out that windows needs $_REQUEST to read the form elements. This worked well until parsing a dynamically built form with checkboxes named: cb0, cb1, cb2, etc. I can't figure out how I can use $_REQUEST to read the form elements, when I try $_REQUEST[$i] for example all values of the array elements are 'cc'. No idea where this comes from as cc is never used as a value?
Form Field Dynamic Population And PHP
I have a form that dynamically generates a drop down from a table column called suppliers. Products supplied by each supplier vary so what I want to try and achieve is that once a supplier has been selected a second drop down on the same page is populated with data from the same table / different column with that suppliers products. (I am trying to avoid refreshing the page) I have not supplied any code at this stage as I am not sure whether PHP is capable of doing this by itself or whether javascript would need to be incorporated.
POST Form To Dynamic Page Name
I've got a simple form with an HTML OPTION block. I'd like to POST the form to a page whose name is based on the OPTION they select. So for example say the user selected this option, I'd like to POST the form to a page named "memory.php". echo "<option value="memory">Memory Utilization</option>";
Reset Dynamic Search Form
i have a search form that has a set of checkboxes and a set of select boxes. the checkboxes correspond to a select box and activates the select box once checked. when i submit the search form to display the results on the same page, the elements are echoed back into the form so the user can see what search criteria he/she search for: 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:
Dynamic JS Form And $_POST Array
I have a form that I am altering after page load with javascript. Basically I have a button that inserts another text field into the form which the user can fill out. Its for a calendar, and I'm allowing them to optionally add multiple days for an event. Each box that is created has the same name with [] on the end to make it an array. When I view the post array with print_r($_POST), only the first textbox's value shows up. This is the only textbox in the form when the page loads. Simplified example: <form name="calform" action="process.php" method="post"> <input name="startday[]" type="text" class="bordered" size="25" /> <input type="button" onclick="add_one_more()" value="Add another date" /> // if the user hits the add button it adds this input field after pageload <input name="startday[]" type="text" class="bordered" size="25" /> </form> And here's what I'd get from that form Array ( [startday] => Array ( [0] => test1 )) A button inside the form basically adds another <input> tag between the <form> tags. Why isn't PHP seeing the data?
Dynamic Form Option List
I want to create a dynamic drop down option list in a form, but I just can't wrap my head around this. Both of the below scripts work as intended, but how do I make the mySql query results work with my existing script? Yes, I know I must replace the "$options = array" part in the top piece of code, but I need a little more guidance than that. Code:
Dynamic Form - How To Set Values Of A List
I have a form with a list/menu in it that is populated with records from a database. The items in list#2 are based upon what is selected in list#1. I have been able to use a combination of php and javascript to get it to work, but the javascript reloads the page to get list #2 to refresh - and that clears out any other fields that have been filled in. Instead of javascript being called for the 'onchange' event for list #1, I'd rather it call php when list#1 is changed and so reset the values in list#2. OPTIONS: 1. I thought I could have a php function that is called (i.e. onchange="<?php reload();?>" but I can't figure out how to set the values of the list from within the php function. How to reference form objects with php?
How To Process Dynamic Form Field Names
Let me start by saying I don't have a lot of PHP experience, and am just starting to fumble my way around some of this stuff... I'm sure this has been asked a number of times, but after 2 days of searching the internet, I just haven't found a solution that makes sense, so I am hoping someone here can help me. I have a pretty simple project schedule sort of web page that lists a number of tasks & 4 dates associated with each task. (planned start, planned complete, actual start, actual complete. The page is built dynamically based on what is in a mysql database, and the dates listed are form fields, with the intent that a person with access can change any number of these dates. Each task has an id associated with it, so when i build the form, I name the form field <task_id>-<date type>. so, for example, for task id = 10 I have 4 related form fields: 10-planned_start 10-planned_complete 10-actual_start 10-actual_complete This basic pattern is repeated for all the tasks (up to 100 right now, but it could grow slightly). Once all the form fields have been updated, and the user clicks submit I want to update the data in the database with the appropriate data. So, my questions is: 1) How can I process this form, when I don't know what the names of the fields are going to be, and/or how many fields there are? 2) Is there a good way to identify only those fields that have changed and do updates on only those fields, or am I "stuck" updating all the records, even those where the dates have not changed from when the form was built?
How To Get A Dynamic Javacript Form Variables Seperated In PHP
PROBLEM: I have this form that allows the user to dynamically create additional fields (see javascript code bellow). I am trying to retrieve the values entered into these fields from my php script. I ultimatly need to pick out the variables and place the values into my php script page. I have worked with a little code I found on php.net (see php code below), but I wan unable to grasp the knowledge on how to seperate the variables in the address bar. Please reply. QUESTION: How do I create variables in my php script from my dynamic javascript form? PHP CODE: foreach($_GET as $name => $value) { print "$name : $value<br>"; } JAVASCRIPT CODE: <HEAD> <!-- Begin function createForm(number) { data = ""; inter = "'"; if (number < 16 && number > -1) { for (i=1; i <= number; i++) { if (i < 10) spaces=" "; else spaces=" "; data = data + "URL " + i + " :" + spaces + "<input type='text' size=10 name=" + inter + "url" + i + inter + "'><br>"; } if (document.layers) { document.layers.cust.document.write(data); document.layers.cust.document.close(); } else { if (document.all) { cust.innerHTML = data; } } } else { window.alert("Please select up to 15 entries."); } }
Dynamic Form Option Diapearing On Submit
when i submit one option field after inserting a option value and an amount the previous one i had done disappears causing me lose all the information that i had typed in and i was wondering how i could keep the information alive as well as keep the newly created form fields from diapearing, PHP Code:
Update A Ststic HTML Form To Dynamic
I have a form which I now want to be more dynamic. The datbase tables are builtbut I cannot get the fields to populate. When a member selects an age group from the first select statement and the dates that age group are scheduled to play a match are displayed in a second select statement. When both select ions have been made the rest of the form is displayed and can be filled in and the database updated. Code:
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
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:
Related Items
I noticed a lot of websites show "Related Items" on each product page. I want to know how usually do you implement it. Should I add a field in the mysql table to hold the "Related Items" information? What's the best solution?
Get ID Of Deleted Items
I wonder if there is anything similar to "mysql_insert_id();" for deleted/updated id's? If i do a query and DELETE WHERE text_field="", can i get the id's of the fields that were deleted?
How Many Items Are In An Array?
I dont know how many values there are in my array after it's been split.. is there a command? array_count_values doesnt do what I need sadly.
Add/Delete Items
I have the following code, that displays a message whether a users shopping cart contains items or not. How do I add/delete items from the shopping cart, upon the appropriate product link being clicked? If a items is already in the cart, how do I display a message notifying the user? Code:
Favorit Items
i have many tables with different data structure due, am making a service which will allow users to add itimes to thier "favorit items" tables I thinked to use the table names as a hidden filed, like if the table name is "hotel" and the user added a hotel to his favorit items , the hidden fild will be hotels, and then pass that field as a variable then use it in a query to get the hitel data, does this adea work? or there is a better way ?
Using If Empty With Two Items
I am trying to say if $_Post and $_Session are empty set the variable $dcparent to equal 1, but it doesn't like what I am doing. if(isset($_POST['dcparent'])) { $dcparent = mysql_real_escape_string($_POST['dcparent']); } if(isset($_SESSION['dcparent'])) { $dcparent = mysql_real_escape_string($_SESSION['dcparent']); } if(empty($_POST['dcparent']) && (empty($_SESSION['dcparent'])) { $dcparent = 1; }
Multiple Cart Items
I've created a shopping cart application using php 4.06 and postgres. a problem i had was that when i added the same item twice it was adding an extra item as opposed to adding the quantities together. i did manage to sort this out to an extent but my only solution means using a block of code for each item which has made my script very long and i'm pretty sure has made the script somewhat unreliable. I would appreciate it greatly if someone could offer a solution to this, this is my code for adding items to the cart: PHP Code:
Finding @ In A String, And Other Items
Ok - I want to check a string for @ in it (Im checking to see if a string that should contain an email holds a @ ) How would I go about this? preg_match? ereg? strstr? Examples? Also - how would I find any non alpha numeric characters in a string so I can give the user an error message. I dont want any characters besides alpha-numeric in the strings.
Multiple Items Of Same Name In Session?
I have a shopping cart where I can add tshirt designs to the cart. The designs are added to a php session object called cart. The object 'cart' consists of the design name, color and the quantity. The probem is that if someone adds the same design to the cart again then it just increments the quantity of the existing design with the same name instead of adding another instance of it to the cart. How can I have multiple instances of the same design with the same name in the cart at the same time. One thing I thought of was to append some sort of incrementing id to the design name before it is added to the cart. Thus the next time the design is added it would have a new id appended and the resulting name would be different.
Number Of Items In A Cart
I am working with a session and a 'cart' (note that I do not really know what I am doing though). I was wondering if there is some easy way (function) to work out how many items I have in my 'basket' / 'cart', because then I could call this function from anywhere to show the user just how many items are on order
Only Allow X Number Of Items To Be Checked
I have a function that renders out tag categories, and then all the tags within said category. Each tag has a checbox beside it, i am wondering if it's possible to only allow a user to check 4 tags. Here is the function: Code:
Display Items Using Checkbox
i have a page where in it lists all job items on a table and each item has a checkbox so when i check one or more items when i click the post button it should display the job items on this post page. my problem is, my post page is not working. Code:
Count Of How Many Items Are In Database
I am wanting to create an select menu for displaying the order of the item on a page. I am guessing that I need to get the count of how many items are in the db and them put them into a select menu. Does anyone know how to do this or can point me in the right direction?
Display All Array Items
How do I display all the items within an array? Also, how do I delete a particular item from an array?
Changing Items After A Date
What I have is a table (code below) and it is for an events page. What I want is after the date has gone, it changes the whole row to grey. ( #666666 ). Code:
Deleting Items From A List
When i click one of the delete buttons, the form submits, but nothing happens. I'm pretty sure i'm doing something stupid with the form buttons, but I've been staring at it too long...any takers? Code:
Multiple Items In Foreach()
Can someone tell me what im doing wrong with the code bellow please? I get print_ticket called lots of times, with 1 as the hash,name,ticket_no responce. (i have chequed that the query is returning the right results). $return = pg_query($pg_connection, $query); $data = pg_fetch_array($return); foreach ( $data as $temp ) { echo print_ticket ($temp['hash'],$temp['name'],$temp['ticket_no']); }
Compare Items In An Array...
I have been getting on fine with basic coding until I stumbled accross a problem. I cant seem to figure out how to check to see if a value in one array is in another array - and if so just simple report back "true" or "false". Lets call the two arrays LOCKS and KEYS. Doing a print_r($locks) would give: Code:
|