SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Enthusiast
    Join Date
    Mar 2001
    Location
    UK, London
    Posts
    42
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    error with [selectedIndex]

    Can anyone help???!!!!

    Im currently designing a JSP, which has some javascript embedded. What i am trying to do, is disable a button, if a user selects a particular row from the drop down list.

    At the moment, within the select tag, the value of a variable (called Status) is queried to find out which option should have the <option selected> tag by it.
    The problem is every time onchange gets run, i get an error saying that 'selectedindex' is undefined.
    Any ideas?




    Code:
    <% String status = DLPULGA3Bean.getStatus(); %>
    
    function checkIfAll()
    {
    
    	if (window.document.DLPULGA3form.statusValue.options[selectedIndex].value == "All")
    		{
    	window.document.DLPULGA3form.Find.disabled = true;
                    }
    	else
    		{
    		return false;
    		}
    }
    
    
    <select name="statusValue" onChange="checkIfAll()">
    			<% if (status.equals("Accepted")) {%>
    			      <option selected>Accepted</option>
    			      <option value ="Rejected">Rejected</option>
    			      <option value ="Proposed"> Proposed</option>
    			      <option value ="All">All</option>
    			<% } else  if (status.equals("Rejected")) {%>
    			      <option value ="Accepted">Accepted</option>
    			      <option selected>Rejected</option>
    			      <option value ="Proposed">Proposed</option>
    			      <option value ="All">All</option>
    			<% } else if (status.equals("Proposed")) {%>
    			      <option value ="Accepted">Accepted</option>
    			      <option value ="Rejected">Rejected</option>
    			      <option selected>Proposed</option>
    			      <option value ="All">All</option>
    			<% } else { %>	
    			      <option value ="Accepted">Accepted</option>
    			      <option value ="Rejected">Rejected</option>
    			      <option value ="Proposed">Proposed</option>
    		              <option selected>All</option>					      
    			<% }      %>
    		</select>
    If you can talk, you can sing, if you can walk, you can dance!!

  2. #2
    SitePoint Guru
    Join Date
    Jan 2001
    Location
    Alkmaar, Netherlands
    Posts
    710
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    document.formName.selectName.options[document.formName.selectName.selectedIndex].value


Bookmarks

Posting Permissions

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