SitePoint Sponsor

User Tag List

Results 1 to 4 of 4

Thread: Price Form

  1. #1
    SitePoint Member
    Join Date
    May 2003
    Location
    UK, Solihull
    Posts
    3
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Price Form

    Hi, I had a search on here and found a bit of script for check boxes but I dont know how to do the same for txt boxes

    http://beta.gardenfun4u.co.uk/form/

    Theres a simple form, if you click basketball and/or foot ball then calculate the cost it worsk but as for the quantity and total on the hop scotch.. well i aint got a clue lol. I removed checked from "ch"&&frm.elements[i].checked)" which worked but it also adds the checked value of the check boxes hehe.

    As you can see im kinda crap at javascript. If i can figure this little form out then I can probably do the main one myself well I hope:

    http://beta.gardenfun4u.co.uk/order/

    Its either figure it myself or pay someone to do it.. the quote was 100


    Any help would be appreciated, tnx

  2. #2
    Web-coding NINJA! silver trophy beetle's Avatar
    Join Date
    Jul 2002
    Location
    Dallas, TX
    Posts
    2,900
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    100 pounds? That's like $160!!! Somebody is trying to rip you off.

    Personally - I'd probably charge $50 (~30) for this but even then that's a strech. I mean - we're just talking about implementing some arithmetic, right?
    Code:
    <html>
    <head>
    	<title>Untitled Document</title>
    	<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
    	<link href="../css/garden.css" rel="stylesheet" type="text/css">
    	<script type="text/javascript">
    	
    		function doSubTotal( f, qty, targ, price )
    		{
    			qty = f.elements[qty];
    			if ( /[^\d]/.test( qty.value ) )
    			{
    				alert( "Please enter a valid number for a quantity" );
    				qty.select();
    				qty.focus();
    				return;
    			}
    			f.elements[targ].value = ( qty.value * price ).round( 2 );
    			doTotal( f );
    		}
    		function doTotal( f )
    		{
    			var total = 0;
    			if ( f.elements['chbasketball'].checked ) total += parseFloat( f.elements['chbasketball'].value );
    			if ( f.elements['chfootball'].checked ) total += parseFloat( f.elements['chfootball'].value );
    			total += parseFloat( f.elements['hopscotch_total'].value );
    			f.elements['Total'].value = total.round( 2 );
    		}
    		Number.prototype.round = function( places )
    		{
    			var rounder = Math.pow( 10, places );
    			return Math.round( this * rounder ) / rounder;
    		}
    	
    	</script>
    </head>
    <body class="content">
    	<form>
    	  <div align="left">
    		<table width="100%" border="1" cellpadding="2" cellspacing="2" class="content">
    		  <tr> 
    			<td>&nbsp;</td>
    			<td>quantity</td>
    			<td>price</td>
    			<td>total</td>
    			<td>Recalculate</td>
    		  </tr>
    		  <tr> 
    			<td><input name="chbasketball" type="checkbox" value="50">
    			  Basketball </td>
    			<td><div align="center">-</div></td>
    			<td><div align="center">50</div></td>
    			<td><div align="center">-</div></td>
    			<td>&nbsp;</td>
    		  </tr>
    		  <tr> 
    			<td> <input name="chfootball" type="checkbox" value="90">
    			  Football </td>
    			<td><div align="center">-</div></td>
    			<td><div align="center">90</div></td>
    			<td><div align="center">-</div></td>
    			<td>&nbsp;</td>
    		  </tr>
    		  <tr> 
    			<td>GIANT Hop Scotch</td>
    			<td><div align="center"> 
    				<input name="hopscotch_quantity" type="text" value="0" size="4">
    			  </div></td>
    			<td><div align="center">19.99</div></td>
    			<td><div align="center"> 
    				<input name="hopscotch_total" type="text" size="4" value="0" readonly="true">
    			  </div></td>
    			<td><input name="Recalculate" type="button" value="Update" onclick="doSubTotal(this.form,'hopscotch_quantity','hopscotch_total',19.99);">
    			</td>
    		  </tr>
    		</table>
    		overall Total 
    		<input type="text" name="Total" value="0" readonly="true">
    		<input type="button" onclick="doTotal(this.form)" value="Calculate">
    	  </div>
    	</form>
    	<div align="left">
    </div>
    </body>
    </html>
    beetle a.k.a. Peter Bailey
    blogs: php | prophp | security | design | zen | software
    refs: dhtml | gecko | prototype | phpdocs | unicode | charsets
    tools: ide | ftp | regex | ffdev




  3. #3
    SitePoint Member
    Join Date
    May 2003
    Location
    UK, Solihull
    Posts
    3
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    wow nice, tnx man
    I will let u know how it goes

  4. #4
    SitePoint Member
    Join Date
    May 2003
    Location
    UK, Solihull
    Posts
    3
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Right I have it installed but there are 2 things I still cant figure out

    If you look @ the form:

    http://beta.gardenfun4u.co.uk/order/test.php

    I dont know how to add the bottom 2 checkbox values 'Giant Chess Peices Board Option Stong PVC Mat' & 'Giant Chess Peices Board Option Rigid Mesh Lawn Saver' to the 'Total Giant Chess Pieces' txtbox or the 'Total' so that it auto updates as soon as you click..

    The top "new hoppers" section is just too hard to figure out, well for me anyway think it needs drop boxes with 1-10 in or something, I dont know there are too many ways a customer can order.

    Help here would be appreciated Tnx!


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
  •