Go Back   CodingForums.com > :: Client side development > JavaScript programming

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 01-22-2009, 05:06 PM   PM User | #1
jennypretty
Regular Coder

 
Join Date: Nov 2005
Posts: 225
Thanks: 2
Thanked 0 Times in 0 Posts
jennypretty is an unknown quantity at this point
Disable the values from drop-down list after first time write in it

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.

Code:
<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>
jennypretty is offline   Reply With Quote
Old 01-22-2009, 05:18 PM   PM User | #2
Philip M
Supreme Master coder!

 
Philip M's Avatar
 
Join Date: Jun 2002
Location: London, England
Posts: 17,105
Thanks: 197
Thanked 2,422 Times in 2,400 Posts
Philip M has a spectacular aura aboutPhilip M has a spectacular aura aboutPhilip M has a spectacular aura about
Does this help?

Code:
<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
Philip M is offline   Reply With Quote
Old 01-26-2009, 01:12 PM   PM User | #3
jennypretty
Regular Coder

 
Join Date: Nov 2005
Posts: 225
Thanks: 2
Thanked 0 Times in 0 Posts
jennypretty is an unknown quantity at this point
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.
jennypretty is offline   Reply With Quote
Old 01-26-2009, 01:29 PM   PM User | #4
Philip M
Supreme Master coder!

 
Philip M's Avatar
 
Join Date: Jun 2002
Location: London, England
Posts: 17,105
Thanks: 197
Thanked 2,422 Times in 2,400 Posts
Philip M has a spectacular aura aboutPhilip M has a spectacular aura aboutPhilip M has a spectacular aura about
Quote:
Originally Posted by jennypretty View Post
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.
Philip M is offline   Reply With Quote
Old 01-26-2009, 05:19 PM   PM User | #5
jennypretty
Regular Coder

 
Join Date: Nov 2005
Posts: 225
Thanks: 2
Thanked 0 Times in 0 Posts
jennypretty is an unknown quantity at this point
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.
jennypretty is offline   Reply With Quote
Old 01-26-2009, 05:45 PM   PM User | #6
Philip M
Supreme Master coder!

 
Philip M's Avatar
 
Join Date: Jun 2002
Location: London, England
Posts: 17,105
Thanks: 197
Thanked 2,422 Times in 2,400 Posts
Philip M has a spectacular aura aboutPhilip M has a spectacular aura aboutPhilip M has a spectacular aura about
Quote:
Originally Posted by jennypretty View Post
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.
Philip M is offline   Reply With Quote
Old 01-27-2009, 03:44 PM   PM User | #7
jennypretty
Regular Coder

 
Join Date: Nov 2005
Posts: 225
Thanks: 2
Thanked 0 Times in 0 Posts
jennypretty is an unknown quantity at this point
Server side is better?
Can yuo give me a hint ow how to do it?
thanks.
jennypretty is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 12:53 PM.


Advertisement
Log in to turn off these ads.