Reputation: 1
I am trying to disable the default value for an asp select list, the default value being the string "null".
I want this to remain as the default, but when the user has selected another item in the select list to disable it as a selectable option.
The ASP code for the select list is below:
Response.Write "<Select name=""PersonID" & temporary.Fields("EventID") & class=""SelectText"" style=""width:100%"">" & vbCrLf &_
"<Option value=""NULL""></Option>"
Upvotes: 0
Views: 437
Reputation:
Alternatively to Zee Tee's answer, you could read the value on post back and determine its value...
<select id="personId" name="personId<%=eventId%>" class="selectText">
<option value="-1">-- Please select a value --</option>
<option value="1">......</option>
</select>
...and the postback code...
Dim personId, failForm
personId = Request.Form("PersonId")
failForm = (personId = -1)
Upvotes: 1
Reputation: 13233
Not sure why you would need to do this, usually you convert the empty value to null in your backend script if needed, or you can use something like jQuery to do this client-side, hoping that your browser has javascript enabled:
$("select").change(function(e){
$("option[value='NULL']:first",this).remove();
});
This will remove the first null option in your select list on change. If you need more help with javascript/jquery, you should tag your questions as so.
Upvotes: 1