Hi all,
I'm building a shopping website that within the products' page, there's an HTML select that allows the user to choose what product type he wants to view. beneath the select, there's a heading followed by a div or a table created at runtime showing the product name, image and a description.
My problem is in dynamically write the title. The designer provided me the prototype with a static heading in a span,once i try to automate it, the heading is created on a blank page not within the same page.
Here's my code so far:
Product type: <select name="product_type" id="product_type" onchange="select_type()">
<option value="none" selected="selected">---</option>
<option value="screen">monitors</option>
<option value="map">maps</option>
<option value="all">View all</option>
</select>
.
.
.
<div class="module">
<span>
<script language="javascript">
function select_type()
{
if(document.getElementById("product_type").value=="screen")
document.write("<h2> Monitors</h2>");
else if(document.getElementById("product_type").value=="map")
document.write("<h2>Maps</h2>");
else if(document.getElementById("product_type").value=="all")
document.write("<h2>All Products</h2>");
else
document.write("<h2>Please select a product type</h2>");
}
</script>
</span>
I think the problem is in document.write and it's the way it works, but i need something to write the heading in the same place of the code.
can anyone help??
Thank you