SitePoint Sponsor

User Tag List

Results 1 to 2 of 2

Hybrid View

  1. #1
    SitePoint Zealot
    Join Date
    Dec 2010
    Posts
    107
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    how to get selected value of the list box

    Hi

    All

    I am using a list box which is having some options like english, arabic and so on.

    When user selects the language, I want to run the java script function which will get the selected value. Here is the code

    function changelanguage()
    {
    var test=document.loginform.s1.selectedIndex.value;

    if(var=='en')
    {

    <?require_once ROOT_PATH . '/language/default/lang_default_full.php'?>;
    <?require_once($lan->getLangPath("full.php"))?>;
    }
    else
    {
    <?require_once ROOT_PATH . '/language/ar/lang_ar_full.php'?>;
    <?require_once($lan->getLangPath("full.php"))?>;

    }

    please help me out to solve this problem

    Thanks & Regards
    MD.Samiuddin

  2. #2
    SitePoint Wizard bronze trophy chris.upjohn's Avatar
    Join Date
    Apr 2010
    Location
    Melbourne, AU
    Posts
    2,192
    Mentioned
    17 Post(s)
    Tagged
    1 Thread(s)
    You almost have it, when searching for a selected value within a select box there is an extra method which needs to be used as well and its called options. See how the below goes for you.

    Code JavaScript:
    var test = document.loginform.s1.options[document.loginform.s1.selectedIndex].value;


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •