Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie
Hi there,
There is an issue with role permissions that is being worked on at the moment.
If you are having trouble with access or permissions on regional forums please post here to get access: https://www.boards.ie/discussion/2058365403/you-do-not-have-permission-for-that#latest

Form Question

  • 25-10-2010 3:31pm
    #1
    Registered Users, Registered Users 2 Posts: 2,650 ✭✭✭


    Hi, im not sure if this is in the right section so mods please move if necessary.

    Basically I have what is probably a fairly simple problem. On the homepage of the site im working on I have a small version of a booking form. Basically drop down boxes for Arrival date Departure date and number of people.

    What I want to be able to do is when this form is submitted it brings you to the full booking form on another page and fills in the data you have already submitted into the full form.

    I know to use the 'get' method to send the data to the second page but im having trouble splitting the data on the second page and filling it into the appropriate form fields.

    Im very new to this whole area so any help would be great


Comments

  • Registered Users, Registered Users 2 Posts: 21,263 ✭✭✭✭Eoin


    What language are you using (PHP / ASP / ASP.net etc)? You will most likely have an inbuilt method available to you that can get the value from the Querystring without having to do any lengthy string manipulation. Then you just need to assign that value to the form field.


  • Registered Users, Registered Users 2 Posts: 2,650 ✭✭✭cooperguy


    Hi eoin, it is just a standard html form on the second page which sends the data to a perl script to email the data to myself and display a thank you page.


  • Registered Users, Registered Users 2 Posts: 21,263 ✭✭✭✭Eoin


    OK, I don't know anything about perl scripts like if they can interact with a web page to set form fields etc. However, what you're looking to do can still be done using client side JavaScript.

    You need a JavaScript function that can interrogate the URL and return a value. It's not an inbuilt function, but there are a good few ones available if you google.

    Next you need a function that is called when the page has finished completed. This function will get the values from the querystring and assign them to the form fields.

    So, in pseudo-code, it would be something like this:
    function getQueryStringValue(qsName)
    {
        // return value of querystring based on the name
    }
    
    function checkFormFields()
    {
        // call this function when the page is fully loaded
        var sName = getQueryStringValue("txtName") // e.g. URL contains txtName=eoin
        document.getElementById("txtName").value = sName; // set the form field value
    
        var sDate = getQueryStringValue("txtDate") // e.g. URL contains txtDate=13-Apr-2010
        document.getElementById("txtDate").value = sDate ; // set the form field value
    }
    

    This should give you enough to get started. I can point you towards that function to get values from the URL for you if you need.


  • Closed Accounts Posts: 18,163 ✭✭✭✭Liam Byrne


    eoin wrote: »
    This should give you enough to get started. I can point you towards that function to get values from the URL for you if you need.

    http://www.enghiong.com/javascript-get-url-parameters.html


  • Registered Users, Registered Users 2 Posts: 6,570 ✭✭✭daymobrew


    eoin wrote: »
    OK, I don't know anything about perl scripts like if they can interact with a web page to set form fields etc.
    perl certainly can interact with a web page to set form fields.
    If you use the CGI.pm module you can retrieve data sent to the web page.

    If you are generating the html within the perl script then you can set the form field's "value".


  • Advertisement
Advertisement