The forums ran from 2008-2020 and are now closed and viewable here as an archive.

Home Forums JavaScript Collecting form data to display elsewhere on page?

  • This topic is empty.
Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
  • #30844

    Hi there,

    Ive got a collection of forms all with check boxes, its basically a coffee menu with four sections.

    Say for example the user selects (clicks check box) a small cappuccino, a latte, and an espresso, how can i get the input names (name+size of coffee) to appear with the value (cost of coffee) in another div so i can then calculate sub-total, add vat etc

    So far ive only managed to get the users selections to appear where i want using jQuery serialize, however im having a little trouble picking out the values to carry out calculations on them.

    Can anyone suggest an easier / better way for me to approach this?

    note : this is a made up project for a fake client and cant involve any server side scripting.


    server side scripting would be the way to go for any project like this. If you use javascript then your form is subject to fail anytime anyone has javascript turned off. Your form will not work. This is bad web design. I would recommend that you use php. it is the best and easiest way to go. Getting the information is really easy using php. There are many form tutorials using php. Why don’t you want to use server side scripting?


    yeh i totally understand that, but this project is for a uni assignment, part one to only use client side technologies, part two is where these are changed out to server side.


    Have you tried using JSON? You can set up a multidimensional array of data that stores everything you need, then when the user selects something, simply utilise JQuery to get the appropriate corresponding price etc.


    hi mark, any chance you could explain that a bit more, im fairly new to javascript so just getting used to the basics.

    heres what i currently have,

    from here i need to be able to target the users selection to perform calculations for vat, delivery etc.



    I’ve managed to come up with a solution (im implementing at the moment), it involves separating the huge string of info and converting the cost of the coffees to a float where i can perform the calculations i need (Vat etc), and of course using css to position everything where it needs to be.

    I realise now i should have created an associative array or something similar for the coffee menu then pulled the users choice, similar to what mark suggested above, however im fairly new to javascript so just picking up things as i go.

    Thanks all for the help :)

Viewing 6 posts - 1 through 6 (of 6 total)
  • The forum ‘JavaScript’ is closed to new topics and replies.