reset password
Author Message
TC465
Posts: 4
Posted 22:11 May 29, 2015 |

I am trying to display the "pizza type" value on the summary but got "The order is placed for a Medium sized undefined pizza". I wanted "Deep dish pizza" but got "undefined pizza" instead.

Here is my pizza type block:

<h1>Choose pizza type:</h1>
                <select>
                    <option name="style" value="Regular">Regular</option>
                    <option name="style" value="Deep dish">Deep Dish</option>
                </select>

<script>

function order() {

var Size = document.form.size.value;

var Style = document.form.style.value;

document.write("The order is placed for a " + Size + " sized " + Style + " pizza");

}

</script>

I tried using different methods of displaying value but doesn't work. May someone help me please?

 

cesar714
Posts: 30
Posted 23:21 May 29, 2015 |

I do not know how to approach your issue the way you are approaching it. A way that you can solve this situation is by creating an id for your select tag. Than you can use the "document.getElementById("").value" Than you can assign your variable style to it.

That should do it. Goodluck.

chondee
Posts: 9
Posted 01:41 May 30, 2015 |

Style is a built in member object, referring to the css properties (like margin, padding, color) of the object.

Assign a different name for the input element instead of style, type or something, so that you would access it like "document.form.type.value"