Click to See Complete Forum and Search --> : plz check this code..in java script


sampathreddyv2000
October 7th, 2004, 07:48 AM
<html>
<head>
<title>

</title>
<script language="javascript">
function getPropValues()
{
var docclassname = search.docclass.options.value;
search.indexName.value = docclassname;
document.search.submit();

}
function changeLabel( buttonName )
{
var label = buttonName.value;

if(label == " ")
{

buttonName.value = " AND ";
}else if(label == " AND ")
{
buttonName.value = " OR ";
}else
{
buttonName.value = " ";
}
}


function emptyselect( myObj )
{


var operatorData1 = new Array("is equal","not equal","is after","is before","is null","is not null"," ");
var operatorData2 = new Array("is equal","is null","is not null"," ");
var operatorData3 = new Array("is equal","not equal","is greater than","is greater than or equal","is less than","is less than or equal","is null","is not null");
var operatorData4 = new Array("is equal","not equal","is greater than","is greater than or equal","is less than","is less than or equal","like","not like","is null","is not null");

// create an object pointing to the operator select
var operator = document.search.opr;

//clear the operator select
operator.options.length = 0;

if((myObj.options[myObj.selectedIndex].value == "F_ARCHIVEDATE" ) || (myObj.options[myObj.selectedIndex].value == "F_DELETEDATE" ) || (myObj.options[myObj.selectedIndex].value == "F_ENTRYDATE" ) || (myObj.options[myObj.selectedIndex].value == "date1" ))
{
for( var i=0;i<operatorData1.length;i++ )
{
operator.options[i] = new Option( operatorData1[i], i );
}

}
else if((myObj.options[myObj.selectedIndex].value == "F_DOCCLASSNUMBER" ) || (myObj.options[myObj.selectedIndex].value == "F_DOCNUMBER" ) || (myObj.options[myObj.selectedIndex].value == "F_PAGES" ) || (myObj.options[myObj.selectedIndex].value == "F_RETENOFFSET" ) ||
(myObj.options[myObj.selectedIndex].value == "id" ))
{

for( var i=0;i<operatorData3.length;i++ )
{
operator.options[i] = new Option( operatorData3[i] ,i );
}
}
else if((myObj.options[myObj.selectedIndex].value == "F_DOCTYPE" ) || (myObj.options[myObj.selectedIndex].value == "F_DOCCLASSNAME" ))
{

for( var i=0;i<operatorData2.length;i++ )
{
operator.options[i] = new Option( operatorData2[i] ,i );
}
}else
{
for( var i=0;i<operatorData4.length;i++ )
{
operator.options[i] = new Option( operatorData4[i] ,i );
}
}
}

</script>
</head>
<body style="margin:0" bgcolor="silver">



<form method="POST" name="search">

<br></br>



<center>
<DIV STYLE="overflow: auto; width: 650px; height: 230;
border-left: 1px gray solid; border-bottom: 1px gray solid;
padding:0px; margin: 0px">
<TABLE border=1 cellspacing=0 cellpadding=0>
<COL WIDTH=10><COL WIDTH=100><COL WIDTH=100><COL WIDTH=100>
<tr>
<td align="center" width=10 valign="top" nowrap>
<input type=button name="condition" value=" " onClick="javascript:changeLabel( this );">
</input>
</td>
<td align="center" width=150 valign="top">
<select name="prop" onChange="emptyselect( this );">

<option>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
&nbsp;&nbsp;&nbsp;&nbsp;
</option>

<option value=> </option>
<option value=F_ARCHIVEDATE> F_ARCHIVEDATE </option>
<option value=F_DELETEDATE> F_DELETEDATE </option>
<option value=F_DOCCLASSNAME> F_DOCCLASSNAME </option> <option value=F_DOCCLASSNUMBER> F_DOCCLASSNUMBER </option>
<option value=F_DOCFORMAT> F_DOCFORMAT </option> <option value=F_DOCLOCATION> F_DOCLOCATION </option> <option value=F_DOCNUBER> F_DOCNUBER </option> <option value=F_DOCTYPE> F_DOCTYPE </option>
<option value=F_ENTRYDATE> F_ENTRYDATE </option>
<option value=F_PAGES> F_PAGES </option> <option value=F_RETENOFFSET> F_RETENOFFSET </option>
<option value=date1> date1 </option>
<option value=id> id </option>
<option value=name> name </option>
<select>
</td>
<td align="center" width=200 valign="top">
<select name="opr">
<option>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
&nbsp;&nbsp;&nbsp;&nbsp;
</option>

</select>
</td>
<td align="center">
<input type=text size=20>
</td>
</tr>

<tr>
<td align="center" width=10 valign="top" nowrap>
<input type=button name="condition" value=" " onClick="javascript:changeLabel( this );">
</input>
</td>
<td align="center" width=150 valign="top">
<select name="prop" onChange="emptyselect( this );">

<option>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
&nbsp;&nbsp;&nbsp;&nbsp;
</option>

<option value=> </option>
<option value=F_ARCHIVEDATE> F_ARCHIVEDATE </option>
<option value=F_DELETEDATE> F_DELETEDATE </option>
<option value=F_DOCCLASSNAME> F_DOCCLASSNAME </option> <option value=F_DOCCLASSNUMBER> F_DOCCLASSNUMBER </option>
<option value=F_DOCFORMAT> F_DOCFORMAT </option> <option value=F_DOCLOCATION> F_DOCLOCATION </option> <option value=F_DOCNUBER> F_DOCNUBER </option> <option value=F_DOCTYPE> F_DOCTYPE </option>
<option value=F_ENTRYDATE> F_ENTRYDATE </option>
<option value=F_PAGES> F_PAGES </option> <option value=F_RETENOFFSET> F_RETENOFFSET </option>
<option value=date1> date1 </option>
<option value=id> id </option>
<option value=name> name </option>
<select>
</td>
<td align="center" width=200 valign="top">
<select name="opr">
<option>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
&nbsp;&nbsp;&nbsp;&nbsp;
</option>

</select>
</td>
<td align="center">
<input type=text size=20>
</td>
</tr>



</TABLE>
</div>
</center>
</form>
</body>
</html>



this code iam using in jsp..when user selects avalue from second column combobox then it should invoke emptselect() and show the corresponding values in third column combo box ..it should happen for all three rows..but its not working..and showing an error options not an object

PallaviDalvi
October 8th, 2004, 12:56 AM
for the simple reason that u have two controls named "opr" and 2 controls named "prop" in the same form.

sampathreddyv2000
October 9th, 2004, 03:15 AM
then how can resolve this problem.bcos i want to use same java script function for all rows..if i change the control names then i have to write java script function for each row with that code bocomes very lenghty..so how to use the same function for all rows..is it not possible to use if we wont give diffrent controls..if it is possible give me the solution..and also if i give the different controls name for all rows then how i can i use same function ..
plz help me..
regards,
sam

PallaviDalvi
October 9th, 2004, 10:10 AM
First and foremost...its is never encouraged to have controls with the same id or name. so basing ur processing in this fashion is not advisable. what u should do here is... pass the id/name of the control to the function. so no matter which controls id/name the function gets, it does its work correctly.

sampathreddyv2000
October 9th, 2004, 12:36 PM
thanks for your response..

do i need to pass both names of combo boxex..
means property combox box name is prop..when he selects then a combo box name called operator values should be changed..which is in next column..so i have to pass these values..if so how can i pass..plz give me some hint with code..
because i have like this 17 rows in my table..in each row same functionality applied..names of combo boxes i want to keep diffrent bcos i habe to retreive these values in next page..


only what i want is i want to use same java script function to all rows..then how can i apply.
tell me the way how can i pass the values of both combo boxex..

i tried in this way emptySelect(this,document.form.opr1)..like this but not working..

opr1 is the combo box name of the other one where values are changed when we select in first combo box..
regards,
sam

PallaviDalvi
October 10th, 2004, 11:59 PM
thats exactly how u shud be making a call to the function. at the same time i do hope that u've chnaged the signature and body of the function to incorporate this change. and now the controls have unique ids and Names.