2

I have following select list from which user can select multiple option

<select size="6" onblur="validatevalumethod()" multiple="" id="valumethod[]" name="valumethod[]"> 
        <option value="0">Select Asset</option>

        <option value="OC">ORIGINAL COST</option>
        <option value="OCUIP">ORIGINAL COST USING INDEXED PRICES</option>
        <option value="RC">REPLACEMENT COST</option>
        <option value="OCCR">ORIGINAL COST CONSIDERING REVALUATION</option>
        <option value="OCUIPCR">ORIGINAL COST USING INDEXED PRICES & CONSIDERING REVALUATION</option>
        <option value="RCCR">REPLACEMENT COST CONSIDERING REVALUATION</option>
        </select>

I need to fetch the value selected by user in javascript but dont know how to do this please help me.

1
  • Do you know what are the arrows, numbers, checkmarks beside each answer/question for? ... and why you have Accept_rate = 0; ? Can you show us your first try to solve your issue? Commented Mar 15, 2012 at 8:17

4 Answers 4

1

With jQuery you could do $("#list option:selected").text(); to get the text of the selected option $("#list option:selected").val(); to get the value behind the selected option

EDIT:

where #list is the id of your select tag

Sign up to request clarification or add additional context in comments.

Comments

1

I think that the following solution is better to fetch VALUES :

$("#list option:selected").val();

Comments

1

Here's a very simple code that tells you how many you selected on every change:

For the Html Code:

<html>
<body>

<select multiple="true">
  <option>Volvo</option>
  <option>Saab</option>
  <option>Mercedes</option>
  <option>Audi</option>
</select>

</body>
</html>

​Use this jQuery Code:

$("select").change(function() {
    alert($("option:selected").length);
});

Here's a live example: http://jsfiddle.net/hesher/3M36e/

Comments

1

You can use pure javascript as in : document.getElementById('valumethod[]').value

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.