Win a copy of Cross-Platform Desktop Applications: Using Node, Electron, and NW.js this week in the JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Display Text in Dropdown List  RSS feed

Fred Victa
Ranch Hand
Posts: 206
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have an application and it has a webpage that displays various drop down menus. I have drop down menus for the makes and models of a vehicle. When I select the make of a vehicle, I would like to have the drop down menu for model to say, "Select Model of Vehicle". My drop down menu displays the vehicle models, but it does not display "Select Model of Vehicle." How can I get it to display that?

Here is a snippet from one of my freemarker templates:

<td class="cellpadding2"> </td>
<td class="normalfont cellpadding2"><@spring.message code="page.fieldLabel.model" /></td>
<td class="cellpadding2">
<SELECT name="modelOfVehicle" id="modelOfVehicle">
<OPTION value=""><@spring.message code=""/></OPTION>
<#if vehicleModels??>
<#list vehicleModels as model>
<#assign selected=""/>
<#if model.description?trim == myCars.modelOfVehicle?trim >
<#assign selected = "selected"/>
<OPTION value="${model.description}" selected> ${model.description}</OPTION>
<OPTION value="${model.description}" >${model.description}</OPTION>
<INPUT class="adjust_input lotdisp_input" type=text id="model" name="model" value="${myCars.model!""}" maxlength="10">

Here is a snippet from my Javascript file:

new Ajax.Request(message.vehicleModelListURL,
method: "post",
parameters: "selectedMake="+selectedMake,
onComplete: function(transport)
var modelCodes = transport.responseText.split('|');
var modelCodesCount = 0;

$("modelOfVehicle").options.length = 0;
$("modelOfVehicle").options[0] = new Option("Select Model","");

for (var i=0; i < modelCodes.length; i++)
$("modelOfVehicle").options[i+1] = new Option(trimWS(modelCodes[i]),trimWS(modelCodes[i]));

if (modelCodes[i].trim().length > 0)



if(modelCodesCount > 0)

$("model").style.display ="";
$("modelOfVehicle").value = model;

$("modelOfVehicle").style.display ="none";
$("model").style.display ="";


onFailure : function()

With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!