SitePoint Sponsor

User Tag List

Results 1 to 4 of 4
  1. #1
    SitePoint Zealot
    Join Date
    Sep 2002
    Posts
    161
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Exclamation Using JavaScript for dynamic content

    I need to know if I can do the following with JavaScript. I have a course page and when the user clicks on "Enrol Now" I want the form to pass the course name and price onto the Enrolment page and dynamically print the course name and the price on the enrolment page. The course page can be a form.

    In simple steps:

    <User Clicks On "Enrol Now" Button> course.html

    <User is taken to enrolment page, I want to be able to pass the course name and price onto the enrolment page from course.html, and print it here> enrolment.html

    Im wondering if i can use a "Hidden" Input field to define the Course name & Price in course.html and when the user clicks on "Enrol Now", which is a button, the form takes the hidden fields and uses javascript to display them on the enrolment.html page. Is it possible to do this with plain HTML, I could not think of a solution with just HTML.

    Any advice would be greatly appreciated!

  2. #2
    Sports Publisher mjames's Avatar
    Join Date
    Jan 2000
    Location
    Charlotte, NC
    Posts
    5,891
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Moved to appropriate forum.

  3. #3
    SitePoint Enthusiast Wouter's Avatar
    Join Date
    Jan 2002
    Posts
    59
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Where is this question moved ?

    tx

  4. #4
    SitePoint Zealot
    Join Date
    Aug 2002
    Posts
    180
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Code:
    <script Language="JavaScript">
    var mainthing
    var price
    var price2
    var course
    mainthing = parent.document.URL;
    if (mainthing.indexOf('?price=') != -1) {
    	price = mainthing.substring(mainthing.indexOf('?price')+1,mainthing.length);
    	course = price.substring(price.indexOf('&course=')+1,price.length);
    	price2 = mainthing.substring(mainthing.indexOf('?price')+1,(mainthing.lengh)-(course.length)-8);
    }
    
    document.write('<p>'+price2+'</p>');
    document.write('<p>'+course+'</p>');
    </script>
    that should work, i havn't tested it though. it will only work if you are using a GET form and the first two fields in the url are price and course (in that order).

    this is not the most practicle thing in the world, a serverside language would be much more useful...


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
  •