Jump to content

jonnystudent

Members
  • Posts

    19
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

jonnystudent's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. I know there is a simple way to do this but I can't seem to find it. I have a drop down box, which has a list. One you hover your mouse over any one of the items on the list, it's encircled by a border. This is great. What I want is for when a user selects an item from this list. It will automatically change the background colour to #ddd. If the user selects another item from the list, it will change that items background and the other item will have reverted back to it's white background. So, I have a class called 'hi'. My CSS is like so: #changer a{ padding:3px; border: solid 1px #fff; } #changer a.hi{ background:#ddd; } #changer a:hover{ border: solid 1px #ddd; text-decoration:none; } How would I change the element on selection using javascript or jquery. Any help would be mostly appreciated. Cheers, Jonny
  2. Wow, who'd have thought it. It was a case of putting some single quotes around the $c variable. I didn't need quotes at all or I could have put double quotes. This topic can now be labelled as answered. Cheers, Jonah
  3. Just as a side note. When I type in the URL ending in .php?c=EUR I have put a dump in there and my output is array 0 => string '"GBP$C=X"' (length=9) 1 => string '0.00' (length=4) 2 => string '"N/A"' (length=5) 3 => string '"N/A" ' (length=7) Why is the $c value not being returned as the chosen currency? Cheers, Jonah
  4. Hello all, I'm looking for some assistance with some code. I'm trying to put this to bed as it's driving me nuts. The Psuedo code for this would be to 1) Download the rates from the Yahoo API and declare my base rate to my foreign exchange. 2) Store an array of currencies to choose from to compare against the base currency. 3) I then GET the chosen currency and register it in a SESSION to be used on other pages. (I'm unsure if this is correct?) 4) I then calculate the Price of my product which is in GBP to the selected foreign currency. 5) Output the converted price anywhere on the page. My script takes GET values from the URL like so.. .com?c=EUR My code is like so.. 1) First I get the rates from the Yahoo API session_start(); $from = 'GBP'; $to = '$c'; $url = 'http://finance.yahoo.com/d/quotes.csv?e=.csv&f=sl1d1t1&s='. $from . $to .'=X'; $handle = @fopen($url, 'r'); if ($handle) { $result = fgets($handle, 4096); fclose($handle); } $allData = explode(',',$result); /* Get all the contents to an array */ $PoundValue = $allData[1]; 2) Then I store an array of the currencies. $currency_array = array ('USD','EUR','RMB','JPY','AUD','CHF') 3) Then I get the chosen currency. if(isset($_GET['c'])) { $c = $_GET['c']; if(array($currency_array)) { $_SESSION['currency_array'] = $c; } } 4) I then calculate the product price. $Total = $Price * $currency_array; $outprice = number_format($Total, 2, '.', ','); 5) Then I output on the page <?php echo .$outprice; ?> So is all my coding logically in the right order? Any help would be greatly appreciated. Thank you.
  5. Thanks guys. Very simple fix. There was a problem with the last line of the javascript. An offending ';'. All sorted. Cheers.
  6. Hi Thorpe thanks for the reply, drop down list is probably the better phrase for it. It's been done in CSS and I use Javascript to drop it. If you click on the fiddle you'll see it. The issue is when I put it in my web page, the dropdown doesn't work anymore. I'm wondering if it's because of the CSS. Would I need to wrap any of the currency id's in the top-header and header id's?
  7. Hi Guys, for some reason, my Dropdown box isn't working when I enter it into my webpage. I think it is a CSS issue hence me posting here. You can view my script here. http://jsfiddle.net/jonnystudent/kmqx7/ I think the issue lies in the fact that this dropdown box is wrapped within two divs. So there is body div id = top-header> div id = header> div id = currency-logout> <!-- Start of my Currency dropdown --> Any help would be greatly appreciated. Cheers.
  8. Sorry for the double post. Now that I have this script, I'll now need to have a currency base so that I can change the current currency to a global value and then convert that global value to the requested currency. Any ideas will be greatly appreciated. Will I have to connect to Yahoo or Google to get the base rate. How would this be programmed? If anyone could forward me any example, I'll be greatly appreciative. Cheers, Jonah
  9. I've altered my code somewhat as I realised that my previous code was not an array. So my new code is.. if(isset($_GET['c'])) { $currency = $_GET['c']; $currency_array = array( $currency_array [GBP] = 1.00; $currency_array [uSD] = 1.56362 ; $currency_array [EURO]= 1.18894; $currency_array [JPY] = 128.651; $currency_array [AUD] = 1.48711; $currency_array [CHF] = 1.43373; ); if(array($currency, $currency_array)) { $_SESSION['rdt'] = $currency; } } if(!isset($_SESSION['rdt'])) { $_SESSION['rdt'] = 'GBP'; } ?> <span>Currency:</span><a href="http://x/Currency_script.php?c=GBP" class="hi"> £ GBP</a><a href="http://x/Currency_script.php?c=USD"> $ USD</a><a href="http://x/Currency_script.php?c=EURO"> € EURO</a><a href="http://x/Currency_script.php?c=JPY"> ¥ JPY</a><a href="http://x/Currency_script.php?c=AUD"> $ AUD</a><a href="http://x/Currency_script.php?c=CHF"> <span class="currency_sign">Fr</span> CHF</a> Can anyone tell me if this would reload the page with new prices and store it in a session once a currency has been selected. Cheers, Jonny
  10. Ok, I think I'm getting somewhere...Is this code below correct? <?php session_start(); if(isset($_GET['c'])) { $currency = $_GET['c']; $allowable_currencies = currency_array( $currency_array [GBP] = 1.00; $currency_array [uSD] = 1.56362 ; $currency_array [EURO]= 1.18894; $currency_array [JPY] = 128.651; $currency_array [AUD] = 1.48711; $currency_array [CHF] = 1.43373; ); if(in_array($currency, $allowable_currencies)) { $_SESSION['rdt'] = $currency; } } if(!isset($_SESSION['rdt'])) { $_SESSION['rdt'] = 'GBP'; } ?> Any help would be greatly appreciated. Cheers, Jonah
  11. Ok, I can see the answer to question 1 below. <?php function getUrlWithout($getNames){ $url = "http" . ((!empty($_SERVER['HTTPS'])) ? "s" : "") . "://".$_SERVER['SERVER_NAME'].$_SERVER['REQUEST_URI']; $questionMarkExp = explode("?", $url); $urlArray = explode("&", $questionMarkExp[1]); $retUrl=$questionMarkExp[0]; $retGet=""; $found=array(); foreach($getNames as $id => $name){ foreach ($urlArray as $key=>$value){ if(isset($_GET[$name]) && $value==$name."=".$_GET[$name]) unset($urlArray[$key]); } } $urlArray = array_values($urlArray); foreach ($urlArray as $key => $value){ if($key<sizeof($urlArray) && $retGet!=="") $retGet.="&"; $retGet.=$value; } return $retUrl."?".$retGet; } ?> Can anyone help me with the other questions. Would be very grateful. Cheers, Jonah
  12. Hi CPD, thanks for reply. I don't mind the page refresh, so I'd be happy without the AJAX. Cheers, Jonah
  13. Hi CPD, thanks for pointing me in the right direction. Having looked at the my-wardrobe site and the URL's. I'm still confused to know how on changing the currency. 1) The URL at the top stays exactly the same. 2) I'm unsure of how to output the correct currency in PHP. 3) I'm unsure on how to link this to cookies. (Even more unsure through your revelation) How else could I do this. Can someone please help me in how to do this please. I've got here so far. <?php $r = new HttpRequest('http://example.com/currency_setter.php', HttpRequest::METH_POST); $r->setOptions(array('cookies' => array('lang' => 'de'))); I'm completely friggin lost. Please help. Jonah
×
×
  • 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.