Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

PHP Forum


You are currently viewing our PHP Forum as a guest. Please register to participate.
Login



Freelance Jobs

Reply
Need to do an online quote, not a cart...
Old 03-14-2005, 06:23 PM Need to do an online quote, not a cart...
consure's Avatar
Novice Talker

Posts: 9
Trades: 0
I need perhaps a template, or someone to point me in the right direction on a software package to use to make up an online quote page for a retail computer store.

Basically I need to have a bunch of pull downs populated from a MySQL database (already exists), and I need price beside the item chosen in the pull down, then totals for the items based on what was chosen in the pull downs.

I have done a php page with pull downs populated by the DB, but I can't manage the (what I'm told) javascript needed to put the price in the text box beside the pull downs, then add the price up! argh... a kind person here explained a lot of javascript code to me, but I just can't make it 'jive'.. any help appreciated!

consure is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 03-14-2005, 06:51 PM
Phaedrus's Avatar
Ultra Talker

Posts: 271
Location: CA
Trades: 0
See if this thread helps any: http://www.webmaster-talk.com/showthread.php?t=25705

If not, go ahead and post up some of your code and we can get it figured out.
__________________

Please login or register to view this content. Registration is FREE

Last edited by Phaedrus; 03-14-2005 at 06:57 PM..
Phaedrus is offline
Reply With Quote
View Public Profile
 
Old 03-14-2005, 07:19 PM
azkul's Avatar
Skilled Talker

Posts: 58
Location: Utah
Trades: 0
This type of system can get tricky. In the end, what you need to do is echo JavaScript. The trick is when you have a dynamic number of menu items, you need to write the same items into your JavaScript. I use the "eval" a lot for this so that I dynamically add a number to each of the elements. If you're not sure how to use eval, PM me and I'll send you some sample code.
__________________

Please login or register to view this content. Registration is FREE


Please login or register to view this content. Registration is FREE


Please login or register to view this content. Registration is FREE
azkul is offline
Reply With Quote
View Public Profile Visit azkul's homepage!
 
Old 03-14-2005, 10:39 PM
consure's Avatar
Novice Talker

Posts: 9
Trades: 0
Phaedrus, hey, I think you were the person who posted some code for me in my other post... I understood your concepts, just don't really understand enough of coding to put ideas into action lol... I did look at that link but on my quick browse, the items there were static and I don't understand how to take your ideas onto my dynamic page... Maybe its best if I post some of my code. Theres a lot so I'll just post some snippits I suppose, probably messy, I have done it with Dreamweaver MX.

PHP Code:

<?php require_once('Connections/dbm_mydatabasename.php'); ?>
<?php
mysql_select_db
($database_dbm_mydatabasename$dbm_mydatabasename);
$query_motherboard "SELECT * FROM products WHERE idCategory = 14 ORDER BY idSubCategory ASC";
$motherboard mysql_query($query_motherboard$dbm_mydatabasename) or die(mysql_error());
$row_motherboard mysql_fetch_assoc($motherboard);
$totalRows_motherboard mysql_num_rows($motherboard);
And that continues on with other categories such as cpu, memory, hdd... etc...
Then I have this after the body tag...

PHP Code:

<body>
<form name="form1" method="post" action="">
  <p>Motherboard........:
    <select name="select">
      <?php
do {  
?>
      <option value="<?php echo $row_motherboard['brand']?>"><?php echo $row_motherboard['brand']." ".$row_motherboard['nameEng']?></option>
      <?php
} while ($row_motherboard mysql_fetch_assoc($motherboard));
  
$rows mysql_num_rows($motherboard);
  if(
$rows 0) {
      
mysql_data_seek($motherboard0);
      
$row_motherboard mysql_fetch_assoc($motherboard);
  }
?>
    </select>

<br>
And that also goes on for the various categories. I haven't bothered posting the version with the text box, cause I figured it'd be cleaner like this... I think I deleted that attempt anyhow! What do you guys think??
heh

Last edited by consure; 03-14-2005 at 10:41 PM..
consure is offline
Reply With Quote
View Public Profile
 
Old 03-14-2005, 10:52 PM
Phaedrus's Avatar
Ultra Talker

Posts: 271
Location: CA
Trades: 0
Okay, you've got some dropdown menus... cool. Now, what exactly do you need to happen? And, what event do you need to trigger it?

For example, do you need the price for something to be displayed when that thing is selected? Do you need prices to be added up into a total?

I'll write some generic code for you that you can just plug in, but I need a few more details.
__________________

Please login or register to view this content. Registration is FREE
Phaedrus is offline
Reply With Quote
View Public Profile
 
Old 03-15-2005, 01:34 AM
consure's Avatar
Novice Talker

Posts: 9
Trades: 0
Well thanks for your constant help! And anyone else who'd like to jump in too... Yes, when something is selected from the dropdown, I need the price for that item to appear in a text box (prices are also stored in the mysql database) and then I need a total for all the items picked from the dropdowns.
OR, I suppose if it is easier - I could include the price in the dropdown beside the name of the product... I'd still like a running total type thing. Perhaps I'll PM you a link to a site that sort of has my general ideas! (not sure if I'm allowed to post it since its a retail store)
consure is offline
Reply With Quote
View Public Profile
 
Old 03-15-2005, 03:58 AM
Phaedrus's Avatar
Ultra Talker

Posts: 271
Location: CA
Trades: 0
Okay this will work for any amount of dropdown menus, and you can basically just plug it right in. It displays the price of the selected item and keeps a running total at the bottom.

Requirements:

* Make sure the <select> menus are in a <form> tag.

* When you build the menus, set the value of the <option> tags to the price, without the dollar sign, something like:
PHP Code:
<option value="<?php echo $row_motherboard['price']?>">
* Put this inside the <head> of the page:

Code:
<script language="javascript">
function calculate()
{	
	var total = 0;
	var displayTotal = document.forms[0].elements[document.forms[0].elements.length-1];
	
	for(i=0;i<document.forms[0].elements.length-2;i++)
	{
		if((document.forms[0].elements[i].type == "select-one"))
		{
			if(document.forms[0].elements[i].value != "select one")
			{
				document.forms[0].elements[i+1].value = document.forms[0].elements[i].value;
				total += parseFloat(document.forms[0].elements[i].value);
			}
			else
			{
				document.forms[0].elements[i+1].value = "";
			}
		}
	}
	displayTotal.value = Math.round(total*100)/100;
}
</script>
* Add onChange="calculate();" to your <select> menus like this:

HTML Code:
<body>
<form>

<p>

Motherboard........:<br />
<select onChange="calculate();">
	<option value="select one">Select one</option>
	<option value="99.95">ACME basic</option>
	<option value="149.95">ACME plus</option>
	<option value="249.95">Intel 435</option>
</select> <input type="text" /><br /><br />

CPU................:<br />
<select onChange="calculate();">
	<option value="select one">Select one</option>
	<option value="44.95">CPU basic</option>
	<option value="79.95">CPU plus</option>
	<option value="129.95">Intel CPU</option>
</select> <input type="text" /><br /><br />

Memory.............:<br />
<select onChange="calculate();">
	<option value="select one">Select one</option>
	<option value="199.95">10 Gig</option>
	<option value="249.95">20 Gig</option>
	<option value="349.95">40 Gig</option>
</select> <input type="text" /><br /><br />

Total..............:<br />
<input type="text" /> 

</form>
</body>
* Set the value of the first <option> in each menu to "select one". (Edit: This should be easy because it looks like you're hand-coding the actual <select> box, it's only the options that are dynamic... So now, you just hand-code the first <option> as well.)

That's about it... the code is generic so you can name your form elements whatever you want, or not name them at all, and it will work the same.

The order of the elements is important, though, you want to have a dropdown, then its price box, dropdown-price, dropdown-price, like that until the end, and then just throw in an extra text box for the total.
__________________

Please login or register to view this content. Registration is FREE

Last edited by Phaedrus; 03-15-2005 at 04:37 AM..
Phaedrus is offline
Reply With Quote
View Public Profile
 
Old 03-16-2005, 01:10 AM
consure's Avatar
Novice Talker

Posts: 9
Trades: 0
Wow, so I actually have something going now - I started a fresh page and did everthing you mentioned and things are going well --- just one thing: In my database, I have a table called 'products'. In that table I have many FIELDS, including: ' idCategory' and 'idSubCategory'. SO- on the quote page, I have a drop down for floppy drives (fdd) and one for hard drives (hdd). The floppy drives are a subcategory of hard drives. See here:

PHP Code:
mysql_select_db($database_dbm_mydatabase$dbm_mydatabase);
$query_fdd "SELECT * FROM products WHERE idSubCategory = 17";
$fdd mysql_query($query_fdd$dbm_mydatabase) or die(mysql_error());
$row_fdd mysql_fetch_assoc($fdd);
$totalRows_fdd mysql_num_rows($fdd);

mysql_select_db($database_dbm_mydatabase$dbm_mydatabase);
$query_hdd "SELECT * FROM products WHERE idCategory = 5";
$hdd mysql_query($query_hdd$dbm_mydatabase) or die(mysql_error());
$row_hdd mysql_fetch_assoc($hdd);
$totalRows_hdd mysql_num_rows($hdd); 
The problem is that when I select something in the FDD dropdown, it selects the same thing in the HDD dropdown automatically. So do I have to figure something to exclude the FDD subcategory from the HDD dropdown? btw, super happy that I now have something calculating something!!!! lol

Edit I've just re-read the bottom part of your post for like the 4th time, I've been using one text box for the grand total all along, I'm going to try doing a text box for each pull down THEN a text box for total... and see what happens!

Last edited by consure; 03-16-2005 at 01:28 AM..
consure is offline
Reply With Quote
View Public Profile
 
Old 03-16-2005, 01:32 AM
Phaedrus's Avatar
Ultra Talker

Posts: 271
Location: CA
Trades: 0
Yeah that should work, just put a text box after every select box until the end, then add another text box for the total. So at the end, there's two text boxes in a row.
__________________

Please login or register to view this content. Registration is FREE

Last edited by Phaedrus; 03-16-2005 at 01:56 AM..
Phaedrus is offline
Reply With Quote
View Public Profile
 
Old 03-16-2005, 02:18 AM
consure's Avatar
Novice Talker

Posts: 9
Trades: 0
Yes, totally worked!! Thanks verrry much, now my boss won't bug me about this anymore! And I've learned a few things!!
consure is offline
Reply With Quote
View Public Profile
 
Reply     « Reply to Need to do an online quote, not a cart...
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.30978 seconds with 12 queries