Results 1 to 6 of 6

Thread: Javascript Help

  1. #1
    Hmmm bed
    Join Date
    Jul 2003
    Posts
    441
    Thanks
    5
    Thanked
    0 times in 0 posts

    Javascript Help

    Hi, i'm trying to develop a pc configurator using javascript just wondered if anyone could help me do this.

    What i want is for users to select the part from a drop down list (each part has a set price) and the price of each part is totalled up and store in a <input type="hidden" name="amount" value="sumvaluehere"> kinda situation.

    can anyone help?

    cheers

  2. #2
    Member
    Join Date
    Aug 2003
    Location
    Wimbledon
    Posts
    141
    Thanks
    0
    Thanked
    0 times in 0 posts
    Is it just a piece of standalone HTML or will it be part of a ASP/PHP website?

    If the page has ASP/PHP behind it you will be able to write some server side script which reads the selected item from each drop down list and adds them up so no need for a hidden total field.

  3. #3
    Hmmm bed
    Join Date
    Jul 2003
    Posts
    441
    Thanks
    5
    Thanked
    0 times in 0 posts
    well it integrates with paypal payment, so that hidded payment field is required to tell the payment system how much to debit the customer card

  4. #4
    Member
    Join Date
    Aug 2003
    Location
    Wimbledon
    Posts
    141
    Thanks
    0
    Thanked
    0 times in 0 posts
    Save this to a file and have a play. The total is updated whenever the selection in the drop downs change. The button is just used to display the current value of the hidden field.

    Code:
    <HTML>
    <HEAD>
    <script>
    function Update_Total()
    {
    	totalAmount.value = Number(ddCPU.value) + Number(ddHDD.value);
    }
    
    function Total_Click()
    {
    	alert(totalAmount.value);
    }
    </script>
    </HEAD>
    <BODY onload="Update_Total()">
    	<SELECT id=ddCPU onchange="Update_Total()">
    		<OPTION value=200>Pentium II - £200</OPTION>
    		<OPTION value=300>Pentium III - £300</OPTION>
    		<OPTION value=400>AMD Athlon - £400</OPTION>
    	</SELECT>
    	<BR>
    	<BR>
    	<SELECT id=ddHDD onchange="Update_Total()">
    		<OPTION value=20>20Gb - £20</OPTION>
    		<OPTION value=30>40Gb - £30</OPTION>
    		<OPTION value=40>80Gb - £40</OPTION>
    	</SELECT>
    	<BR>
    	<BR>
    	<input type="button" value="Total" onclick="Total_Click()">
    	<INPUT id=totalAmount type="hidden" value=0>
    </BODY>
    </HTML>

  5. #5
    Hmmm bed
    Join Date
    Jul 2003
    Posts
    441
    Thanks
    5
    Thanked
    0 times in 0 posts
    cheers, m8, will let you know how i get on
    Last edited by Basher; 22-01-2004 at 08:17 PM.

  6. #6
    Pixel Abuser Spunkey's Avatar
    Join Date
    Nov 2003
    Location
    Milton Keynes
    Posts
    1,523
    Thanks
    0
    Thanked
    0 times in 0 posts
    the only problem with that is the fact that when you submit the form, instead of getting the names of the components people have specified youll end up with just their values. Which is fine unless two items have the same price - doh

    id do it similar to the way you were, having a load of hidden fields at the bottom of the page which relate to the records in the database (assuming you have a DB, if not then just hard code all the values in there) call each field by the value you have on the option tag.

    eg.
    <OPTION value="20Gb HDD">20Gig Seagate HDD</option>

    the corresponding value =
    <INPUT type="hidden" name="20Gb HDD" value="20">

    then in your javascript for the onchange event of the dropdown, look for a field called 'hddprice = document.all[document.formname.SelectTagName.value].value'

    Hope this all made sense ive just rattled it off from memory
    Of course this is probably all a lot more beneficial if your looping through a database otherwise you'll be updating your prices in HTML manually

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Whats the javascript command for exit ?
    By Agent in forum Software
    Replies: 4
    Last Post: 29-09-2003, 10:37 PM
  2. Javascript Help
    By Basher in forum Software
    Replies: 31
    Last Post: 30-08-2003, 09:19 PM
  3. Replies: 1
    Last Post: 14-08-2003, 03:32 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •