How can I fill out an HTML form using Session data?

Posted on 2007-10-08
Last Modified: 2008-03-03
I have an html page with a form that has several fields. When you click submit, it first checks to make sure the form data is valid using JavaScript.  It then posts to a classic ASP page where the form data is redisplayed for validation and stored in session.  it can go through several more classic ASP pages until it reaches a screen where they can choose to go back to the first page and change the data.
What is the best way to pull the data out of Session, and display it in the correct fields in the form on the HTML page?
Question by:pamh_cfcausa
    LVL 23

    Assisted Solution

    just do something like this:

    <input type='text' value='<%= Session("mysessionvariable") %>'/>

    Author Comment

    Thanks - this works great for text boxes.  What should I do for radio buttons and drop down selection lists?

    Author Comment

    Also:  text area boxes and check boxes?  Thanks for your help.
    LVL 12

    Accepted Solution


    <input type="checkbox" name="YourFieldName" value="YourDataValue" <%If Session("mysessionvariable")="YourDataValue" Then response.write("checked")%> >

    Drop Down

    <select name="YourFieldName">
    <option <%If Session("mysessionvariable")="YourDataValue" Then response.write("selected")%>>YourDataValue</option>

    Author Comment

    Thanks to you both - these work great!
    I still need help with the radio button and the text area box.
    Thanks again.
    LVL 12

    Assisted Solution

    text area

    <textarea name="YourFieldName"><%=Session("mysessionvariable")%></textarea>

    Radio Button (basically the same as a checkbox)
    <input type="radio" name="YourFieldName" value="YourDataValue" <%If Session("mysessionvariable")="YourDataValue" Then response.write("checked")%> >

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Free Trending Threat Insights Every Day

    Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

    Suggested Solutions

    Introduction (All good things must come to an end ( The original MySQL API ( has gone away, deprecated by PHP in Version 5.5, and removed from PHP in all curre…
    New Relic: Our company recently started researching several products to figure out what were the best ways for us to increase our web page speed and to quickly identify performance problems that we may be having. One of the products we evaluated wa…
    The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…
    Use Wufoo, an online form creation tool, to make powerful forms. Learn how to choose which pages of your form are visible to your users based on their inputs. The page rules feature provides you with an opportunity to create if:then statements for y…

    761 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    11 Experts available now in Live!

    Get 1:1 Help Now