www.webdeveloper.com
Results 1 to 6 of 6

Thread: Hi I got a question about managing a unknown limit in a dropdown menu

  1. #1
    Join Date
    Jan 2010
    Posts
    6

    Hi I got a question about managing a unknown limit in a dropdown menu

    <Input name='Input'>
    Choice:
    <select name='Input'>
    <option value= 1 >1</option>
    <option value=2>2</option>
    <option value=3>3</option>
    <option value=4>4</option>
    </select>
    <input type=button name='Max' value='Max' onclick='Max' show(choice);">
    </Input>

    Hi I'm pretty fresh with making user scripts so any help would be apprechiated.

    The Option value may varry from 1 to 50. I can select the Max button but I want to make a choice. Any Ideas anyone

    I figure that I need a Array here and make the selection by mouseclick.
    But how do I make this happen when the options keep changing in numbers.

    There can be 5 or more dropdowns on the same page
    I figured out how to find the input options but not how to use them

  2. #2
    Join Date
    Dec 2005
    Location
    FL
    Posts
    7,373
    What exactly are you trying to do here?

    What is the purpose and the desired results?

    There is not enough code for me to guess what you are trying to do.

  3. #3
    Join Date
    Jan 2010
    Posts
    6
    I only want to detect the number of options to select and make a click on the selected value of my choice.

    What more do you need in this case?


    <td class='actions'>
    <div id='select_link_123'>
    <span class='ajax_link'>
    <span class='active'>
    <span class='enabled'>
    <a href="#" onclick="disable_ajax_links();; new Ajax.Request
    ('/run/123?current=321&amp;quantities=default',
    {asynchronous:true, evalScripts:true,
    parameters:Form.Element.serialize($('batch_size_123'))});
    return false;"> <span class='button'>Start</span>
    </a>
    </span>
    <span class='disabled' style='display: none;'>
    <span class='button'>Run</span>
    </span>
    </span>
    <span class='waiting' style='display: none;'>
    <span class='button'>Run</span>
    </span>
    </span>
    </div>
    <div id="batch_selector_123" class='batch_selector'>
    <div class='batch'>Times:
    <select class="batch_dropdown" id="batch_size_123"
    name="batch_size_123"><option value="1">1</option>
    <option value="2">2</option>
    <option value="3">3</option>
    <option value="4">4</option>
    <option value="5">5</option></select>
    <input class="max" onclick="select_max_batches('batch_size_123');" type="button" value="Max" />
    <div class='clear'></div>
    </div>
    </div>
    </td>

  4. #4
    Join Date
    Dec 2005
    Location
    FL
    Posts
    7,373

    Lightbulb

    Quote Originally Posted by synergi View Post
    I only want to detect the number of options to select and make a click on the selected value of my choice.

    What more do you need in this case?
    Still don't understand the purpose, but this should get you started.
    Code:
    <html>
    <head>
    <title>Undefined</title>
    <script type="text/javascript">
    // For: http://www.webdeveloper.com/forum/showthread.php?p=1064394#post1064394
    
    function showInput() {
      var sel = document.getElementById('Input');
      var str = 'Your choice: '+sel.value;
          str +='\nof maximum: '+sel.options.length;
      alert(str);
    }
      
    </script>
    </head>
    <body>
    Choice:
    <select name='Input' id="Input">
    <option value=1>1</option>
    <option value=2>2</option>
    <option value=3>3</option>
    <option value=4>4</option>
    </select>
    <input type='button' name='Max' value="Max" onclick='showInput()'>
    </body>
    </html>
    BTW: Wrap you code between [ code] and [ /code] tags (without the spaces)
    to make it easier to read your request.

  5. #5
    Join Date
    Jan 2010
    Posts
    6
    Right that reads the values
    But what I want to is make an manipulative function based on what I get from it
    I already have a script for adding the value I need inside the dropdown but it only manages to handle one action at the time.

    So the real questions should be.
    How do I set the value to become the wanted value (if it exists though)
    that would make several operations run simultanious not one by one

    I do not need the dropdown if I could force the:
    var 'batch_size_123' to change

    [part of Code]
    <a href="#" onclick="disable_ajax_links();; new Ajax.Request
    ('/run/123?current=321&amp;quantities=default',
    {asynchronous:true, evalScripts:true,
    parameters:Form.Element.serialize($('batch_size_123'))});
    equal
    <div class='batch'>Times:
    <select class="batch_dropdown" id="batch_size_123"
    [/part of code]

  6. #6
    Join Date
    Dec 2005
    Location
    FL
    Posts
    7,373

    Question More questions ... and one suggestion.

    Quote Originally Posted by synergi View Post
    ...
    I do not need the dropdown if I could force the:
    var 'batch_size_123' to change
    ...
    Why not make the select list a hidden value instead.
    Then you could change it at any time and use it anywhere you want.

    Code:
    <input type="hidden" name="batch_size" id="batch_size" value="0">
    ...
    // later in JS code
    ...
    document.getElementById('batch_size').value = document.getElementById('batch_size_123').value;
    // or whatever you want it set to for whatever calculations you wish to perform.
    // (which you have yet to specify)

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

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



Recent Articles