- Melraidin
- Oct 11, 2005
-
|
joojoo2915 posted:
code:(function() {
var oldonload = window.onload;
window.onload = function() {
if (oldonload)
oldonload();
if (!document.forms.futuresSeasonal.contractSelect.value){
var GOGRAIN_XML_URL = 'XML/futures_seasonal_chart_new.asp?ticker=<%=crop_letter%>&cropy=<%=Cropy%>';}
else{
var GOGRAIN_XML_URL = 'XML/futures_seasonal_chart_new.asp?ticker=<%=crop_letter%>&cropy=<%=Cropy%>&fs='+document.forms.futuresSeasonal.contractSelect.value;
}
buildMovieFromXML(GOGRAIN_XML_URL);
};
})();
[...]
First guess: define GOGRAIN_XML_URL outside of the if statement, then inside it do not use "var". Right now it looks like you're probably passing "undefined" to buildMovieFromXML as GOGRAIN_XML_URL doesn't exist outside that if statement in your code.
Try this:
code:var GOGRAIN_XML_URL = false;
if (!document.forms.futuresSeasonal.contractSelect.value){
GOGRAIN_XML_URL = 'XML/futures_seasonal_chart_new.asp?ticker=<%=crop_letter%>&cropy=<%=Cropy%>';}
else{
GOGRAIN_XML_URL = 'XML/futures_seasonal_chart_new.asp?ticker=<%=crop_letter%>&cropy=<%=Cropy%>&fs='+document.forms.futuresSeasonal.contractSelect.value;
}
buildMovieFromXML(GOGRAIN_XML_URL);
|
#
¿
Mar 13, 2009 14:48
|
|
- Adbot
-
ADBOT LOVES YOU
|
|
#
¿
May 8, 2024 18:30
|
|
- Melraidin
- Oct 11, 2005
-
|
Lumpy posted:
Huh? He passes it as an argument before the function ends, and javascript passes by value, not reference, so it's not undefined. Using 'var' twice like that is ugly, but it works in javascript.
[...]
Well drat, you're entirely correct. I was thinking that the variable would fall out of scope as soon as execution left the if-block. Tested and I was wrong, dammit.
|
#
¿
Mar 13, 2009 16:00
|
|