Results 1 to 13 of 13

Thread: preserving input fields on a form

  1. #1
    Join Date
    Feb 2003

    preserving input fields on a form

    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 on the form, 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, but then what?

    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 /get3.asp which retrieves all the form fields and sends an email using cdonts and then redirects back to newpage2.asp.


    P.S. I use outlook, IE 6.0

  2. #2
    Join Date
    Feb 2003

    I grad all of the input request variable value and past them on to succeeding pages. I do this like:

    dim savReq

    One way to pass these on is:

    <form ...... Action="xxx.asp?<%=savReq%> .....>

    Another would be to save the values ("request.form") in a session variable.

    Then you may have to do some ASP coding to reload the variable values into the form, depending on how you loaded them initially. If you just start out with an empty form (not DB fed) then the textboxes will not be a problem You might have to "force" values into the dropdown boxes though.

    Ex. of textbox:

    <input type="text" name="xxx" value="<%=request("fieldname")%>" >

    First time it will be empty; on reentry it will have the previous value.

    This should give you some ideas....

    Larry Woods

  3. #3
    Join Date
    Feb 2003
    Hi Larry, thanks for your response. I have no problem passing the fields to the send email page and the send email does send me a valid email with all the form fields on it. I have tried doing the following which is similar to what you suggested:

    input type="text" name="Name" size="38" maxlength="35" value="<%=session("holdname")%>">

    I use a global.asa which initialized all the fields I need to keep - to null.

    In the form, just before the submit, I did the following:

    Session("holdname") = request.form("Name")

    The results in the name field are always blank when the form page redisplays. What do you think?

    How did you access savreq in the send mail page?

    In your statement below, should =request("fieldname") be
    =request.form("fieldname") ?????

    input type="text" name="xxx" value="<%=request("fieldname")%>" >


  4. #4
    Join Date
    Feb 2003
    A couple of comments:

    First, there is really no reason that I can see for you to define the Session variable in global.asa. Just use it when you need to. Then set it to an empty string.

    As far as the email page is concerned, if you just pass the request variables as I showed you, you should be able to examine their values on the target page just as if they were controls on the previous page. I have exactly the same situation as you have, and I don't have any problems with interrogating the request values.

    Larry Woods

  5. #5
    Join Date
    Jan 2003
    Dundee, Scotland
    Ok to start with, don't abuse session variables for storing values to be passed to another page. What you are trying to do would be a lot easier if you post your form back to itself and have the form and the CDONTS in the same page.

    validate = request.form("validate")
    if validate = "yes" then
    UserName = request.form("UserName")
        Set MailObject = Server.CreateObject("CDONTS.NewMail") 
        MailObject.From = "from@me.com" 
        MailObject.To = "to@me.com" 
       message = "Your email is sent"
    end if
    <form action="samepage.asp" method="get">
    <input name="Username" type="text" value="<%=username%>">
      <input name="validate" type="hidden" id="validate" value="yes">
      <input type="submit" name="Submit" value="Submit">
    Now this is an example of how i would do this, but you can change it to suit yourself. There are different ways you can set this up the above is only one of them. Hope this helps.

  6. #6
    Join Date
    Feb 2003
    ribeyed, look at my form at www.faxfoodorder.com/newpage2.asp and tell me if you still think the same way.

    name, email address, phone, pickup/delivery (dropdown box), times for pickup or delivery (dropdown box), address and company name are thew fields that I need to redisplay, after submitting to send email page.

  7. #7
    Join Date
    Jan 2003
    Dundee, Scotland
    sure yes it would work you can even populate the select boxes as well.

  8. #8
    Join Date
    Feb 2003
    ribeyed, I finally got it to work. One problem was the Method="Get", it should have been Method="Post". I will have a lot of work making changes for the time (about 44 options), but I'll get it done.

    Now, I have one last problem. If I click on refresh, I get the following:

    "The page cannot be refreshed without resending the information".

    If I click on "retry", it submits it again. How can I make it so it refreshes or does nothing when I click on refresh?



  9. #9
    Join Date
    Jan 2003
    Dundee, Scotland
    sorry for misstake with method.

    "The page cannot be refreshed without resending the information".
    This is correct. If you click the refresh basically your telling the browers to redisplay the page the way it was when you first requested it. As the page is ASP then to do this it has to resend the information back to the server.

    How can I make it so it refreshes or does nothing when I click on refresh?
    You can't with ASP. Not sure if you can use Javascript to disable the refresh btton, but this is not recommended.

  10. #10
    Join Date
    Feb 2003
    One last thing!

    Ribeyed, I am using dropdown box code as follows:

    <Select Name="pudeliv">

    <option name="--choose one--" value="--choose one--"

    <% if select_opt = "--choose one--" then %> <%= selected %>

    <% end if %>>

    --choose one--</option>

    <option name="Pickup" value="Pickup"

    <% if select_opt = "Pickup" then %> <%= selected %>

    <% end if %>>


    <option name="Delivery" value="Delivery"

    <% if select_opt = "Delivery" then %> <%= selected %>

    <% end if %>>



    I also call the validate routine to hold values just prior to a submit to the same page as follows:


    validate = request.form("validate")

    if validate = "yes" then

    UserName = request.form("UserName")

    emailaddress = request.form("emailaddress")

    pudeliv = request.form("pudeliv")

    phone = request.form("phone")

    addressdeliv = request.form("addressdeliv")

    coname = request.form("coname")

    then I use cdonts to email me the form……

    end if


    All works fine except that when my page links to itself and returns, the pudeliv dropdown field returns to -choose one- regardless of which item I select. The email I get is fine with the proper selection.

    1. Do I need to save the pudeliv field? If so, am I doing it correctly above?

    2. What else do I need to do keep the value I selected when I come back from the link to myself?

    Thanks for taking the time, really appreciated.


  11. #11
    Join Date
    Jan 2003
    Dundee, Scotland
    i am not sure which order you have your select box and your validation script but i will persume it is in the same order as what you have posted. If this is the case then you need to request the value of the select box before you try use the value in your if statment in your options. Bellow is an example:

    <%pudeliv = request.form("pudeliv")%>
    <form action="selecttest.asp" method="post">
      <Select Name="pudeliv"> 
    <option name="--choose one--" value="choose one" <% if pudeliv = "choose one" then response.write "selected" end if%>>--choose one--</option> 
    <option name="Pickup" value="Pickup" <% if pudeliv = "Pickup" then response.write "selected" end if %>>Pickup</option> 
    <option name="Delivery" value="Delivery" <% if pudeliv = "Delivery" then response.write "selected" end if %>>Delivery</option> 
      <input type="submit" name="Submit" value="Submit">
    What you need is the request.form stuff and validation at the top of your page then your form. This way if the page is being displayed for the first time the validation part will be skipped and only display the form with the initial state for text and select boxes etc. On submit the page starts again this time it will do the validate, set values to variables for all your form elements then display the form again, but this time you have all your values to work with. You can now use them to set the submitted values on your form.

    Hope this helps.

  12. #12
    Join Date
    Feb 2003


    Ribeyed, It worked like a charm.

    I am very greatful for your help!


  13. #13
    Join Date
    Jan 2003
    Dundee, Scotland
    good stuff, well done and no problem any time.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

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



X vBulletin 4.2.2 Debug Information

  • Page Generation 0.12561 seconds
  • Memory Usage 2,992KB
  • Queries Executed 15 (?)
More Information
Template Usage (34):
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_global_above_footer
  • (1)ad_global_below_navbar
  • (1)ad_global_header1
  • (1)ad_global_header2
  • (1)ad_navbar_below
  • (1)ad_showthread_firstpost_sig
  • (1)ad_showthread_firstpost_start
  • (1)ad_thread_first_post_content
  • (1)ad_thread_last_post_content
  • (2)bbcode_code
  • (2)bbcode_quote
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)headinclude_bottom
  • (13)memberaction_dropdown
  • (1)navbar
  • (4)navbar_link
  • (1)navbar_moderation
  • (1)navbar_noticebit
  • (1)navbar_tabs
  • (2)option
  • (13)postbit
  • (13)postbit_onlinestatus
  • (13)postbit_wrapper
  • (1)spacer_close
  • (1)spacer_open
  • (1)tagbit_wrapper 

Phrase Groups Available (6):
  • global
  • inlinemod
  • postbit
  • posting
  • reputationlevel
  • showthread
Included Files (26):
  • ./showthread.php
  • ./global.php
  • ./includes/class_bootstrap.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/functions_navigation.php
  • ./includes/class_friendly_url.php
  • ./includes/class_hook.php
  • ./includes/class_bootstrap_framework.php
  • ./vb/vb.php
  • ./vb/phrase.php
  • ./includes/functions_facebook.php
  • ./includes/functions_calendar.php
  • ./includes/functions_bigthree.php
  • ./includes/class_postbit.php
  • ./includes/class_bbcode.php
  • ./includes/functions_reputation.php
  • ./includes/functions_notice.php
  • ./packages/vbattach/attach.php
  • ./vb/types.php
  • ./vb/cache.php
  • ./vb/cache/db.php
  • ./vb/cache/observer/db.php
  • ./vb/cache/observer.php 

Hooks Called (72):
  • init_startup
  • friendlyurl_resolve_class
  • init_startup_session_setup_start
  • database_pre_fetch_array
  • database_post_fetch_array
  • init_startup_session_setup_complete
  • global_bootstrap_init_start
  • global_bootstrap_init_complete
  • cache_permissions
  • fetch_postinfo_query
  • fetch_postinfo
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • load_show_variables
  • load_forum_show_variables
  • global_state_check
  • global_bootstrap_complete
  • global_start
  • style_fetch
  • global_setup_complete
  • showthread_start
  • showthread_getinfo
  • strip_bbcode
  • friendlyurl_clean_fragment
  • friendlyurl_geturl
  • forumjump
  • cache_templates
  • cache_templates_process
  • template_register_var
  • template_render_output
  • fetch_template_start
  • fetch_template_complete
  • parse_templates
  • fetch_musername
  • notices_check_start
  • notices_noticebit
  • process_templates_complete
  • friendlyurl_redirect_canonical
  • showthread_post_start
  • showthread_query_postids
  • showthread_query
  • bbcode_fetch_tags
  • bbcode_create
  • showthread_postbit_create
  • postbit_factory
  • postbit_display_start
  • postbit_imicons
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • postbit_display_complete
  • memberaction_dropdown
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • build_navigation_data
  • build_navigation_array
  • check_navigation_permission
  • process_navigation_links_start
  • process_navigation_links_complete
  • set_navigation_menu_element
  • build_navigation_menudata
  • build_navigation_listdata
  • build_navigation_list
  • set_navigation_tab_main
  • set_navigation_tab_fallback
  • navigation_tab_complete
  • fb_like_button
  • showthread_complete
  • page_templates