Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Please help me with this...

Status
Not open for further replies.

sabavno

Programmer
Jul 25, 2002
381
CA
Hi,
I have a problem.
I suspect something is wrong with the sequence in which the events fire, because my OnChange event for SearchBy drop-down list works only until OnChange event for DisplayBy fires, then if I come back to SearchBy drop-down box and change the values, OnChange event does not fire.

Please help me. I am stuck with this for quite a while already.

You can copy and paste the following to see what happens.


<html>

<head>
<title>PC Refresh Charges</title>
<style fprolloverstyle>A:hover {color:#ff9900; font-weight: bold}
</style>



<SCRIPT LANGUAGE=&quot;JavaScript&quot;>

function ChangeValues()
{

var theOptions=[&quot;Name&quot;,&quot;Rollup/Bill To Transit&quot;,&quot;Physical Transit&quot;];
document.all.tblPh_tr.style.display='none'
document.all.tblBl_tr.style.display='none'
document.all.tblName.style.display='none'

if (document.all.DisplayBy.value==&quot;Charges&quot;)
{
numOptions=2;
document.all.SearchBy.options.length=0; //clears options
for (count=0;count<numOptions;count++)
{
document.all.SearchBy.options[count] = new Option (theOptions[count]);


}
document.all.tblName.style.display='block'

} else
{
numOptions=3;
document.all.SearchBy.options.length=0; //clears options
for (count=0;count<numOptions;count++)
{
document.all.SearchBy.options[count] = new Option (theOptions[count]);


}
document.all.tblBl_tr.style.display='block'

}


document.all.SearchBy.focus()

}


function Show()
{
if (document.all.DisplayBy.value==&quot;Charges&quot;)
{
if (document.all.SearchBy.value==&quot;Name&quot;){
document.all.tblPh_tr.style.display='none'
document.all.tblBl_tr.style.display='none'
document.all.tblName.style.display='block'
document.all.tblName.focus()}
if (document.all.SearchBy.value==&quot;BillingTransit&quot;) {
document.all.tblPh_tr.style.display='none'
document.all.tblBl_tr.style.display='block'
document.all.tblName.style.display='none'
document.all.tblBl_tr.focus()}
}else {
if (document.all.SearchBy.value==&quot;PhysicalTransit&quot;) {
document.all.tblPh_tr.style.display='block'
document.all.tblBl_tr.style.display='none'
document.all.tblName.style.display='none'
document.all.tblPh_tr.focus()}
if (document.all.SearchBy.value==&quot;BillingTransit&quot;) {
document.all.tblPh_tr.style.display='none'
document.all.tblBl_tr.style.display='block'
document.all.tblName.style.display='none'
document.all.tblBl_tr.focus()}
if (document.all.SearchBy.value==&quot;Name&quot;){
document.all.tblPh_tr.style.display='none'
document.all.tblBl_tr.style.display='none'
document.all.tblName.style.display='block'
document.all.tblName.focus()
}

}


}

</Script>



</head>


<body>

<SELECT ID=&quot;DisplayBy&quot; onChange=&quot;ChangeValues()&quot;>

<OPTION value=&quot;Charges&quot;
>Charges</OPTION>
<OPTION value=&quot;Count&quot;

>Count</OPTION>

</SELECT>
<SELECT ID=&quot;SearchBy&quot; onChange=&quot;Show()&quot;>


<OPTION value=&quot;BillingTransit&quot;
>Rollup/Bill To Transit</OPTION>

<OPTION value=&quot;Name&quot;

>Name</OPTION>
</SELECT>
<table ID=&quot;tblBl_tr&quot; STYLE=&quot;display: block &quot;width=&quot;488&quot;>
<tr>
<td width=&quot;269&quot;>&nbsp; Enter Rollup/Bill To Transit:</td>
<td width=&quot;176&quot;>
<!--webbot bot=&quot;Validation&quot; s-data-type=&quot;Integer&quot; s-number-separators=&quot;,&quot; i-maximum-length=&quot;5&quot; --><INPUT NAME=&quot;BillingTransit&quot; size=18 MAXLENGTH=5></td>
<td width=&quot;83&quot;><INPUT TYPE=&quot;SUBMIT&quot; VALUE=&quot;Submit&quot;></td>
</tr>
</table>
<table ID=&quot;tblName&quot; STYLE=&quot;display: none&quot;width=&quot;558&quot;>
<tr>
<td width=&quot;225&quot;>&nbsp; Enter Last Name:</td>
<td width=&quot;169&quot;>
<!--webbot bot=&quot;Validation&quot; s-data-type=&quot;Integer&quot; s-number-separators=&quot;,&quot; i-maximum-length=&quot;5&quot; --><INPUT NAME=&quot;LastName&quot; size=18 MAXLENGTH=5></td>
<td width=&quot;150&quot;>&nbsp;</td>
</tr>
<tr>
<td width=&quot;225&quot;>&nbsp; Enter First Name:</td>
<td width=&quot;169&quot;>
<!--webbot bot=&quot;Validation&quot; s-data-type=&quot;Integer&quot; s-number-separators=&quot;,&quot; i-maximum-length=&quot;5&quot; --><INPUT NAME=&quot;LastName&quot; size=18 MAXLENGTH=5></td>
<td width=&quot;150&quot;><INPUT TYPE=&quot;SUBMIT&quot; VALUE=&quot;Submit&quot;></td>
</tr>
</table>
<table ID=&quot;tblPh_tr&quot; STYLE=&quot;display: none&quot;width=&quot;559&quot;>
<tr>
<td width=&quot;226&quot;>&nbsp; Enter Physical Transit:</td>
<td width=&quot;167&quot;>
<!--webbot bot=&quot;Validation&quot; s-data-type=&quot;Integer&quot; s-number-separators=&quot;,&quot; i-maximum-length=&quot;5&quot; --><INPUT NAME=&quot;PhysicalTransit&quot; size=18 MAXLENGTH=5></td>
<td width=&quot;152&quot;><INPUT TYPE=&quot;SUBMIT&quot; VALUE=&quot;Submit&quot;></td>
</tr>
</table>
<p align=&quot;justify&quot;>&nbsp;</td>
</tr>


</table>

</body>

</html>

 
This is what looks like the problem to me.

The HTML page sets the following
Code:
<OPTION value=&quot;BillingTransit&quot;>Rollup/Bill To Tansit</OPTION>
    
<OPTION value=&quot;Name&quot;>Name</OPTION>
Your ChangeValues function erases these options and creates new ones with these values
Code:
var theOptions=[&quot;Name&quot;,&quot;Rollup/Bill To Transit&quot;,&quot;Physical Transit&quot;];
Nowhere in the code do you set the value of the &quot;Rollup/Bill To Transit&quot; option to &quot;BillingTransit&quot;.

By the same token, you are not specifically setting the new Name option to have a value of &quot;Name&quot;. I thought if you don't specify a value for an Option, it takes on the value of the display text but this may be different because you are creating it through script.

Hope this helps,

Thanks,

Gabe
 
Thanks a lot,
But would you happen to know how I should set the value of the &quot;Rollup/Bill To Transit&quot; option to &quot;BillingTransit&quot;?
 
Try this:
Code:
document.all.SearchBy.options[count].value = 'BillingTransit';
Thanks,

Gabe
 
You were right!
Thank you very much!
You've made my day!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top