I have a Struts select list however i would like to use javascript to set selected option to the default headerKey and headerValue specified when creating the item. I am unable to get the option to set. Under is my select list:

Struts Select List

<s:select id="relationshipTypeId"
name="relationshipTypelist" headerKey= "0" headerValue="Select Relationship Type"
list="relationshipTypelist"
listKey="id" listValue="relationshipName"/>

Javascript

This does not work it only sets the display item to 0 i would like it to default to the headerKey and headerValue.

  document.getElementById('relationshipTypeId').value = 0;
有帮助吗?

解决方案

This worked for me after i posted this question

document.getElementById('relationshipTypeId').setAttribute('value',0);
许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top