#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Feb 2013
    Posts
    1
    Rep Power
    0

    Partially Working Drop-Down Boxes


    Hello all,

    I am having trouble with some drop-down boxes in some code that I am modifying from an open-source software (intersango).

    All of my desired entries display but I am unable to actually select most of them.

    Here is the code from their "index.php" that I am working with:

    Code:
    <div class='content_box'>
                <h3>Currency converter</h3>
            <form id='buy_form' action='?page=place_order' method='post'>
                <table id='exchanger'>
                <tr><td>
    
                <p><b>Currency I have:</b></p>
                <div class='currbox_wrapper'>
                    <div id='incurrency' class='currbox' onclick='javascript:rolldown_in();'>
                        <div class='currbox_right'>
                            <b class='currcode'>BBQ</b>
                            <img src='images/arrow_down.png' />
                        </div>
    					<img class='currflag' src='images/bbq_flag.png' />
                        <span class='currname'>BBQCoin</span>
                    </div>
                    
                    <div id='currsel_in'>
                        <div class='currsel_entry' onclick='javascript:select_currency_in(this, true);'>
                            <div class='currbox_right'>
                                <b class='currcode'>BBQ</b>
                            </div>
                            <img class='currflag' src='images/bbq_flag.png' />
                            <span class='currname'>BBQCoin</span>
                        </div>
    
                        <div class='currsel_entry' onclick='javascript:select_currency_in(this, true);'>
                            <div class='currbox_right'>
                                <b class='currcode'>BTC</b>
                            </div>
                            <img class='currflag' src='images/btc_flag.png' />
                            <span class='currname'>Bitcoin</span>
                        </div>
    
                        <div class='currsel_entry' onclick='javascript:select_currency_in(this, true);'>
                            <div class='currbox_right'>
                                <b class='currcode'>CLC</b>
                            </div>
                            <img class='currflag' src='images/clc_flag.png' />
                            <span class='currname'>Coiledcoin</span>
                        </div>
    
                        <div class='currsel_entry' onclick='javascript:select_currency_in(this, true);'>
                            <div class='currbox_right'>
                                <b class='currcode'>DVC</b>
                            </div>
                            <img class='currflag' src='images/dvc_flag.png' />
                            <span class='currname'>Devcoin</span>
                        </div>
    
                        <div class='currsel_entry' onclick='javascript:select_currency_in(this, true);'>
                            <div class='currbox_right'>
                                <b class='currcode'>FBX</b>
                            </div>
                            <img class='currflag' src='images/fbx_flag.png' />
                            <span class='currname'>Fairbrix</span>
                        </div>
    
                        <div class='currsel_entry' onclick='javascript:select_currency_in(this, true);'>
                            <div class='currbox_right'>
                                <b class='currcode'>GGD</b>
                            </div>
                            <img class='currflag' src='images/ggd_flag.png' />
                            <span class='currname'>GeistGeld</span>
                        </div>
    
                        <div class='currsel_entry' onclick='javascript:select_currency_in(this, true);'>
                            <div class='currbox_right'>
                                <b class='currcode'>GPC</b>
                            </div>
                            <img class='currflag' src='images/gpc_flag.png' />
                            <span class='currname'>Groupcoin</span>
                        </div>
    
                        <div class='currsel_entry' onclick='javascript:select_currency_in(this, true);'>
                            <div class='currbox_right'>
                                <b class='currcode'>IXC</b>
                            </div>
                            <img class='currflag' src='images/ixc_flag.png' />
                            <span class='currname'>IXCoin</span>
                        </div>
    
                        <div class='currsel_entry' onclick='javascript:select_currency_in(this, true);'>
                            <div class='currbox_right'>
                                <b class='currcode'>LQC</b>
                            </div>
                            <img class='currflag' src='images/lqc_flag.png' />
                            <span class='currname'>Liquidcoin</span>
                        </div>
    
                        <div class='currsel_entry' onclick='javascript:select_currency_in(this, true);'>
                            <div class='currbox_right'>
                                <b class='currcode'>LTC</b>
                            </div>
                            <img class='currflag' src='images/ltc_flag.png' />
                            <span class='currname'>Litecoin</span>
                        </div>
    
                        <div class='currsel_entry' onclick='javascript:select_currency_in(this, true);'>
                            <div class='currbox_right'>
                                <b class='currcode'>NMC</b>
                            </div>
                            <img class='currflag' src='images/nmc_flag.png' />
                            <span class='currname'>Namecoin</span>
                        </div>
    
                        <div class='currsel_entry' onclick='javascript:select_currency_in(this, true);'>
                            <div class='currbox_right'>
                                <b class='currcode'>PPC</b>
                            </div>
                            <img class='currflag' src='images/ppc_flag.png' />
                            <span class='currname'>PPCoin</span>
                        </div>
    
                        <div class='currsel_entry' onclick='javascript:select_currency_in(this, true);'>
                            <div class='currbox_right'>
                                <b class='currcode'>RUC</b>
                            </div>
                            <img class='currflag' src='images/ruc_flag.png' />
                            <span class='currname'>RuCoin</span>
                        </div>
    
                        <div class='currsel_entry' onclick='javascript:select_currency_in(this, true);'>
                            <div class='currbox_right'>
                                <b class='currcode'>SLC</b>
                            </div>
                            <img class='currflag' src='images/slc_flag.png' />
                            <span class='currname'>Solidcoin</span>
                        </div>
    
                        <div class='currsel_entry' onclick='javascript:select_currency_in(this, true);'>
                            <div class='currbox_right'>
                                <b class='currcode'>TRC</b>
                            </div>
                            <img class='currflag' src='images/trc_flag.png' />
                            <span class='currname'>Terracoin</span>
                        </div>
                     </div>
                </div>
    
    
            </td>
            <td>
    
                <p><b>Currency I want:</b></p>
                <div class='currbox_wrapper'>
                    <div id='outcurrency' class='currbox' onclick='javascript:rolldown_out();'>
                        <div class='currbox_right'>
                            <b class='currcode'>BTC</b>
                            <img src='images/arrow_down.png' />
                        </div>
                        <img class='currflag' src='images/btc_flag.png' />
                        <span class='currname'>Bitcoin</span>
                    </div>
                    
                    <div id='currsel_out'>
                        <div class='currsel_entry' onclick='javascript:select_currency_out(this, true);'>
                            <div class='currbox_right'>
                                <b class='currcode'>BBQ</b>
                            </div>
                            <img class='currflag' src='images/bbq_flag.png' />
                            <span class='currname'>BBQCoin</span>
                        </div>
                        
                        <div class='currsel_entry' onclick='javascript:select_currency_out(this, true);'>
                            <div class='currbox_right'>
                                <b class='currcode'>BTC</b>
                            </div>
                            <img class='currflag' src='images/btc_flag.png' />
                            <span class='currname'>Bitcoin</span>
                        </div>
                        
                        <div class='currsel_entry' onclick='javascript:select_currency_out(this, true);'>
                            <div class='currbox_right'>
                                <b class='currcode'>CLC</b>
                            </div>
                            <img class='currflag' src='images/clc_flag.png' />
                            <span class='currname'>Coiledcoin</span>
                        </div>
    
                        <div class='currsel_entry' onclick='javascript:select_currency_out(this, true);'>
                            <div class='currbox_right'>
                                <b class='currcode'>DVC</b>
                            </div>
                            <img class='currflag' src='images/dvc_flag.png' />
                            <span class='currname'>Devcoin</span>
                        </div>
    
                        <div class='currsel_entry' onclick='javascript:select_currency_out(this, true);'>
                            <div class='currbox_right'>
                                <b class='currcode'>FBX</b>
                            </div>
                            <img class='currflag' src='images/fbx_flag.png' />
                            <span class='currname'>Fairbrix</span>
                        </div>
    
                        <div class='currsel_entry' onclick='javascript:select_currency_out(this, true);'>
                            <div class='currbox_right'>
                                <b class='currcode'>GGD</b>
                            </div>
                            <img class='currflag' src='images/ggd_flag.png' />
                            <span class='currname'>GeistGeld</span>
                        </div>
    
                        <div class='currsel_entry' onclick='javascript:select_currency_out(this, true);'>
                            <div class='currbox_right'>
                                <b class='currcode'>GPC</b>
                            </div>
                            <img class='currflag' src='images/gpc_flag.png' />
                            <span class='currname'>Groupcoin</span>
                        </div>
    
                        <div class='currsel_entry' onclick='javascript:select_currency_out(this, true);'>
                            <div class='currbox_right'>
                                <b class='currcode'>IXC</b>
                            </div>
                            <img class='currflag' src='images/ixc_flag.png' />
                            <span class='currname'>IXCoin</span>
                        </div>
    
                        <div class='currsel_entry' onclick='javascript:select_currency_out(this, true);'>
                            <div class='currbox_right'>
                                <b class='currcode'>LQC</b>
                            </div>
                            <img class='currflag' src='images/lqc_flag.png' />
                            <span class='currname'>Liquidcoin</span>
                        </div>
    
                        <div class='currsel_entry' onclick='javascript:select_currency_out(this, true);'>
                            <div class='currbox_right'>
                                <b class='currcode'>LTC</b>
                            </div>
                            <img class='currflag' src='images/ltc_flag.png' />
                            <span class='currname'>Litecoin</span>
                        </div>
    
                        <div class='currsel_entry' onclick='javascript:select_currency_out(this, true);'>
                            <div class='currbox_right'>
                                <b class='currcode'>NMC</b>
                            </div>
                            <img class='currflag' src='images/nmc_flag.png' />
                            <span class='currname'>Namecoin</span>
                        </div>
    
                        <div class='currsel_entry' onclick='javascript:select_currency_out(this, true);'>
                            <div class='currbox_right'>
                                <b class='currcode'>PPC</b>
                            </div>
                            <img class='currflag' src='images/ppc_flag.png' />
                            <span class='currname'>PPCoin</span>
                        </div>
    
                        <div class='currsel_entry' onclick='javascript:select_currency_out(this, true);'>
                            <div class='currbox_right'>
                                <b class='currcode'>RUC</b>
                            </div>
                            <img class='currflag' src='images/ruc_flag.png' />
                            <span class='currname'>RuCoin</span>
                        </div>
    
                        <div class='currsel_entry' onclick='javascript:select_currency_out(this, true);'>
                            <div class='currbox_right'>
                                <b class='currcode'>SLC</b>
                            </div>
                            <img class='currflag' src='images/slc_flag.png' />
                            <span class='currname'>Solidcoin</span>
                        </div>
    
                        <div class='currsel_entry' onclick='javascript:select_currency_out(this, true);'>
                            <div class='currbox_right'>
                                <b class='currcode'>TRC</b>
                            </div>
                            <img class='currflag' src='images/trc_flag.png' />
                            <span class='currname'>Terracoin</span>
                        </div>
                    </div>
                </div>
            </td>
            </tr>
    
                <tr>
                <td>
                <input id='inamount' name='amount' class='curramount' type="text" size="20" value="" onkeyup='typed_amount_in();'>
                </td>
    
                <td>
                <input id='outamount' name='want_amount' class='curramount' type="text" size="20" value="" onkeyup='typed_amount_out();'>
                </td>
                </tr>
        <?php
        if ($loggedin) { ?>
            <tr><td></td><td>
                        <input type='hidden' name='csrf_token' value="<?php echo $_SESSION['csrf_token']; ?>" />
                        <input type='hidden' name='type' value='' />
                        <input type='hidden' name='want_type' value='' />
                        <input type='submit' onclick='return buy_clicked();' value='Buy' />
            </td></tr>
        <?php } ?>
            </table>
            </form>
    
        <?php
        if ($loggedin) { ?>
                <center><p>
                Use the above to give you an indication of the current exchange rates.
                </p>
            <?php show_balances($indent=true); ?>
                <p>
                Select the currency you wish to buy on the right, then click Buy.
                </p>
    	    <p>There is a 0.1% trading fee.</p></center>
        <?php }
        else { ?>
                <p>
                To begin trading you will need an OpenID account.
                </p>
                <p>If you do not have an OpenID login then we recommend <a href="https://www.myopenid.com/">MyOpenID</a>.
        <?php } ?>
            </div>
    
            <div class='content_box'>
                <h3>Crypto-Currencies</h3>
                <p>
                Crypto-currencies are a new form of currency which varies from traditional currencies in the fact that they are decentralized, safer to use and transactions can be conducted anonymously.<br /><br />To learn more, visit some of our sister sites:</p>
    	    <a href="http://bitcointalk.org", target="blank">Bitcoin Talk</a><br /><a href="http://forum.rucoin.us" target="blank">RuCoin Forum</a><br /><a href="http://forum.litecoin.net" target="blank">Litecoin Forum</a><br /><a href="http://ppcointalk.org" target="blank">PPCoin Talk</a>
                </p>
            </div>
    
    <div class='content_box'>
    <h3>Contact info</h3>
    <p>support@crypto-exchange.us</p>
            </div>
    and here is the code from exchanger.js which contains the instructions for the onclick= functions being called by index.php

    Code:
    function set_curr_block(elem, currency, textname)
    {
        elem.children('.currflag').attr('src', 'images/'.concat(currency).concat('_flag.png'));
        elem.children('.currname').text(textname);
        elem.children('.currbox_right').children('.currcode').text(currency);
    }
    function set_currency(elem, currency)
    {
        switch(currency)
        {
            case 'bbq':
                set_curr_block(elem, 'bbq', 'BBQCoin');
            break;
    
            case 'btc':
                set_curr_block(elem, 'btc', 'Bitcoin');
            break;
    	
    	case 'clc':
    	    set_curr_block(elem, 'clc', 'Coiledcoin');
    	break;
    	
    	case 'dvc':
    	    set_curr_block(elem, 'dvc', 'Devcoin');
    	break;
    	
    	case 'fbx':
    	    set_curr_block(elem, 'fbx', 'Fairbrix');
    	break;
    	
    	case 'ggd':
    	    set_curr_block(elem, 'ggd', 'GeistGeld');
    	break;
    	
    	case 'gpc':
    	    set_curr_block(elem, 'gpc', 'Groupcoin');
    	break;
    	
    	case 'ixc':
    	    set_curr_block(elem, 'ixc', 'IXCoin');
    	break;
    	
    	case 'lqc':
    	    set_curr_block(elem, 'lqc', 'Liquidcoin');
    	break;
    	
    	case 'ltc':
    	    set_curr_block(elem, 'ltc', 'Litecoin');
    	break;
    	
    	case 'nmc':
    	    set_curr_block(elem, 'nmc', 'Namecoin');
    	break;
    
    	case 'ppc':
    	    set_curr_block(elem, 'ppc', 'PPCoin');
    	break;
    	
    	case 'ruc':
    	    set_curr_block(elem, 'ruc', 'RuCoin');
    	break;
    	
    	case 'slc':
    	    set_curr_block(elem, 'slc', 'Solidcoin');
    	break;
    	
    	case 'trc':
    	    set_curr_block(elem, 'trc', 'Terracoin');
    	break;
    		}
    }
    
    function set_currency_in(currency)
    {
        ic = $('#incurrency');
        set_currency(ic, currency);
    }
    function set_currency_out(currency)
    {
        ic = $('#outcurrency');
        set_currency(ic, currency);
    }
    
    function rolldown(cs, ic)
    {
        if (cs.css('visibility') == 'hidden') {
            cs.position({
                my: "left top",
                at: "left bottom",
                of: ic
            });
            cs.css('visibility', 'visible');
        }
        else
            cs.css('visibility', 'hidden');
    }
    function hide_rolldown(cs)
    {
        cs.css('visibility', 'hidden');
    }
    function rolldown_in()
    {
        rolldown($('#currsel_in'), '#incurrency');
        hide_rolldown($('#currsel_out'));
    }
    function rolldown_out()
    {
        rolldown($('#currsel_out'), '#outcurrency');
        hide_rolldown($('#currsel_in'));
    }
    
    function select_currency_in(caller)
    {
        $('#currsel_in').css('visibility', 'hidden');
        curr = jQuery('.currcode', caller).text();
        curr = curr.toLowerCase();
        set_currency_in(curr);
        set_currency_out(twin_currency(curr), false);
        $('#inamount').attr('value', '');
        typed_amount_in();
    }
    function select_currency_out(caller)
    {
        $('#currsel_out').css('visibility', 'hidden');
        curr = jQuery('.currcode', caller).text();
        curr = curr.toLowerCase();
        set_currency_out(curr);
        set_currency_in(twin_currency(curr));
        $('#outamount').attr('value', '');
        typed_amount_out();
    }
    
    function typed_amount(this_name, change_name)
    {
        this_obj = $('#' + this_name + 'amount');
        change_obj = $('#' + change_name + 'amount');
        a_obj = $('#inamount');
        b_obj = $('#outamount');
        a_curr = jQuery('.currcode', '#incurrency').text();
        b_curr = jQuery('.currcode', '#outcurrency').text();
        if (a_curr in exchange_rates) {
            a_curr_rates = exchange_rates[a_curr];
            if (b_curr in a_curr_rates) {
                text_field = this_obj.attr('value');
                if (text_field == '') {
                    change_obj.attr('value', 0);
                    return;
                }
                else if (isNaN(text_field)) {
                    change_obj.attr('value', '-');
                    return;
                }
                rate = a_curr_rates[b_curr];
                val = parseFloat(text_field);
                val *= rate;
                change_obj.attr('value', val.toFixed(2));
            }
            else {
                b_obj.attr('value', 'N/A');
            }
        }
        else {
            b_obj.attr('value', 'N/A');
        }
    }
    function typed_amount_in()
    {
        typed_amount('in', 'out');
    }
    function typed_amount_out()
    {
        //typed_amount('out', 'in');
    }
    
    function buy_clicked()
    {
        curr_type = jQuery('.currcode', '#incurrency').text();
        want_curr_type = jQuery('.currcode', '#outcurrency').text();
        amount = $('#inamount').attr('value');
        want_amount = $('#outamount').attr('value');
        $("input[name='type']").val(curr_type);
        $("input[name='amount']").val(amount);
        if (amount == '' || want_amount == '' || isNaN(amount) || isNaN(want_amount)) {
            alert("Invalid amount specified.");
            return false;
        }
        $("input[name='want_type']").val(want_curr_type);
        $("input[name='want_amount']").val(want_amount);
        return true;
    }
    On both drop-down boxes I am able to select the entries for Bitcoin, Litecoin, PPCoin and RuCoin but none of the others even though it appears to me that they are all using the same code...

    If you need more info, please feel free to ask, thanks in advance!
  2. #2
  3. Contributing User
    Devshed Expert (3500 - 3999 posts)

    Join Date
    Aug 2010
    Location
    Eastern Florida
    Posts
    3,713
    Rep Power
    348
    Read this: http://forums.devshed.com/java-help-9/new-users--this-is-not-the-javascript-forum-141984.html

IMN logo majestic logo threadwatch logo seochat tools logo