What is JotForm?
JotForm is a free online form builder which helps you create online forms without writing a single line of code. No sign-up required.

At JotForm, we want to make sure that you’re getting the online form builder help that you need. Our friendly customer support team is available 24/7.

We believe that if one user has a question, there could be more users who may have the same question. This is why many of our support forum threads are public and available to be searched and viewed. If you’d like help immediately, feel free to search for a similar question, or submit your question or concern.


  • Profile Image

    autofill with session variables using VBSCRIPT

    Asked by increase on October 18, 2014 at 12:13 PM

    I have a VBSCRIPT that saves session variables for Title and Price. How can I autofill the message box with these two variables?

    Page URL:
    http://bible-searches.com/omcb_order_test.asp

    session variables message vbscript
  • Profile Image
    JotForm Support

    Answered by jonathan on October 18, 2014 at 03:19 PM

    Hi,

    Can you please tell us which Title and Price you were referring to here.

    I checked your jotform http://www.jotformeu.com/form/42023423350338 from your website, but I could not find those fields.

    But to help you get started, you will most likely need to use the form full source code embed.

    http://www.jotform.com/help/104-How-to-get-the-Full-Source-Code-of-your-Form

    and use your own custom VBSCRIPT code to pre-populate the message box of your form.

    OR

    Just to let you know also, there are simple method of pre-filling the form fields with values using jotform.

    1. Using the Field Prepopulator App (http://apps.jotform.com/app/field_prepopulator)

    2. By using the method described on this user guide http://www.jotform.com/help/71-Prepopulating-fields-to-your-JotForm-via-URL-parameters

    Hope this help. Inform us if you need further assistance.

    Thanks.

     

     

  • Profile Image

    Answered by increase on October 18, 2014 at 03:27 PM

    Here is the code

    <%@ Language=VBScript %>
    <%option explicit%>
    <SCRIPT id=DebugDirectives runat=server language=javascript>
    // Set these to true to enable debugging or tracing
    @set @debug=false
    @set @trace=false
    </SCRIPT>
    <HTML>
    <HEAD>
    <META NAME="GENERATOR" Content="Microsoft Visual Studio 6.0">
    <title>Olde Musick and Cokery Books Order Form</title>
    </head>
    <body bgcolor="#b0e0ff">

    <%   
        dim strMode
        dim strRefNum
        dim strTitle
        dim strPrice
        dim dctTitle
        dim dctPrice
        dim strIdx
        dim vntKeys

        'Get the query string
        strMode = Request.QueryString("mode") & ""
        strRefNum = Request.QueryString("ref") & ""
        strTitle = Request.QueryString("title") & ""
        strPrice = Request.QueryString("price") & ""
        strIdx = Request.QueryString("idx") & ""

        'The order is held in a dictionary object
       
        'Create the dictionary objects
        set dctTitle = server.CreateObject("Scripting.Dictionary")
        set dctPrice = server.CreateObject("Scripting.Dictionary")
       
        if isobject(session("order_title")) then
            'Get the current document
            set dctTitle = session("order_title")
            set dctPrice = session("order_price")
        end if
       
        'If the mode is add, then add the new item, providing that there are no more than ten
        select case strMode
            case "add"
               
                if dctTitle.Count < 10 then
                    if not (dctTitle.Exists(strRefNum) or dctPrice.Exists(strRefNum)) then
                        dctTitle.Add strRefNum, strTitle
                        dctPrice.Add strRefNum, strPrice
                    end if
                end if

            case "remove"
                vntKeys = dctTitle.Keys

                dctTitle.Remove(vntKeys(strIdx))
                dctPrice.Remove(vntKeys(strIdx))
               
        end select
               
        'Save the order
        set session("ref") = dctTitle
        set session("order_price") = dctPrice
          
    %>

    <script type="text/javascript">
    </script>
    <p align="center"><font size="5"><u>Olde Musick &amp; Cokery Books Enquiry Form</u></font></p>
    <font size="2">
    <p>Our Terms: Prices are quoted in Euros. Airmail Postage, insurance and bank charges are extra. We regret we no longer accept Visa card and Mastercard - due to the immense decline in their use by the majority of our customers.</p><p>
    Fill out the email Order form below. On receipt of your Order, we will contact you with full cost details and upon payment we will forward the items.</p><p>
    We accept Paypal. Cheques in Euros drawn on an Irish Bank, or British Sterling cheques drawn on a British bank, or Australian $ cheques drawn on an Australian Bank.</p><p>
    Additionally, a direct debit into our bank account would also be acceptable. In this case enter your preference on the enquiry form and specify your payment method and we can email the full amount in both Euros and in your preferred currency to you. Upon cleared payment, we will be pleased to post the items to you.
    </p>
    <p align="center" style="text-indent:0; line-height:1; margin:0;"><font size="4"><u>Please email your order on the form below</u></font></p>
    <p align="center" style="text-indent:0; line-height:1; margin:0;">Note: when filling in the form, please copy the antispam characters into the right hand box provided, then send message. </p>
    <p align="center" style="text-indent:0; line-height:1; margin:0;">&nbsp;</p>
    </font>
    <p align="center" style="text-indent:0; line-height:1; margin:0;">
    <script src="//max.jotfor.ms/static/prototype.forms.js" type="text/javascript">
    </script>
    <script src="//max.jotfor.ms/static/jotform.forms.js?3.2.2926" type="text/javascript">
    </script>
    <script type="text/javascript">
       JotForm.setConditions([{"action":[{"field":"5","visibility":"Require"}],"id":"1405875621052","index":"0","link":"Any","priority":"0","terms":[{"field":"5","operator":"isEmpty","value":false}],"type":"require"}]);
       JotForm.init(function(){
          $('input_5').hint('ex: myname@example.com');
          JotForm.initCaptcha('input_6');
       });
    </script>
        </p>
    <form class="jotform-form" action="http://submit.jotformeu.com/submit/42023423350338/" method="post" name="form_42023423350338" id="42023423350338" accept-charset="utf-8">
     
        <p align="center" style="text-indent:0; line-height:1; margin:0;">&nbsp;</p>
                        <div id="cid_4" class="form-input">
              <span class="form-sub-label-container">
                </span>
            <p align="center" style="text-indent:0; line-height:1; margin:0;"><span class="form-sub-label-container">First Name &nbsp;</span><span class="form-sub-label-container"><input class="form-textbox" type="text" size="10" name="q4_name[first]" id="first_4" />
            <label class="form-sub-label" for="first_4" id="sublabel_first">  </label> &nbsp;Last Name</span>
              <span class="form-sub-label-container">
                <input class="form-textbox" type="text" size="15" name="q4_name[last]" id="last_4" />
            <label class="form-sub-label" for="last_4" id="sublabel_last">  </label>
              </span></p>
            <p align="center" style="text-indent:0; line-height:1; margin:0;">&nbsp;</p>
            <p align="center" style="text-indent:0; line-height:1; margin:0;"><label class="form-label form-label-left form-label-auto" id="label_5" for="input_5"> * Email Address</label>
     <input type="email" class=" form-textbox validate[Email]" id="input_5" name="q5_emailAddress" size="30" value="" />
    </p>
            <div id="cid_5" class="form-input">
                          <p align="center" style="text-indent:0; line-height:1; margin:0;">&nbsp;</p>
                <p align="center" style="text-indent:0; line-height:1; margin:0;"><label class="form-label form-label-left form-label-auto" id="label_3 value = "strRefNum"" for="input_3"> Message</label>
    </p>
                <div id="cid_3" class="form-input">

             
                    <p align="center" style="text-indent:0; line-height:1; margin:0;"><textarea id="input_3" class="form-textarea" name="q5_fullName[first]" value="strRefNum" cols="40" rows="6"></textarea></p>

                    <p align="center" style="text-indent:0; line-height:1; margin:0;">&nbsp;</p>
                    <p align="center" style="text-indent:0; line-height:1; margin:0;"><label class="form-label form-label-top" id="label_6" for="input_6">
              Enter the code below as it's shown
              <span class="form-required">
                *
              </span>
                    </label>
    </p>
                        <div id="cid_6" class="form-input-wide">
                        <div class="form-captcha">
                            <p align="center" style="text-indent:0; line-height:1; margin:0;"><label for="input_6"> <img alt="Captcha - Reload if it's not displayed" id="input_6_captcha" class="form-captcha-image" style="background:url(http://max.jotfor.ms/images/loader-big.gif) no-repeat center;" src="//max.jotfor.ms/images/blank.gif" width="150" height="41" />    </label>
    </p>
                            <div style="white-space:nowrap;">
                 
                                <p align="center" style="text-indent:0; line-height:1; margin:0;"><input type="text" id="input_6" class="form-textbox validate[required]" name="captcha" style="width:130px;" />
                  <img src="//max.jotfor.ms/images/reload.png" alt="Reload" align="absmiddle" style="cursor:pointer" onclick="JotForm.reloadCaptcha('input_6');" />
                  <input type="hidden" name="captcha_id" id="input_6_captcha_id" value="0" />
    </p>
                                <p align="center" style="text-indent:0; line-height:1; margin:0;"><button id="input_2" type="submit" class="form-submit-button">
                  Submit
                                </button>
    </p>
                                <p align="center" style="text-indent:0; line-height:1; margin:0;">&nbsp;</p>
                                <p align="center" style="text-indent:0; line-height:1; margin:0;">*required field</p>
                            </div>
                        </div>
                        </div>
                </div>
            </div>
                        </div>
     
        <p align="center" style="text-indent:0; line-height:1; margin:0;"><input type="hidden" id="simple_spc" name="simple_spc" value="42023423350338" />
        <script type="text/javascript">
      document.getElementById("si" + "mple" + "_spc").value = "42023423350338-42023423350338";
     
       
        </script>
    </p>
    </form>
    </body>
    </html>

    So these would be the two variables from the top of the form

        set session("ref") = dctTitle
        set session("order_price") = dctPrice

     

    and I want to prefill them automatically into the message box when the form page is opened

    Thanks for the help

  • Profile Image
    JotForm Support

    Answered by jonathan on October 18, 2014 at 05:15 PM

    Hi,

    Please check this article also.

    Base on your details, you can do it like this..

    1. Get your jotform http://www.jotform.com/42023423350338  full source code embed

    2. On the embedded form source code you need to look for the "message" field input ID#.

    In your jotform it was this one

    <textarea id="input_3" class="form-textarea" name="q3_message" cols="40" rows="6"></textarea>

     

    3. Better if you combine first the value of the 2 session variables Title and Order Price into single variable so that you can just use 1 variable to fill in the 'message' field value.

    something like this..

    set session("ref") = dctTitle

    set session("order_price") = dctPrice

    set session("forMessage") = dcTitle & "|" & dcPrice

     

    4. To fill the value of the 'message' field, code should be like this

    <textarea id="input_3" class="form-textarea" name="q3_message" cols="40" rows="6"  value="<%=Request.Form("forMessage")%>"></textarea>

     

    I am not very familiar with classic ASP/VBSCRIPT so it may require some correction. But I am quite confident that you will somehow be able to figure this out since you are more verse on it.

    Do inform us if you encounter any difficulty accomplishing your requirement.

    Thanks.

     

  • Profile Image

    Answered by increase on October 19, 2014 at 09:50 AM

    Thanks for the reply, I cannot work out then syntax, whenever I use <% as in <%=Request.Form("forMessage")%>"> I get a form error

  • Profile Image

    Answered by increase on October 19, 2014 at 09:58 AM

    seems whenever I use the <% I get 500 error cannot display form?

  • Profile Image

    Answered by increase on October 19, 2014 at 10:07 AM

    Is it because I am trying to write into a form, that is meant to be filled manually only by a live client ?

  • Profile Image
    JotForm Support

    Answered by jonathan on October 19, 2014 at 10:10 AM

    Hi,

    Sorry for the delays.

    Can you share to us the URL of the test website?

    I tried checking it the previous test website you provided http://bible-searches.com/omcb_order_test.asp but the doesn't seem to work anymore.

    We can check for more details if we can see the actual form on the website.

    Thanks.

     

     

  • Profile Image

    Answered by increase on October 19, 2014 at 11:19 AM

    Yes here is the live site http://www.musick-cokerybooks.com/Home/default.asp click '**quick search**' on the left hand menu, then click the search button next to search for reference number

    Then click 'Click here to order' next to ref no 309

    In the order form that opens I am trying to place the Title and Price into the message box

         

     

  • Profile Image

    Answered by Shadae on October 19, 2014 at 02:34 PM

    Hi increase,

    Thank you for providing us with that additional information

    Jonathan has received your response and will review your form and will get back to you as soon as possible.

    Thank you.