/    Sign up×
Community /Pin to ProfileBookmark

Logic works only if alert() is present

Hi,

I am facing a problem in a javascript code which populates about 20 combo box (varies dynamically)
using “new Option(text,value,..,..)” in a for loop and selects the appropriate value in the combo box based on a logic.
The logic is working fine if an alert() message is included in the script before the for loop but doesnt work properly if the alert is removed.
Can anyone provide some help on solving this issue?
Thanks in advance,
Anand

to post a comment
JavaScript

6 Comments(s)

Copy linkTweet thisAlerts:
@KorFeb 06.2004 — Show us the code and maybe we can help
Copy linkTweet thisAlerts:
@anand_sidhuauthorFeb 06.2004 — Hi ,

Here is the piece of script that cause the problem....

I am sending only the script part and this is a code generated dynamically in ASP..

( See the comments )

Complexity = new Object();

Links = new Object();

SimCapabilities = new Array("AppTalk", "EIH", "ETL", "REPL");

CapabilitiesLinks = new Array("1", "2", "3", "4");

Complexity["AppTalk"] = new Array("FTP", "Simple", "Standard", "Complex", "Custom");

Complexity["EIH"] = new Array("Simple", "Medium", "Complex", "Custom");

Complexity["ETL"] = new Array("Generic", "Custom");

Complexity["REPL"] = new Array("Generic", "Custom");

Links["AppTalk"] = new Array("1", "2", "3", "4", "5");

Links["EIH"] = new Array("1", "2", "3", "4");

Links["ETL"] = new Array("1", "2");

Links["REPL"] = new Array("1", "2");

initializefrm();

function initializefrm(){

[B]//logic works if only the alert is present[/B]

alert('Please wait...');

frmSubmit.cmb45_0.length = 0;

frmSubmit.cmb45_0.options[0] = new Option(SimCapabilities[0],CapabilitiesLinks[0],1,1)

for(count = 1; count < SimCapabilities.length; count++) {

var databaseSelCount =4;

[B]//**** problem area **************[/B]

[B]//here it should selects the fourth value in the combo box[/B]

[B] //which doesnt happen without the alert above[/B]

if (databaseSelCount !=1 && ((databaseSelCount) == CapabilitiesLinks[count])) {

frmSubmit.cmb45_0.options[count] = new Option(SimCapabilities[count], CapabilitiesLinks[count],0,1)

}

else{

frmSubmit.cmb45_0.options[count] = new Option(SimCapabilities[count], CapabilitiesLinks[count])

}

}

fillComplex0()

frmSubmit.cmb45_1.length = 0;

frmSubmit.cmb45_1.options[0] = new Option(SimCapabilities[0],CapabilitiesLinks[0],1,1)

for(count = 1; count < SimCapabilities.length; count++) {

[B] //**** problem area **************[/B]

[B] //here it should selects the second value in the combo [/B] [B]box[/B]

[B] //which doesnt happen without the alert above[/B]

var databaseSelCount =2;

if (databaseSelCount !=1 && ((databaseSelCount) == CapabilitiesLinks[count])) {

frmSubmit.cmb45_1.options[count] = new Option(SimCapabilities[count], CapabilitiesLinks[count],0,1)

}

else{

frmSubmit.cmb45_1.options[count] = new Option(SimCapabilities[count], CapabilitiesLinks[count])

}

}

fillComplex1()

frmSubmit.cmb45_2.length = 0;

frmSubmit.cmb45_2.options[0] = new Option(SimCapabilities[0],CapabilitiesLinks[0],1,1)

for(count = 1; count < SimCapabilities.length; count++) {

var databaseSelCount =3;

if (databaseSelCount !=1 && ((databaseSelCount) == CapabilitiesLinks[count])) {

frmSubmit.cmb45_2.options[count] = new Option(SimCapabilities[count], CapabilitiesLinks[count],0,1)

}

else{

frmSubmit.cmb45_2.options[count] = new Option(SimCapabilities[count], CapabilitiesLinks[count])

}

}

fillComplex2()

}

function fillComplex0(){

frmSubmit.cmb47_0.length = 0;

reg = new String(SimCapabilities[frmSubmit.cmb45_0.selectedIndex])

frmSubmit.cmb47_0.options[0] = new Option(Complexity[reg][0],Links[reg][0],1,1);

for(count = 1; count < Links[reg].length; count ++){

frmSubmit.cmb47_0.options[count] = new Option(Complexity[reg][count],Links[reg][count]);

}

}

function fillComplex1(){

frmSubmit.cmb47_1.length = 0;

reg = new String(SimCapabilities[frmSubmit.cmb45_1.selectedIndex])

frmSubmit.cmb47_1.options[0] = new Option(Complexity[reg][0],Links[reg][0],1,1);

for(count = 1; count < Links[reg].length; count ++){

frmSubmit.cmb47_1.options[count] = new Option(Complexity[reg][count],Links[reg][count]);

}

}

function fillComplex2(){

frmSubmit.cmb47_2.length = 0;

reg = new String(SimCapabilities[frmSubmit.cmb45_2.selectedIndex])

frmSubmit.cmb47_2.options[0] = new Option(Complexity[reg][0],Links[reg][0],1,1);

for(count = 1; count < Links[reg].length; count ++){

frmSubmit.cmb47_2.options[count] = new Option(Complexity[reg][count],Links[reg][count]);

}

}

Thanks in advance,

Anand
Copy linkTweet thisAlerts:
@anand_sidhuauthorFeb 06.2004 — Hi i am attaching the file which has the alert.

[upl-file uuid=f3b685bf-9833-4922-99fc-c663d591244d size=35kB]dingu.txt[/upl-file]
Copy linkTweet thisAlerts:
@anand_sidhuauthorFeb 06.2004 — Please ignore the previous file that was a wrong attachment.

[upl-file uuid=b0e6aad0-2a77-4ef7-b2ad-383bda746ae7 size=28kB]test.txt[/upl-file]
Copy linkTweet thisAlerts:
@KorFeb 06.2004 — seems OK at a rapid glance. Yet It might be a problem...

rise the end bracket in all code lines wich are:

<i>
</i>frmSubmit.cmb45_0.options[0]=new Option(SimCapabilities[0],CapabilitiesLinks[0],1,1
)


to:

<i>
</i>frmSubmit.cmb45_0.options[0]=new Option(SimCapabilities[0],CapabilitiesLinks[0],1,1)


I think that empty space can cause problems....
Copy linkTweet thisAlerts:
@anand_sidhuauthorFeb 06.2004 — Hi KOR, The solution You gave is not working


can anybody thing of any other solution??????
×

Success!

Help @anand_sidhu spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.6,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...