...

View Full Version : validate order of dynamic dropdown menu



carrera
08-15-2005, 02:40 AM
Hi I'm having trouble with my validating the arrangement of my item list. Here's the scenario. I have several categories. Under each category are items. These items can be re-arranged for displaying purposes. Example Category A may have apple, ornage, grapes. Categ B may have carrots, potato. The items are dynamically inserted using database. I need to validate that arrangement of the items per category. It seems that my getElementByID is not working when I use it in my dropdown menu.
<%Rs = Select * from tblProducts Inner Join tblCategory ON tblCategory.ID=tbProducts.CategoryID order by CategoryID%>
<table>
<%do while not rs.eof%>
<tr>
<td><%=rs("CategoryName")%>
<input name="categ_<%=categctr%>" type="hidden" value="<%=rs("categoryid")%>" id="categ_<%=categctr%>"> </td>
<td><select name="rank_<%=listctr%>" class="catgrp_<%=categctr%>"
id="rank_<%=listctr%>">
<option value="0"></option>
<%For ctr = 1 to ranklist%><!--if there are 3 items under this
category, the dropdown menu will list 1,2,3 -->
<option value="<%=ctr%>"><%=ctr%></option>
<%Next%>
</select>
</td>
<td><%=rs("ProductName")%></td>
<%rs.movenext
Wend%>

javascrit part validation......
function ValidateRank(){
var categCount;
var categval;
var totalrankpercategory;
var numRank;
categCount = document.product.totalCategory.value; //total category count that will be used for looping
for(categcounter=1; categcounter <= categCount; categcounter++)
{
//get the value of category
categval = eval("document.product.categ_" + categcounter + ".value");
alert ("The Category beind tested is Category ID= " + categval);
//compare if rank belongs to category using class of dropdown menu. used alert only of testing if it works
if("document.getElementById('totalrankpercateg_" + categval + "').className == 'totalrankpercateg_" + categval + "'")
{
// get totalrank per category
totalrankpercategory = eval("document.product.totalrankpercateg_" + categval + ".value");
for(x=1; x <= totalrankpercategory; x++)
{
if("document.getElementById('rank_" + x + "').className == 'catgrp_" +
categval + "'")
{
numRank = eval("document.getElementById('rank_" + x
+ "').selectedIndex"); );<!--this is where im having difficulty. I dont get the right value that was seledted from the dropdown menu. -->

alert ("Category ID = " + categval + ". Total Rank= " +
totalrankpercategory + ". Rank List = " + numRank }
}
}

}

nikkiH
08-15-2005, 03:48 PM
Do a view source and look at what the browser sees. You ASP code may be wrong or something.
Javascript is case-sensitive, unlike VBScript.

If you still don't see what's wrong, post only the browser code here (not the ASP). Use the code [ code ]
and [ /code ]
(no spaces) to enclose it so it's readable, okay?

carrera
08-16-2005, 03:35 AM
Thanks for your help! Yeah I got it. You're right I have not reconsidered that javascript is case sensitve unlike vbscript. Thanks!



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum