Gossamer Forum
Home : General : Internet Technologies :

Weird Javascript Assistance....

Quote Reply
Weird Javascript Assistance....
Okay...I've been trying to debug the following javascript and I still can't get it to work in IE (works just fine in Netscape 4.73 and 7.0, that's the weird part)....

JAVASCRIPT CODES

Code:
<SCRIPT language="JavaScript">
function butAdd_onClick() {
var inSelect = document.formQuestionListing.selQuestionListing;

//Depends on a fram named 'survey'
var outSelect = parent.survey.document.formNewQuestions.selSurveyQuestions;
for(var i=0; i<inSelect.length; i++) {
if(inSelect.options.selected) {
newOpt = new Option(inSelect.options.text, inSelect.options.value, false, false);
var iIndex = outSelect.selectedIndex;
//Kinda ugly ... you have to manually move all of the options down for
//an insert
for(var k=outSelect.length; k>outSelect.selectedIndex; k--)
outSelect.options[k] = outSelect.options[k-1];
outSelect.options[iIndex]=newOpt;
outSelect.options[iIndex].selected = false;
outSelect.options[iIndex+1].selected = true;
outSelect.selectedIndex = iIndex + 1;
}
else {
alert("You did not select a question.");
return false;
}
}
//Refreshes the listbox in the survey frame
parent.survey.history.go(0);
}
</script>

Basically, this script is supposed to move selections from a drop-down (multiple select) from one window to another drop-down (multiple select) in another window.

HTML FORM CODES (WINDOW 1: Selector)

Code:
<FORM NAME="formQuestionListing" ACTION="/admin/questionlisting.cfm" METHOD="POST">
<SELECT NAME="selQuestionListing" SIZE="10" MULTIPLE
onChange="questionList_onChange()">

<OPTION Value="7409">Which of the following vehicles would you prefer to win in a contest? (AT&T proposal survey 1/16/01)

<OPTION Value="7410">If you chose other, please specify a vehicle that is approximately $25,000 or less. (AT&T proposal survey 1/16/01)

<SELECT>
<INPUT name="butAdd" type="button" value="<<Add" onClick="butAdd_onClick()">
</FORM>

HTML FORM CODES (WINDOW 2: Selected)

Code:
<FORM action="#AdminScriptDir#/submitnewsurvey.cfm" method="POST" name="formNewQuestions" target="_parent">
<SELECT id="selNewSurvey" name="selSurveyQuestions" size="15">
<OPTION value="0" selected>
</select>

The javascript I receive in IE is the following:

Quote:

Line: 41
Char: 5
Error: Object doesn't support this property or method
Code: 0
URL: ****************************************


Line 41 is the following:

Code:
outSelect.selectedIndex = iIndex + 1;

Any suggestions and/or corrections are welcome and greatly appreciated.

Thanks.
========================================
Buh Bye!

Cheers,
Me

Last edited by:

Stealth: Jan 29, 2003, 9:37 AM
Quote Reply
Re: [Stealth] Weird Javascript Assistance.... In reply to
Do you have an active url available to see how you have it setup?

I think I get what you mean but the url would just help confirm.

Thanks.
Quote Reply
Re: [Paul] Weird Javascript Assistance.... In reply to
Unfortunately no...it's for our admin site, which has multiple layers of password protection and IP routing enabled...what I could do is upload the various files if that would help...

Thanks for the reply.
========================================
Buh Bye!

Cheers,
Me
Quote Reply
Re: [Stealth] Weird Javascript Assistance.... In reply to
Yeah that would be good. I was going to try and reproduce it but having the files would be quicker thanks.
Quote Reply
Re: [Paul] Weird Javascript Assistance.... In reply to
Paul,

Thanks for the reply...we decided to go with another non-framed solution, which may work better, but as a learning lesson (kicks and giggles), I'd like to know what's wrong with the code, since I may have to use something similar with another project and any suggestions you come up with are welcome and appreciated.

attached are the files that contain the relevant code...note that they are ColdFusion files (and one HTML file) with various queries in them (you'll probably have to re-format the HTML forms with static select drop-down menus).

No hurry, whenever you get a bored, free moment to play.

[BTW: These scripts were not written by me...they were written by the original developer of one of the sites that my company maintains...I'm just fixing some bugs...]

thanks again...
========================================
Buh Bye!

Cheers,
Me
Quote Reply
Re: [Stealth] Weird Javascript Assistance.... In reply to
Hokay, I've stripped out all the CFM code and I've managed to replicate your error. I'll see if I can get anywhere with this and get back to you.
Quote Reply
Re: [Stealth] Weird Javascript Assistance.... In reply to
Is this anything close to what you were after?

http://213.106.15.160/addsurvey.html
Quote Reply
Re: [Paul] Weird Javascript Assistance.... In reply to
Thanks, Paul!

That is great! I appreciate your efforts! That is exactly what I was after. In terms of learning, would you mind providing a brief description of how you fixed the error?

Thanks.
========================================
Buh Bye!

Cheers,
Me
Quote Reply
Re: [Stealth] Weird Javascript Assistance.... In reply to
Here are the files.
Quote Reply
Re: [Paul] Weird Javascript Assistance.... In reply to
Thanks...already saved them to my harddrive...but thanks for attaching the files for other users to download.
========================================
Buh Bye!

Cheers,
Me