Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 7 of 7
  1. #1
    Regular Coder
    Join Date
    Nov 2005
    Posts
    225
    Thanks
    2
    Thanked 0 Times in 0 Posts

    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>

  • #2
    Supreme Master coder! Philip M's Avatar
    Join Date
    Jun 2002
    Location
    London, England
    Posts
    18,017
    Thanks
    203
    Thanked 2,538 Times in 2,516 Posts
    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

  • #3
    Regular Coder
    Join Date
    Nov 2005
    Posts
    225
    Thanks
    2
    Thanked 0 Times in 0 Posts
    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.

  • #4
    Supreme Master coder! Philip M's Avatar
    Join Date
    Jun 2002
    Location
    London, England
    Posts
    18,017
    Thanks
    203
    Thanked 2,538 Times in 2,516 Posts
    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.

  • #5
    Regular Coder
    Join Date
    Nov 2005
    Posts
    225
    Thanks
    2
    Thanked 0 Times in 0 Posts
    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.

  • #6
    Supreme Master coder! Philip M's Avatar
    Join Date
    Jun 2002
    Location
    London, England
    Posts
    18,017
    Thanks
    203
    Thanked 2,538 Times in 2,516 Posts
    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.

  • #7
    Regular Coder
    Join Date
    Nov 2005
    Posts
    225
    Thanks
    2
    Thanked 0 Times in 0 Posts
    Server side is better?
    Can yuo give me a hint ow how to do it?
    thanks.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •