Hi, not the best with Javascript so thought i'd ask where i'm going wrong.
as the title suggests, I have a select box with 4 different options, when an option is selected I want to change the contents of a <p>
tag with id of pricedesc. Here is what I have so far.
function priceText(sel)
{
var listingType = document.getElementById('listingtype');
var priceDesc = document.getElementById('pricedesc');
if ( sel.options[sel.selectedIndex].value == "Residential Letting" ) {
priceDesc = "Enter price per month";
}
else if ( sel.options[sel.selectedIndex].value == "Short Let" ) {
priceDesc = "Enter price per week";
}
else if ( sel.options[sel.selectedIndex].value == "Serviced Accommodation" ) {
priceDesc = "Enter price per week";
}
else if ( sel.options[sel.selectedIndex].value == "Sale" ) {
priceDesc = "Enter for sale price";
}
}
and in the body i have:
<label>Listing Type:</label>
<select name="listingtype" id="listingtype" onchange="priceText(this);">
<option value="Residential Letting">Residential Letting</option>
<option value="Short Let">Short Let</option>
<option value="Serviced Accommodation">Serviced Accommodation</option>
<option value="Sale">Sale</option>
</select>
<label>Price:</label>
<p id="pricedesc">Enter price</p>
<input name="price" type="text" id="price" value="<%=Request.Form("price")%>" maxlength="10" />
Thanks for your help.
J.