Jump to content

Updating Prices


jaronblake

Recommended Posts

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.
Link to comment
Share on other sites

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.
Link to comment
Share on other sites

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.
Link to comment
Share on other sites

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.
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.