SitePoint Sponsor

User Tag List

Results 1 to 3 of 3

Hybrid View

  1. #1
    SitePoint Enthusiast
    Join Date
    May 2007
    Posts
    92
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Unhappy dynamic form multiple select option as image

    hi all, i would like to do some fucntion same as the image i attached. but i duno how the keywords for searching. can someone pla guide me? plz..thanx alot
    [IMG]
    http://i263.photobucket.com/albums/i.../quenstion.jpg
    [/IMG]
    Last edited by purple83; Jan 7, 2008 at 02:18.

  2. #2
    SitePoint Wizard Pepejeria's Avatar
    Join Date
    Jan 2005
    Location
    Too far up north
    Posts
    1,566
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

  3. #3
    SitePoint Enthusiast
    Join Date
    May 2007
    Posts
    92
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Code:
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml" >
    <head>
      
    <script language="JavaScript" type="text/javascript">
    
    //var NS4 = (navigator.appName == "Netscape" && parseInt(navigator.appVersion) < 5);
    
    function addOption(theSel, theText, theValue)
    {
     var newOpt = new Option(theText, theValue);
     var selLength = theSel.length;
     theSel.options[selLength] = newOpt;
    }
    
    function deleteOption(theSel, theIndex)
    { 
     var selLength = theSel.length;
     if(selLength>0)
     {
       theSel.options[theIndex] = null;
     }
    }
    function moveOptions(theSelFrom, theSelTo)
    {
     var theSelFrom=document.getElementById(theSelFrom);
     var theSelTo=document.getElementById(theSelTo);
     var selLength = theSelFrom.length;
     var selectedText = new Array();
     var selectedValues = new Array();
     var selectedCount = 0;
     var i;
     
     // Find the selected Options in reverse order
     // and delete them from the 'from' Select.
     for(i=selLength-1; i>=0; i--)
     {
       if(theSelFrom.options[i].selected)
       {
         selectedText[selectedCount] = theSelFrom.options[i].text;
         selectedValues[selectedCount] = theSelFrom.options[i].value;
         deleteOption(theSelFrom, i);
         selectedCount++;
       }
     }
    
     // Add the selected text/values in reverse order.
     // This will add the Options to the 'to' Select
     // in the same order as they were in the 'from' Select.
    for(i=selectedCount-1; i>=0; i--)
     {
       addOption(theSelTo, selectedText[i], selectedValues[i]);
     }
     
    // if(NS4) history.go(0);
    }
    
    
    </script>
    
    
    </head>
    <&#37;
    
    if request.Form("btnsubmit")<>"" then
      sel=request.Form("sel2")
      response.Write sel
    end if
    %>
    <body>
    <form action="test3.asp" method="post" name="frm">
    <table border="0">
    <tr>
     <td>
      <select name="sel1"  id ="sel1"size="10" multiple="multiple">
      <option value="1">Left1</option>
      <option value="2">Left2</option>
      <option value="3">Left3</option>
      <option value="4">Left4</option>
      <option value="5">Left5</option>
      </select>
     </td>
     <td align="center" valign="middle">
      <input type="button" value="--&gt;" onclick="moveOptions('sel1','sel2');" /><br />
      <input type="button" value="&lt;--" onclick="moveOptions('sel2', 'sel1');" />
     </td>
     <td>
      <select name="sel2" id="sel2" size="10" multiple="multiple">
      </select>
     </td>
    </tr>
    </table>
    <input type="submit" name="btnsubmit" value="Submit" />
    <input type="text" name="hiddenvalue" />
    </form>
    </body>
    </html>
    halo there..i have use the reference tutorial u suggest for me. but i duno how to get the value form the right menu which might consist of multiple value. plz hlpe..thanx alot.


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
  •