Jump to content


Photo

Updating Prices


  • Please log in to reply
7 replies to this topic

#1 jaronblake

jaronblake
  • Members
  • PipPip
  • Member
  • 17 posts

Posted 22 June 2006 - 08:12 PM

I was looking at dell.com and i saw how you can click on a radio input and it will change the price with what you have selected and also the upgrade and downgrade options change too. I was tyring to do this in php but am having a little trouble.

here is the dell website [a href=\"http://configure.us.dell.com/dellstore/config.aspx?c=us&cs=19&l=en&oc=DB110A&s=dhs\" target=\"_blank\"]http://configure.us.dell.com/dellstore/con...oc=DB110A&s=dhs[/a]

here is my code so far. I cant figure out how to have it change once i clike on the radio button.
[!--coloro:#333399--][span style=\"color:#333399\"][!--/coloro--]<html>
<head>
<title>Upgrade</title>
</head>
<form>
<?php
$var1 = 10;
$var2 = 20;
$var3 = 40;


$selection = 1;

if ($selection == 1)
{
$update1 = $var1;
$update2 = $var1+$var2;
$update3 = $var1+$var2+$var3;

echo '<input type="radio" value"1" checked="true">Basic<br>';
echo '<input type="radio" value"2"">Bronze +$'.$update1.'<BR>';
echo '<input type="radio" value"3">Silver +$'.$update2.'<BR>';
echo '<input type="radio" value"4">Gold +$'.$update3.'<BR>';
}
if ($selection == 2)
{
$update1 = $var1;
$update2 = $var2;
$update3 = $var2+$var3;

echo '<input type="radio" value"1">Basic -$'.$update1.'<BR>';
echo '<input type="radio" value"2" checked="true">Bronze<BR>';
echo '<input type="radio" value"3">Silver +$'.$update2.'<BR>';
echo '<input type="radio" value"4">Gold +$'.$update3.'<BR>';
}
if ($selection == 3)
{
$update1 = $var1+$var2;
$update2 = $var2;
$update3 = $var3;

echo '<input type="radio" value"1">Basic -$'.$update1.'<BR>';
echo '<input type="radio" value"2">Bronze -$'.$update2.'<BR>';
echo '<input type="radio" value"3" checked="true">Silver<BR>';
echo '<input type="radio" value"4">Gold +$'.$update3.'<BR>';
}
if ($selection == 4)
{
$update1 = $var1+$var2+$var3;
$update2 = $var2+$var3;
$update3 = $var3;

echo '<input type="radio" value"1">Basic -$'.$update1.'<BR>';
echo '<input type="radio" value"2">Bronze -$'.$update2.'<BR>';
echo '<input type="radio" value"3">Silver -$'.$update3.'<BR>';
echo '<input type="radio" value"4" checked="true">Gold<BR>';
}
?>
</form>
<body>
</body>
</html>[!--colorc--][/span][!--/colorc--]

if there is a tutorial for this let me know.

#2 cmgmyr

cmgmyr
  • Members
  • PipPipPip
  • Advanced Member
  • 1,278 posts
  • LocationUSA

Posted 22 June 2006 - 08:16 PM

You would be able to do this with AJAX. Go to ajaxfreaks.com and read the tutorials.

It's very cool.

#3 jaronblake

jaronblake
  • Members
  • PipPip
  • Member
  • 17 posts

Posted 22 June 2006 - 08:19 PM

thank you very much

#4 cmgmyr

cmgmyr
  • Members
  • PipPipPip
  • Advanced Member
  • 1,278 posts
  • LocationUSA

Posted 22 June 2006 - 08:23 PM

No problem. AJAX is very cool! You can do a lot of slick stuff with it. That has been one of my more recent projects.

#5 Koobi

Koobi
  • Staff Alumni
  • Advanced Member
  • 419 posts
  • LocationColombo, Sri Lanka | South Asia

Posted 24 June 2006 - 09:17 PM

you would have to use Javascript because AJAX is actually Javascript (XMLHTTP Request Object).

PHP is a server side language so unless you submit your page back to the server, PHP won't even know the page exists.

AJAX is Javascript, mainly. which means its client side (on your PC - browser) so the moment it detects you've done something (like clicking on that radio button), the Javascript sends that radio buttons data in the background to your PHP page on the server and retrieves the data it needs frm that (the price of an item in this case) and then dynamically writes that value to a part of the page without refreshing the entire page (because Javascript has the capability to manipulate a part of a page as you may already know)


so in short, for the functionality you require, you would have to use a client side language and the best one i can think of is JavaScript at this moment.




:edit:
if you're looking for an AJAX class, try [a href=\"http://www.xajaxproject.org/\" target=\"_blank\"]Xajax[/a]
i'm not particularly a fan of AJAX which makes coding it an effort for me but the Xajax classes make it that much easier.

#6 Orio

Orio
  • Staff Alumni
  • Advanced Member
  • 2,491 posts

Posted 24 June 2006 - 09:27 PM

The question is- what are you trying to hide? The prices or the code the fetches them?
If it's the code- Basicly, everyone can see it.
But if it's the prices & data in tables- No one can see because not all of the information is loaded into the page, just what was asked.

Orio.
Think you're smarty?

(Gone until 20 to November)

#7 Koobi

Koobi
  • Staff Alumni
  • Advanced Member
  • 419 posts
  • LocationColombo, Sri Lanka | South Asia

Posted 24 June 2006 - 09:32 PM

if it can be viewed by your browser, there will be 101 ways to view it as the browser sees it.

keep in mind that the browser sees no PHP, it only sees the processed PHP (which happens on the hosts server) which is actually HTML.


why would you want to hide your Javascript anyway? all it would do is pass a variable to a PHP script on the server, variables that would exist on the page anyway.

#8 .josh

.josh
  • Staff Alumni
  • .josh
  • 14,871 posts

Posted 25 June 2006 - 07:13 AM

don't be stingy with your code man. you come here looking for help, and people freely offer it. you wanna make money, do it with your product and/or service. open source ftw!

anyways, that's my 2 cents.


Did I help you? Feeling generous? Buy me lunch! 
Please, take the time and do some research and find out how much it would have cost you to get your help from a decent paid-for source. A "roll-of-the-dice" freelancer will charge you $5-$15/hr. A decent entry level freelancer will charge you around $15-30/hr. A professional will charge you anywhere from $50-$100/hr. An agency will charge anywhere from $100-$250/hr. Think about all this when soliciting for help here. Think about how much money you are making from the work you are asking for help on. No, we do not expect you to pay for the help given here, but donating a few bucks is a fraction of the cost of what you would have paid, shows your appreciation, helps motivate people to keep offering help without the pricetag, and helps make this a higher quality free-help community :)




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users