There's no such thing as a stupid question, but they're the easiest to answer.
JoinTour
Login
 
Tag Cloud
acer blue screen boot bsod computer connection crash css dell display driver drivers email error ethernet excel firefox firefox 3 game hard drive hardware internet internet explorer itunes laptop linux malware monitor network networking outlook outlook 2003 outlook express partition password printer problem problems ram router slow sound trojan usb video virus vista windows windows xp wireless
Web Design & Development
Search
Search in:
 
Advanced Search
Tech Support Guy Forums > Internet & Networking > Web Design & Development >
PHP - remembering array generated text field


HELLO AND WELCOME! Before you can post your question, you'll have to register -- it's completely free! Click here to join today! We highly recommend that you print a copy of our Guide for New Members. Enjoy!

Closed Thread
 
Thread Tools
kratak's Avatar
Senior Member with 116 posts.
 
Join Date: Jan 2005
Experience: Advanced
22-Feb-2006, 04:11 PM #1
PHP - remembering array generated text field
Hi,


What my form does now is takes a vaule in a text box, a number that the user enters. Then they hit an update button. From this the below scrip is run and replicated depending on the number the user entered in the text box.

Code:
for ($i=1; $i<=$_POST['number']; $i++) {

    $var .= "<tr>
         <td>{$i}<input type='text' name=\"".$id."[person]\" size='25'      value=\"".$person."\"></td>
         <td align='center'><input type='radio' name=\"".$id."[ind1]\" value='1'></td>
         <td align='center'><input type='radio' name=\"".$id."[ind1]\" value='2'></td>
         <td align='center'><input type='radio' name=\"".$id."[ind1]\" value='3'></td>
          <input type='hidden' name=\"".$id."[checked]\" value='1'>
 </tr>";

   $id ++;
}

The goal I want is for example say the user misses another field on the form that is required, and hits the submit button. How do I make it so the values the user puts in the above text boxs and radio buttons stay and do not get cleared. At the moment all I can do is keep the amout of times the boxes are duplicated but not their values.

So if a user insert 3 in the number field and hits update, then hits the final submit i get 3 text fields and 3 radio buttons but not their values. I can however keep the value for the number field as i do an if isset test then echo the value, however im not sure how to do that for this. For example if i wasnt using a dynamic array to generate the fields i would do as follows

Code:
<input type="text" name="station_name" size="20" maxlength="20" value="<?php if(isset($_POST['station_name'])) echo $_POST['station_name']; ?>" />


If this is unclear, please let me know and i will try to explain it better

Thanks
Closed Thread

THIS THREAD HAS EXPIRED.
Are you having the same problem? We have volunteers ready to answer your question, but first you'll have to join for free. Need help getting started? Check out our Welcome Guide.


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
WELCOME TO TECH SUPPORT GUY! Are you looking for the solution to your computer problem? Join our site today to ask your question -- for free! Our site is run completely by volunteers who help people like you solve computer problems. See our Welcome Guide to get started.



Thread Tools


You Are Using:
Server ID
Advertisements do not imply our endorsement of that product or service.
All times are GMT -4. The time now is 04:01 PM.
Copyright © 1996 - 2008 TechGuy, Inc. All rights reserved.
Powered by vBulletin, Copyright © 2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0
Powered by Cermak Technologies, Inc.