Log in

View Full Version : convert currency selection box to a drop down manu



jackson
12-22-2008, 12:16 AM
Please forgive me if I am asking stupid questions here. I am taking a baby step in learning programming. My question here is: I want to convert a currency selection box to a drop down box. (links provided) It involves JS and PHP. They are way over my head. Can somebody take a look and direct me what I should do?


selection box: http://www.prestashop.com/demo/
drop down box: http://osc3.template-help.com/osc_22304/index.php

My tpl file is as follow:

<!-- Block currencies module -->
<script type="text/javascript" src="{$module_dir}blockcurrencies.js"></script>
<div id="currencies_block_top">
<form id="setCurrency" action="{$request_uri}" method="post">
<ul>
{foreach from=$currencies key=k item=f_currency}
<li {if $id_currency_cookie == $f_currency.id_currency}class="selected"{/if}>
<a href="javascript:setCurrency({$f_currency.id_currency});" title="{$f_currency.name}">{$f_currency.sign}</a>
</li>
{/foreach}
</ul>
<p>
<input type="hidden" name="id_currency" id="id_currency" value=""/>
<input type="hidden" name="SubmitCurrency" value="" />
{l s='Currency' mod='blockcurrencies'}
</p>
</form>
</div>
<!-- /Block currencies module -->

My php file is as follow:

<?php

class BlockCurrencies extends Module
{
function __construct()
{
$this->name = 'blockcurrencies';
$this->tab = 'Blocks';
$this->version = 0.1;

parent::__construct(); // The parent construct is required for translations

$this->page = basename(__FILE__, '.php');
$this->displayName = $this->l('Currency block');
$this->description = $this->l('Adds a block for selecting a currency');
}

function install()
{
if (!parent::install())
return false;
if (!$this->registerHook('top'))
return false;
return true;
}

/**
* Returns module content for header
*
* @param array $params Parameters
* @return string Content
*/
function hookTop($params)
{
global $smarty;
$currencies = Currency::getCurrencies();
if (!sizeof($currencies))
return '';
$smarty->assign('currencies', $currencies);
return $this->display(__FILE__, 'blockcurrencies.tpl');
}

}

?>

My JS file is as follow:

function setCurrency(id)
{
$('form#setCurrency input#id_currency').val(id);
$('form#setCurrency').submit();
}


Thanks in advance for all of your help.
Jackson_h is offline Reply With Quote

Nile
12-22-2008, 12:24 AM
I still don't see what you really want, can you please be a little bit more descriptive?

jackson
12-22-2008, 01:27 AM
I still don't see what you really want, can you please be a little bit more descriptive?


Sorry, I don't know how I can post a picture here.
The script that I posted above is for a currency selection box. Please see: http://www.prestashop.com/demo/. On the top of the page that has the currency selection boxes. I would like to change the codes to a drop down menu. Please see this link: http://osc3.template-help.com/osc_22304/index.php. I saw somebody did it, so I know it can be done. Thank you very much for your help.

Nile
12-22-2008, 01:46 AM
Yes, very very possible, but is http://www.prestashop.com/demo/ your website? B/c I don't know how your changing the currency on your site(unless that is your site).

jackson
12-22-2008, 01:59 AM
Yes, very very possible, but is http://www.prestashop.com/demo/ your website? B/c I don't know how your changing the currency on your site(unless that is your site).

My site is still work in progress. It is www.blossomcart.com. Thank you very much for your help.

Nile
12-22-2008, 02:25 AM
Did you copy that other site or something? Anyways here's the menu:


<select>
<optgroup label="Select a currency">
<option onClick="javascript:setCurrency(2);">USD, $</option>
<option onClick="javascript:setCurrency(1);">Euro, €</option>
<option onClick="javascript:setCurrency(3);">Pound, £</option>
</optgroup>
</select>

jackson
12-22-2008, 03:08 AM
Did you copy that other site or something? Anyways here's the menu:


<select>
<optgroup label="Select a currency">
<option onClick="javascript:setCurrency(2);">USD, $</option>
<option onClick="javascript:setCurrency(1);">Euro, €</option>
<option onClick="javascript:setCurrency(3);">Pound, £</option>
</optgroup>
</select>


Where do I put the script? Do I need to delete any codes? Or replace any codes? Or do I replace these codes with the JS file?

Thanks a lot of ryour help.

Nile
12-22-2008, 03:34 AM
Replace your current currency code with that. Also did you copy that other site?

jackson
12-22-2008, 03:51 AM
Replace your current currency code with that. Also did you copy that other site?

Sorry, my English is not that good. What do you mean by copy that other site? Which site?

Nile
12-28-2008, 04:12 AM
I mean, your code is the exact same code as: http://www.prestashop.com/demo/
Also did my code work?