-1

I need java-script function when user select color in form on submit console should display Hexa code for color that is selected from user.

HTML

<div class="form-group">
 <select id="selectColor"> 
  <option selected="selected"></option>
  <option value="abc">Red</option>
  <option value="def">Green</option>
  <option value="hij">Yellow</option> 
  <option value="hij">Purple</option>
  <option value="hij">orange</option>
  <option value="hij">Blue</option>
  <option value="hij">Brown</option>                                                        
 </select>

aftab
  • 45
  • 1
  • 6
  • 1
    The urgency for your need in code comes with the proof you've tried it yourself, else it doesn't seem urgent. In the meantime, [search](http://stackoverflow.com/questions/1573053/javascript-function-to-convert-color-names-to-hex-codes) for it. – Tim Vermaelen Apr 22 '14 at 14:09
  • 1
    Post some JavaScript that you've tried for us to look at. – Aravona Apr 22 '14 at 14:09
  • 2
    Why dont you set the value to the hex code? – Hauke Apr 22 '14 at 14:11
  • orange write hexa for each colour in your code in value this what the form will pass the hex value... tell me if i missed something. – Shanker Paudel Apr 22 '14 at 14:11
  • i can set value for color but how i will do javascript part...very new in JS – aftab Apr 22 '14 at 14:14
  • Also include jquery in your page. – Shanker Paudel Apr 22 '14 at 14:24

1 Answers1

0
<script>
$( "#selectColor" ).change(function() {
console.log($(this).val());
});
</script>

Also include jquery in your page.

Shanker Paudel
  • 740
  • 1
  • 9
  • 21