1. No Profile Picture
    Devshed Newbie (0 - 499 posts)
    Here's my question. I have no problem reading in the name values from an HTML form object and storing the value in a text file. This is certainly easy enough to do with text boxes. But now I want to do the opposite. How can I use my text file, which contains the values from the original form controls, to populate the values of the form? Populating text fields should be easy, but what about setting the values of selectbox? For example, if I have 10 possible values for a selectbox, how can I set the value to be the one set by the user based on what's stored in the text file, without disturbing how I originally set up the form control, and while maintaining the other 9 choices that were not selected?

    I want to do this because I have a customer input form that I want to read from/write to a text file. If the customer wants to change his personal info, I want to have the original form be repopulated from the file with the values he last entered(so he doesn't have to reinput the values all over again). They can then update anything they want in the form, and then form values will be resaved again to the text file with the updated form values replacing the old values.

    Is there a tutorial that would show how to do this? Thanks.
  2. #2
  3. Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jun 2000
    Southern California
    Rep Power
    <BLOCKQUOTE><font size="1" face="Verdana,Arial,Helvetica">code:</font><HR><pre>
    $current_val = "Yes"; # or from your text file

    $select = qq{<select name=something>n};
    $select .= qq{<option value="" selected>Choose...n} unless $current_val;

    foreach (qw(Yes No)) {
    $select .= qq{<option value="$_"};
    $select .= qq{ selected} if $_ eq $current_val;
    $select .= qq{>$_n};

    $select .= qq{</select>};

    [This message has been edited by vpopper (edited December 12, 2000).]

IMN logo majestic logo threadwatch logo seochat tools logo