SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Addict Smolf3d's Avatar
    Join Date
    Aug 2004
    Location
    russia
    Posts
    232
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)

    Question Select option and print image (Ajax)

    For example

    Code HTML4Strict:
    <select id="opts" size="8">
        <option selected value="nothing">choose
        <option value="ru">Russia
        <option value="en">USA
        <option value="de">Germany
        <option value="il">Israel
        <option value="uk">UK
        <option value="lv">Latvia
        <option value="kr">Korea
    </select>

    Now after select some country, print the country flag .

    <img alt="Flag" height="27" id="flag" src="/flag/here_the_value_option.gif" width="28">
    how to do this with ajax ?

  2. #2
    SitePoint Addict Smolf3d's Avatar
    Join Date
    Aug 2004
    Location
    russia
    Posts
    232
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    Code HTML4Strict:
    <script language="JavaScript">
    <!-- 
    function change(what,imgID) { 
    value = what.options[what.selectedIndex].value; 
    if (value!= '') 
    if (document.images) 
    document.images[imgID].src = (value + ".gif");  
    } 
    //-->
    </script> 
    <form> 
    <select onChange="change(this,'flag')">
        <option selected value="nothing">choose
        <option value="ru">Russia
        <option value="en">USA
        <option value="de">Germany
        <option value="il">Israel
        <option value="uk">UK
        <option value="lv">Latvia
        <option value="kr">Korea
    </select>
    </form>
    <img src="default.gif" name="flag">

    No need more help,thanks ...
    Last edited by Smolf3d; Dec 7, 2007 at 05:05. Reason: No need more help,thanks ...


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
  •