SitePoint Sponsor

User Tag List

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

    JavaScript + HTML Forms: Dynamically Changing a Course Name & Price....

    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. There will also be about 10 course pages that will require their own course name and price attribute.

    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
    SitePoint Addict
    Join Date
    Apr 2002
    Location
    Whitehorse, Yukon
    Posts
    226
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    You don't need javascript to do this. Check and see if your host supports ColdFusion or another server side language such as PHP or ASP. Here is a simple ColdFusion solution; no database required.

    User Clicks On "Enroll Now" Button on the page "course.html". If this button is a drop-down menu, assign a value (such as Rocket Science, Biology, English, Brain Surgery, etc.) to each selection. For instance, in your form you would have "Rocket Science" with a value of 1 or RS or something you could use later on. Wrap <cfoutput> tags around this form and the server will parse the page wherever these appear and then they will be available to use on your form action page (such as enrolment.cfm).

    Append a parameter to the end of the url. You do this in your form action by adding # marks at the end of the page name. So it would be FORM ACTION="enrolment.cfm?courseID=#courseID#, for example. Now when the person clicks on your button, their course selection gets passed to the next page, such as enrolment.cfm?courseID=RocketScience, etc.

    Now on enrolment.cfm, simply put a set of <cfoutput> tags around the text you would like to be dynamic and the server will populate this text with your course name. So if you had the course name "Rocket Science" somewhere on enrolment.cfm, you'd have the text #courseID# (formatted however you like with CSS) wrapped with <cfoutput> tags. If you had used Rocket Science, this would now show up on the page ready to be printed off by a student.

    geof

  3. #3
    SitePoint Zealot
    Join Date
    Sep 2002
    Posts
    161
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks for your reply.

    Unfortunately the server the pages are hosted on, only use CGI That is why I originally thought about using JavaScript, so I didn't have to use CGI, what do you think?

    Cheers


    Originally posted by Geof Harries
    You don't need javascript to do this. Check and see if your host supports ColdFusion or another server side language such as PHP or ASP. Here is a simple ColdFusion solution; no database required.

    User Clicks On "Enroll Now" Button on the page "course.html". If this button is a drop-down menu, assign a value (such as Rocket Science, Biology, English, Brain Surgery, etc.) to each selection. For instance, in your form you would have "Rocket Science" with a value of 1 or RS or something you could use later on. Wrap <cfoutput> tags around this form and the server will parse the page wherever these appear and then they will be available to use on your form action page (such as enrolment.cfm).

    Append a parameter to the end of the url. You do this in your form action by adding # marks at the end of the page name. So it would be FORM ACTION="enrolment.cfm?courseID=#courseID#, for example. Now when the person clicks on your button, their course selection gets passed to the next page, such as enrolment.cfm?courseID=RocketScience, etc.

    Now on enrolment.cfm, simply put a set of <cfoutput> tags around the text you would like to be dynamic and the server will populate this text with your course name. So if you had the course name "Rocket Science" somewhere on enrolment.cfm, you'd have the text #courseID# (formatted however you like with CSS) wrapped with <cfoutput> tags. If you had used Rocket Science, this would now show up on the page ready to be printed off by a student.

    geof

  4. #4
    SitePoint Addict
    Join Date
    Apr 2002
    Location
    Whitehorse, Yukon
    Posts
    226
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Richard,

    Sorry I don't know much about CGI these days. I even pulled out my dusty old Perl 5 book but couldn't find a code sample that suited your situation, and I don't feel comfortable passing along code that "might" work when there's a pretty good chance I can't troubleshoot it

    I would suggest that you repost your question/problem in the Perl forum http://www.sitepointforums.com/forum...?s=&forumid=36 because you'd be running a .pl script anyways. Those folks would most certainly be able to help you.

    It's not that your question is complex (it's actually quite simple for someone in-the-know) so hopefully switching forums would help.

    geof

  5. #5
    SitePoint Zealot
    Join Date
    Sep 2002
    Posts
    161
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hi Geof

    It's okay, I found out a way to be able to integrate PERL into my HTML template and it works perfectly!

    Cheers for the responses though


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
  •