new to html I want to show what was selected in menu like this http://imgur.com/RLPKWMu and i just want the result to show what I have selected text form. Then eventually want to give that combination a value as like an item number. – Yotzin Castrejon Dec 03 '15 at 06:43

4 Answers4

0

Close. Try this:

   var answer = [a,b,c].join(" ");
   document.getElementById('result').innerText = answer;
apscience
  • 7,033
  • 11
  • 55
  • 89
0

Check this if you can use jquery or this if you are using javascript only

Using the code from the link

<script>
    function myNewFunction(sel)
    {
        alert(sel.options[sel.selectedIndex].text);
    }
</script>

<select id="box1" onChange="myNewFunction(this);" >
    <option value="98">dog</option>
    <option value="7122">cat</option>
    <option value="142">bird</option>
</select>
Community
  • 1
  • 1
gurvinder372
  • 66,980
  • 10
  • 72
  • 94
0

I guesh you want to do this.

document.getElementById('link').onclick = function() {

    var a = parseInt(document.getElementById('Licorice').value);
    var b = parseInt(document.getElementById('Chocolate').value);
    var c = parseInt(document.getElementById('Toppings').value);

    var answer = "("+a + "," + b + ","+ c +")";



        document.getElementById('result').innerText = answer;

};
<div class="Licorice Flavors">
<select id="Licorice">
<option selected disabled>Licorice Flavor</option>
<option value="1">Green Apple</option>
<option value="2">Blue Raspberry</option>
<option value="3">Red Raspberry</option>
<option value="4">Watermelon</option>
<option value="5">Chocolate</option>
<option value="6">Orange</option>
<option value="7">Piña Colada</option>
</select>
</div>
<div class="Chocolate Color">
<select id="Chocolate">
<option selected disabled>Chocolate Color</option>
<option value="8">White Chocolate</option>
<option value="9">Dark Chocolate</option>
</select>
</div>

<div class="Toppings">
<select id="Toppings">
<option selected disabled>Toppings</option>
<option value="10">Christmas Sprinkles</option>
<option value="11">Rainbow Sprinkles</option>
<option value="12">Valentine's Day</option>
</select>
</div>

<a href="#" id="link">Add to Cart</a>
<div id="result"></div>
Shubham
  • 1,755
  • 3
  • 17
  • 33
0

Try this:

document.getElementById('link').onclick = function() {

    var a = document.getElementById('Licorice').value;
    var b = document.getElementById('Chocolate').value;
    var c = document.getElementById('Toppings').value;

    var answer = [a,b,c].join(", ");



        document.getElementById('result').innerText = answer;

};

Fiddle

void
  • 36,090
  • 8
  • 62
  • 107
  • sorry i cant upvote i dont have enough reputation, however gladsocc also gave a very similar answer a little earlier. But I do appreciate your help very much. Thank you – Yotzin Castrejon Dec 03 '15 at 06:56