...

View Full Version : Disable the values from drop-down list after first time write in it



jennypretty
01-22-2009, 06:06 PM
Hello,

I have an evaluation form for managers to evaluate each seller who sells each car. Each seller's name is from the DB
table. Each car may have many sellers.

I am thinking about using JS to disable each seller's name when it is evaluated completely.

For example, there are two sellers (Jenny, Tom) at the drop-down list for Car A, when a manager get finished with "Jenny", then
"Jenny"'s name from the drop-down list is disabled from the list so that the manager can submit evaluation for "Tom".

Can JavaScript handle this type of issue? or it must be done with ASP?

If yes, can you please help?

Thanks.




<form name="frmSelect" method="Post" action="actionpost.asp" onSubmit="return chForm(this);">
<fieldset>
Select Cars :
<% Set oRs=Server.CreateObject("adodb.recordset")
strSQL = "SELECT DISTINCT Cars FROM tblComboSelect ORDER BY Cars;"
oRs.Open strSQL, myConn
if not oRs.eof then %>
<!--SELECT name="cars" onChange="document.frmSelect.submit()"-->
<SELECT name="cars" onChange="this.form.action='selectcombo1.asp';this.form.submit();">
<OPTION VALUE="1">Select Car</option>
<% do until oRs.EOF %>
<OPTION VALUE="<%= oRS(0) %>" <% if trim(request.form("Cars")) = trim(oRS(0)) then response.write " selected " end if %>><%= oRS(0) %></option>
<% oRs.MoveNext
loop %>
</SELECT>
<% else %>
<i>No Cars found in the database</i>
<% end if %>
<br />
Seller:
<%
strSQL = "SELECT sellerLast, sellerFirst " _
& " FROM tblComboSelect " _
& " WHERE Cars= '" & trim(request.form("Cars")) & "' and DateSold BETWEEN DateAdd('m', -9, Date()) AND Date(); "
Set oRs=Server.CreateObject("adodb.recordset")
oRs.Open strSQL, myConn
if not oRs.eof then %>
<select name="sellers">
<OPTION VALUE="1">Select Seller</option>
<% do until oRs.eof %>
<option value="<%= oRs("sellerLast") %>, <%= oRs("sellerFirst") %>"><%= oRs("sellerLast") %>, <%= oRs("sellerFirst") %></option>
<% oRs.MoveNext
loop %>
</select>
<% else %>
<i>No records found for that car</i>
<% end if %>
<br />
Customer's comments:
<textarea rows="2" cols="50" name="Comments" id="com"></textarea>
</fieldset>
<p><input name="btnSubmit" type="submit" value="Submit">
&nbsp;&nbsp;<input type="reset" name="Reset" value="Clear Form"></p>
</form>

Philip M
01-22-2009, 06:18 PM
Does this help?


<form name='Form1'>
<Select name='List1'onchange= "removeOptions(this)">
<option selected value=""> Choose A Fruit</option>
<option value='Mango'> Mango </option>
<option value='Apple'> Apple </option>
<option value='Sunkist'> Sunkist </option>
<option value='Watermelon'> Watermelon </option>
<option value='Papaya'> Papaya </option>
</select>
</form>

<script type = "text/javascript">

function removeOptions(selectbox) {
for(var i=selectbox.options.length-1;i>=1;i--) {
if(selectbox.options[i].selected)
selectbox.remove(i);
}
}

</script>



Quizmaster: The 1959 film by Alfred Hitchcock featuring two points of the compass in its name was called "North By North ....." what?
Contestant: South

jennypretty
01-26-2009, 02:12 PM
I tested it out. This script will remove the drop-down option every time I selected it.

Can ASP do this job? Can you give me a hint of how to do this?

Thanks.

Philip M
01-26-2009, 02:29 PM
I tested it out. This script will remove the drop-down option every time I selected it.


I thought that was what you wanted. If not so, please can you make your requirement clearer.

Obviously you can trigger the removeOptions() function with some other event, such as when a form is submitted or whatever.

jennypretty
01-26-2009, 06:19 PM
I like to use either JS or ASP to exclude the person who has already been evaluated when the page reloads, so the manager could only evaluate the remaining sales people.

Thanks.

Philip M
01-26-2009, 06:45 PM
I like to use either JS or ASP to exclude the person who has already been evaluated when the page reloads, so the manager could only evaluate the remaining sales people.



You could only do this in Javascript with cookies - not recommended.
You should do this server-side.

jennypretty
01-27-2009, 04:44 PM
Server side is better?
Can yuo give me a hint ow how to do it?
thanks.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum