#1
  1. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Feb 2003
    Posts
    12
    Rep Power
    0

    ASP - Attempting to preserve input fields


    I have a .asp form page that submits to another .asp page that uses cdonts to send me an email and does a response.redirect back to the form page. I need to preserve (keep) a couple of text box values and a couple of dropdown box values. At this point I have global.asa variables for the fields in question and they are all set to null. I can't figure out how to put the contents back in the fields, when it returns from the cdonts page. I assume that I must save all the field values in the session variables just prior to the submit to the cdonts page.

    If you can show me how to accomplich this for one text field called name and one dropdown box called PUDeliv (one option for pickup and one for delivery), it would be greatly appreciated.

    To get a better picture, go to www.faxfoodorder.com/newpage2.asp - This page submits to /get.asp which retrieves all the form fields and sends an email using cdonts and then redirects back to newpage2.asp.

    Larry

    P.S. I use outlook, IE 6.0
  2. #2
  3. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Feb 2003
    Posts
    15
    Rep Power
    0
    i do the same thing with my forms, where when it redirects back to the form but maintains the values. first i used a querystring; this worked fine, until i started using textareas, which allowed for multiple lines of input. so now i use forms. whatever section the code enters, i have it write out a form with hidden input elements set to the values of the form. then the form submits itself in javascript code when the page loads. on the form end, then, i retrieve the variables. for text fields, it's as simple as putting the variables straight into the inputs, but to have drop down boxes select the appropriate option, it gets tricky. here's what i did for that:

    //This function writes "selected" for the matching term when the
    //user has entered invalid info, and is redirected back to the form
    //to fill in appropriate information
    //num is any one of the following
    //1 = gender, 2 = birthmonth, 3 = birthday, 4 = state
    //option is the value of the option that's being written
    function select(num, option) {
    var category;
    if (num == 1) { category = gender; }
    else if (num == 2) { category = birthmonth; }
    else if (num == 3) { category = birthday; }
    else if (num == 4) { category = state; }
    option = new String(option);
    category = new String(category);
    if(option.valueOf() == category.valueOf()) {
    Response.Write(" selected");
    }
    }


    then an example of when the page writes the select input:

    <select class="formselect" name="gender">
    <option<%select(1, "");%>></option>
    <option<%select(1, "Male");%>>Male</option>
    <option<%select(1, "Female");%>>Female</option>
    </select>

    that's my solution anyway... if you want to use session variables to store form info, i'd think that would work , too:

    Session("name") = name
    Session("PUDeliv") = PUDeliv

    you'll still have to do the function call for PUDeliv's select input

IMN logo majestic logo threadwatch logo seochat tools logo