Code for Computer price sheet
Results 1 to 3 of 3

Thread: Code for Computer price sheet

  1. #1
    Junior Member
    Join Date
    Jul 2005
    Posts
    15

    Code for Computer price sheet

    I'm currently building a webpage with javascript with numerous computer parts where a customer can choose parts to suit thier needs for a computer system. I have it set up so they click a check box in each category e.g processors, memory etc which then adds up a total price. I dont have a problem getting prices to add up when the checkboxes are checked but i need an error checking script so that they can only choose 1 item in a category for example they can only choose 1 processor and if they try to choose 2 processors i want it so that it spits out an error message like "You can only choose 1 processor". Any suggestions would be greatly appreciated.
    \"All men by nature desire knowledge\" - Aristotle


  2. #2
    Just Another Geek
    Join Date
    Jul 2002
    Location
    Rotterdam, Netherlands
    Posts
    3,403
    Why don't you use groups of radiobuttons? One group per category..

    As for checking.. (pseudocode, simple braindead solution)
    Code:
    a=0;
    if (checkbox1) then a++;
    if (checkbox2) then a++;
    if (checkbox3) then a++;
    if a>1 then alert ("greedy hey!");
    if a=0 then alert ("hey, pick 1!");
    Oliver's Law:
    Experience is something you don't get until just after you need it.

  3. #3
    Flash M0nkey
    Join Date
    Sep 2001
    Posts
    3,447
    yup am with SirDice on this I would def go with radio buttons rather than checkboxes. One other point to remember as well is that not only should you be validating the form client side but also server side. Never accept anything from the client is valid when received from a form to your server....no matter how strict your validation routines are in the client.

    As client side validation is being done on the users machine they can easily disable javascript or alter form elements (Firefox Webdev Toolbar Extension is just one way of altering actual form elements on the page.)

Posting Permissions

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

 Security News

     Patches

       Security Trends

         How-To

           Buying Guides