Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    New to the CF scene
    Join Date
    Apr 2008
    Posts
    7
    Thanks
    1
    Thanked 0 Times in 0 Posts

    textbox to multi-select

    hi ¡¡
    I have a textbox and I want spend their content in text to the list selected of a select multiple.
    I found code to do the opposite mode but I don't serve for me.
    Someone can help me?

    Thanx

  • #2
    Senior Coder chump2877's Avatar
    Join Date
    Dec 2004
    Location
    the U.S. of freakin' A.
    Posts
    2,769
    Thanks
    19
    Thanked 155 Times in 146 Posts
    something like this perhaps:

    Code:
    <?xml version="1.1" encoding="iso-8859-1"?>
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
    
    <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
    <head>
    <title>TITLE</title>
    </head>
    <body>
    
    <p>
        <select id="menu" multiple="multiple" size="4">
            <option value="Item #1">Item #1</option>
            <option value="Item #2">Item #2</option>
            <option value="Item #3">Item #3</option>
            <option value="Item #4">Item #4</option>
        </select>
    </p>
    <p><input type="text" id="newtext" /> <input type="button" value="Send to Menu" onclick="sendToMenu('newtext','menu');" /></p>
    
    <script type="text/javascript">
        function sendToMenu(textBoxID,menuID)
        {
            var txtBox = document.getElementById(textBoxID);
            var menu = document.getElementById(menuID);
            var regex = /^[\s]+$/;
    
            if (!regex.test(txtBox.value) && txtBox.value != "")
            {
                var newOption = document.createElement("option");
                newOption.value = newOption.innerHTML = txtBox.value;
                menu.appendChild(newOption);
                menu.size += 1;
            }
    
            txtBox.value = "";
            txtBox.focus();
        }
    </script>
    
    </body>
    </html>
    Last edited by chump2877; 04-23-2008 at 01:58 PM.
    Regards, R.J.

    ---------------------------------------------------------

    Help spread the word! Like my YouTube-to-Mp3 Conversion Script on Facebook !! :)
    [Related videos and tutorials are also available at my YouTube channel and on Dailymotion]
    Get free updates about new software version releases, features, and bug fixes!

  • Users who have thanked chump2877 for this post:

    FlashO (04-23-2008)

  • #3
    New to the CF scene
    Join Date
    Apr 2008
    Posts
    7
    Thanks
    1
    Thanked 0 Times in 0 Posts
    Is perfect
    Thankss


  •  

    Posting Permissions

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