Self Submit - lost values

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • adragton
    New Member
    • Mar 2008
    • 4

    Self Submit - lost values

    I have one text fields(A) and two Select/Option within a self posting form.
    When form comes back the text field is=null, and selects=null, I have lost values.
    Question - how do I preserve or repopulate the text fields and select?


    <FORM METHOD="POST" NAME="form1" ACTION="">
    <input type="text" name="A" >
    <p>
    <select name="B" >
    <option value ="">Select B</option>
    <option value ="10">10</option>
    </select>
    <p>
    <select name="search" onchange=form1. submit() >
    <option value ="">Select Miles</option>
    <option value ="10">10</option>
    </SELECT>
    </FORM>
  • DrBunchman
    Recognized Expert Contributor
    • Jan 2008
    • 979

    #2
    Hi adragton,

    To populate your fields with the form variables you need to set their values. Like this:
    Code:
     
    <input type="text" name="A" value="<%=Request.Form("A")%>" />
    You can do the same with your drop downs by comparing their value with the request.form variable. Like so:
    Code:
    <select name="B" >
    <option value ="">Select B</option>
    <option value ="10" <%If Request.Form("B") = "10" Then "Selected" End If%>>10</option>
    </select>
    I hope this helps.

    Dr B

    Comment

    • adragton
      New Member
      • Mar 2008
      • 4

      #3
      Excellent DrBunchman

      your example works!!!

      Now to increase the situation.
      add an addition form on the same page self submitting like before.

      How to capture Form1 AND Form2 variables after Form2 submits??

      <FORM METHOD="POST" NAME="form1" ACTION="">
      <input type="text" name="A" >
      <p>
      <select name="B" >
      <option value ="">Select B</option>
      <option value ="10">10</option>
      </select>
      <p>
      <select name="search" onchange=form1. submit() >
      <option value ="">Select Miles</option>
      <option value ="10">10</option>
      </SELECT>
      </FORM>
      <p>
      <FORM METHOD="POST" NAME="form2" ACTION="">
      <input type="text" name="B" >
      </FORM>

      Comment

      • DrBunchman
        Recognized Expert Contributor
        • Jan 2008
        • 979

        #4
        Why not just have one form on the page and put all your controls inside it? Then you can access all the form variables when it submits?

        Dr B

        Comment

        • adragton
          New Member
          • Mar 2008
          • 4

          #5
          Because later I am going to have multiple dropdowns LINKED, and that is going to require MULTIPLE forms on same page.

          Comment

          • DrBunchman
            Recognized Expert Contributor
            • Jan 2008
            • 979

            #6
            I don't know if that's possible - normally you can only retreive form data that was contained in the form that was submitted. Whether it's do-able with javascript - perhaps capturing all the control values at the time of submitting and passing them as hidden data? - I don't know.

            Any other experts got any ideas?

            Good luck finding a solution,

            Dr B

            Comment

            Working...