Page 3 of 3 FirstFirst 123
Results 33 to 34 of 34

Thread: Computer Configurator

  1. #33
    Comfortably Numb directhex's Avatar
    Join Date
    Jul 2003
    Location
    /dev/urandom
    Posts
    17,074
    Thanks
    228
    Thanked
    1,027 times in 678 posts
    • directhex's system
      • Motherboard:
      • Asus ROG Strix B550-I Gaming
      • CPU:
      • Ryzen 5900x
      • Memory:
      • 64GB G.Skill Trident Z RGB
      • Storage:
      • 2TB Seagate Firecuda 520
      • Graphics card(s):
      • EVGA GeForce RTX 3080 XC3 Ultra
      • PSU:
      • EVGA SuperNOVA 850W G3
      • Case:
      • NZXT H210i
      • Operating System:
      • Ubuntu 20.04, Windows 10
      • Monitor(s):
      • LG 34GN850
      • Internet:
      • FIOS
    i want to make it clear just how much contempt i have for this - it's 1996-era crappy web design that would earn you a fail at first school.

    in the time it took me to get around javascript's innate unsuitability for the task, i could have done the thing, server-side, with a database back-end, such that it would work in any browser regardless of javascript DOM model, in three different languages.

    however, since your heart is set on it

    Code:
    <?xml version="1.0"?>
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"
            "http://www.w3.org/TR/REC-html40/loose.dtd">
    <html>
    <head>
    <title>foo</title>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
    </head>
    
    <body>
    
    <script type="text/javascript">
    function cent(amount)
    {
         return (amount == Math.floor(amount)) ? amount + '.00' : (  (amount*10 == Math.floor(amount*10)) ? amount + '0' : amount);
    }
    
    
    function calculate()
    {
    	var p1, p2, p3, pt;
    	p1 = document.test.price1hidden.value * 1;
    	p2 = document.test.price2hidden.value * 1;
    	p3 = document.test.price3hidden.value * 1;
    	pt = p1 + p2 + p3;
    	document.test.total_price.value = cent(Math.round(pt*Math.pow(10,2))/Math.pow(10,2));
    }
    
    </script>
    
    <form name="test" method="post" action="http://www.qkxyq.com/thalasson/mailform.cgi">
    <p>
      <input name="price1" type="radio" value="0" onclick="javascript:document.test.price1hidden.value='0';calculate();">0.00<br />
      <input name="price1" type="radio" value="10" onclick="javascript:document.test.price1hidden.value='10';calculate();">10.00<br />
      <input name="price1" type="radio" value="20" onclick="javascript:document.test.price1hidden.value='20';calculate();">20.00<br />
      <input name="price1" type="radio" value="30" onclick="javascript:document.test.price1hidden.value='30';calculate();">30.00<br />
      <input type="hidden" name="price1hidden">
    </p>
    <p>
      <input name="price2" type="radio" value="0" onclick="javascript:document.test.price2hidden.value='0';calculate();">0.00<br />
      <input name="price2" type="radio" value="10" onclick="javascript:document.test.price2hidden.value='10';calculate();">10.00<br />
      <input name="price2" type="radio" value="20" onclick="javascript:document.test.price2hidden.value='20';calculate();">20.00<br />
      <input name="price2" type="radio" value="30" onclick="javascript:document.test.price2hidden.value='30';calculate();">30.00<br />
      <input type="hidden" name="price2hidden">
    </p>
    <p>
      <input name="price3" type="radio" value="0" onclick="javascript:document.test.price3hidden.value='0';calculate();">0.00<br />
      <input name="price3" type="radio" value="10" onclick="javascript:document.test.price3hidden.value='10';calculate();">10.00<br />
      <input name="price3" type="radio" value="20" onclick="javascript:document.test.price3hidden.value='20';calculate();">20.00<br />
      <input name="price3" type="radio" value="30" onclick="javascript:document.test.price3hidden.value='30';calculate();">30.00<br />
      <input type="hidden" name="price3hidden">
    </p>
    <p>&nbsp;</p>
    <p>Total:   <input type="text" name="total_price"></p>
    
    <p>Name: <input type="text" size="10" maxlength="40" name="Name" /><br />
          </p>
    
          <p>Email: <input type="text" size="20" maxlength="40" name="Email" /><br />
          </p>
    
          <p><input type="submit" value="Submit" /> <input name="subject" type="hidden"
          value="Configuration Details" /> <input name="nextpage" type="hidden"
          value="www.cubicomputers.co.uk" /> <input name="emailto" type="hidden"
          value="nvening@gmail.com" /></p>
    </form>
    
    </body>
    </html>
    doesn't quite validate, not sure why.

    the main differences here from what you had are: variable names cannot be numbers, they must start with a letter or underscore; only referencing variables which exist (you mention "total_price" without declaring it in your calculate() function); using full paths for all DOM elements (i.e. document.formname.elementname.value always)
    Last edited by directhex; 02-07-2006 at 06:56 PM.

  2. #34
    lazy student nvening's Avatar
    Join Date
    Jan 2005
    Location
    London
    Posts
    4,656
    Thanks
    196
    Thanked
    31 times in 30 posts


    Ill see how this goes and at some point i will learn all the other stuff

    THANKS!!!
    (\__/)
    (='.'=)
    (")_(")

Page 3 of 3 FirstFirst 123

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Replies: 3
    Last Post: 07-12-2004, 11:45 AM
  2. Replies: 0
    Last Post: 07-12-2004, 10:44 AM

Posting Permissions

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