aspose file tools*
The moose likes Other Application Frameworks and the fly likes Display Text in Dropdown List Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Other Application Frameworks
Bookmark "Display Text in Dropdown List" Watch "Display Text in Dropdown List" New topic
Author

Display Text in Dropdown List

Fred Victa
Ranch Hand

Joined: May 01, 2008
Posts: 104
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:

<tr>
<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="page.option.select.model"/></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>
<#else>
<OPTION value="${model.description}" >${model.description}</OPTION>
</#if>
</#list>
</#if>
</SELECT>
<INPUT class="adjust_input lotdisp_input" type=text id="model" name="model" value="${myCars.model!""}" maxlength="10">
</td>
</tr>


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)
{

modelCodesCount++;
}

}

if(modelCodesCount > 0)
{

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


}
else
{
$("modelOfVehicle").style.display ="none";
$("model").style.display ="";
$("model").value="";

}

},
onFailure : function()
{

}
}
);
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Display Text in Dropdown List