SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Zealot
    Join Date
    Dec 2003
    Location
    Ireland
    Posts
    116
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Post Data but leave values in form?

    Hi all,

    In ASP is there a way to post the data and do the INSERT, but leave the values in the form after the 'Submit' button has been clicked? At the moment all the data disappears. I suppose I could create a cookie and reload the values from that, but that gets tricky as there are a number of cascading combos on the form.

    Hoping there might be a more simple solution.

    Regards
    Melt

  2. #2
    SitePoint Wizard siteguru's Avatar
    Join Date
    Oct 2002
    Location
    Scotland
    Posts
    3,609
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    Just post the form to the same page, check in ASP code above the form whether the form has been submitted, do the ASP database stuff, then show the form again and write the ASP values into it.

    In VERY simple terms ...
    Code ASP:
    <%
    If Request.Form("Submit") = "Submit" Then
      fname = Request.Form("fname")
      lname = Request.Form("lname")
      If Len(fname) > 0 AND Len(lname) > 0 Then
        'Do database stuff
      Else
        errmsg = "<p style=""color:#FF0000"">No first and/or last name provided</p>"
      End if
    End if
     
    If Len (errmg) > 0 Then Response.Write errmsg
    %>
    <form name="myform" method="post" action="thispage.asp">
    <input type="text" name="fname" value="<% =fname %>" - First Name<br>
    <input type="text" name="lname" value="<% =lname %>" - Last Name<br>
    <input type="submit" name="Submit" value="Submit">
    </form>
    Ian Anderson
    www.siteguru.co.uk

  3. #3
    SitePoint Zealot
    Join Date
    Dec 2003
    Location
    Ireland
    Posts
    116
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks a lot, I'll give that a go.

    Regards
    Melt


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •