View Full Version : script not finding the correct form

12-22-2003, 03:51 PM
I am using the javascript below to page forward and backward month to month in a coldfusion calendar app and it works fine EXCEPT when there is an include that contains two other forms (both named)

Then I get an error message ('options' is null or not an object)presumably because gotoMonth() is not looking at the correct form:(. This is not my script and I was wondering if there is someone around with enough javascript knowhow to help? thanks ~meg

function gotoMonth()
var theMonthList = document.forms[0].cboMonth;
var theYearList = document.forms[0].cboYear;
var theMonth = theMonthList.options[theMonthList.selectedIndex].value;
var theYear = theYearList.options[theYearList.selectedIndex].value;
theLocation = "index.cfm?fuseaction=ViewGoToMonth&GoToYear=" + theYear + "&GoToMonth=" + theMonth;
window.open(theLocation, "_top", "")

calling the script:

<input type="button" value=" Go " onclick="JavaScript:gotoMonth()" onmouseover="self.status='Go';return true" onmouseout="self.status='';return true">

if I need to post the whole for let me know and I will do so, but it will contain coldfsuion code that dynamically fills the options thanks again, meg

Willy Duitt
12-22-2003, 05:56 PM
Change what is highlighted in red to reflect the name of your form.

var theMonthList = document.forms[0].cboMonth;
var theYearList = document..forms[0].cboYear;


12-22-2003, 07:03 PM
thanks! I appreciate your help - meg