JavaScript - Variable Is Not Defined Error In Firefox
I'm having some issues with firefox, chrome seems to work ok. Firebug is giving me an error stating country is not defined. The line it's saying it's on is where the function for an ajax call to populate a select input on page load.
Here's the script that sets up the functions to call and fill the state and city values: Code: <script src="/components/com_helloworld/js/request.js"> /**************************************************** * Ajax call to fill city values ****************************************************/ </script> <script> function handleOnChange(dd1) { var idx = dd1.selectedIndex; var val = dd1[idx].text; var par = document.forms["cbcheckedadminForm", "adminForm"]; var parelmts = par.elements; var cb_statesel = parelmts["cb_state"]; var country = val; var directory = ""+document.location; directory = directory.substr(0, directory.lastIndexOf('/')); Http.get({ url: "./components/com_helloworld/js/regvalues/states/" + country + ".php", callback: fillcb_state, cache: Http.Cache.Get }, [cb_statesel]); } function fillcb_state(xmlreply, cb_stateelmt) { if (xmlreply.status == Http.Status.OK) { var cb_stateresponse = xmlreply.responseText; var cb_statear = cb_stateresponse.split("|"); cb_stateelmt.length = 1; cb_stateelmt.length = cb_statear.length; for (o=1; o < cb_statear.length; o++) { cb_stateelmt[o].text = cb_statear[o]; } } else { alert("Cannot handle the Ajax call."); } } function handleOnChange2(dd1) { var idx = dd1.selectedIndex; var val = dd1[idx].text; var par = document.forms["cbcheckedadminForm", "adminForm"]; var parelmts = par.elements; var cb_citysel = parelmts["cb_city"]; var state = val; var directory = ""+document.location; directory = directory.substr(0, directory.lastIndexOf('/')); Http.get({ url: "./components/com_helloworld/js/regvalues/" + state + ".php", callback: fillcb_city, cache: Http.Cache.Get }, [cb_citysel]); } function fillcb_city(xmlreply, cb_cityelmt) { if (xmlreply.status == Http.Status.OK) { var cb_cityresponse = xmlreply.responseText; var cb_cityar = cb_cityresponse.split("|"); cb_cityelmt.length = 1; cb_cityelmt.length = cb_cityar.length; for (o=1; o < cb_cityar.length; o++) { cb_cityelmt[o].text = cb_cityar[o]; } } else { alert("Cannot handle the Ajax call."); } } </script> And here's how it's being triggered on page load: Code: <script> function addLoadEvent(func) { var oldonload = window.onload; if (typeof window.onload != 'function') { window.onload = func; } else { window.onload = function() { if (oldonload) { oldonload(); } func(); } } } addLoadEvent(function() { ajaxFunction(document.getElementById('country').value); handleOnChange(country); setupDependencies('cbcheckedadminForm', ''); handleOnChange2(cb_state); }); </script> I'm not sure why it says it's not defined as it clearly is. This error is causing the dependent drop down script to not work in firefox causing the child dropdowns to not hide. I did notice something odd though, if I remove the doctype line it works ok. I did this as firebug was throwing an error on another page claiming it had a syntax error so obviously something somewhere is messed up. Code: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="<?php echo $this->language; ?>" lang="<?php echo $this->language; ?>" dir="<?php echo $this->direction; ?>"> When the doctype lines are removed firebug throws this error: window.document.forms[arguments[i]] is undefined [Break On This Error] for(var j = 0, e = window.document...ts[i]].elements; j < e.length; ++j) { in formmanager.js. Similar TutorialsHello I have a php page in which I declared a js variable... right at the top of the page... <script type="text/javascript"> var tester = 0; </script> Later in the page I test this variable... <script type="text/javascript"> if (tester==1){ do some stuff!! } </script> But I keep getting an error variable _tester undefined Am I missing something obvious... I am new to js... but this seems really straightforward Hi, Using a while loop in a function, I am trying to test an input character against a stored string of characters. I want the function to return the input character only if it is not in the stored string of characters. The code I've prepared is as follows: Code: <SCRIPT language = "JavaScript"> var storedLetters = 'sideways'; function requestLetters(aString) { var validLetter =''; var inputLetter = window.prompt('Please input a single lower-case letter', ''); while (storedLetters.indexOf(inputLetter) != -1) { inputLetter = window.prompt('You have already tried ' + inputLetter + ' . Please try another' + ' letter.'); } validLetter = inputLetter; return validLetter; } requestLetters(storedLetters); document.write(validLetter); </SCRIPT> The code works fine if I remove it from the function wrapper but if the function is called I keep getting an error message that the variable validLetter is not defined. Can anyone see why this is the case? Thanks. Hi all, I am relatively new to java; hence I know the basics, but have been thrown into trouble because I am currently working with a cms system that doesnt keep within the correct name conventions (pre defined). Within a form, I simply want to set a date to todays date: <script type="text/javascript"> function initdt(mf) { var t = new Date; mf.01-date.value = t.getDate(); mf.02-month.value = t.getMonth() + 1; mf.03-year.value = t.getFullYear(); } onload="initdt(document.WBForm);" </script> This works perfect on a form I create, but sadly I must use a form within a pre defined system that uses "01-date" Is there a way around this? A simple way of setting 01-date to t.getDate(); Your help will be very much appreciated Regards Damon Simpson Hi Guys, I have a new problem My site is run on wordpress, but I'd like to customise the menu so that if the user is logged in the menu displays "Logged In" and if they are not it displays "Log In". Normally I would just use an if statement in PHP to output the required html, but as I can't use PHP code in the menu item I need to use Javascript. So, the way I figured this would work is: 1) PHP code in the header checks to see whether the user is logged in 2) This code then outputs JS to define a variable (varCheckLogin) 3) JS within the menu checks varCheckLogin and outputs the html i want This sounds good hopefully. Unfortunately this isn't working at the moment. The code I have is: HEADER: (I know this works as the variable is being output correctly in the source code) Code: <?php if (is_user_logged_in()) { echo '<script type="text/javascript"> varLoginCheck = "Yes"; </script>'; } else { echo '<script type="text/javascript"> varLoginCheck = "No"; </script>'; } ?> MENU ITEM: Code: <script> if (varLoginCheck = "No") { document.write('<span class="mmLogin">Log In</span>'); } else { document.write('<span class="mmLogin">Logged In</span>'); } </script> I put an alert in the menu item and it always sees varLoginCheck as "Yes". Any ideas why this could be? All help is much appreciated. Thanks Sam Code: $(document).ready(function(){ var theText=["Text one","Text two","Text three", "Text four"]; // Build the array of text var arrayRows = theText.length; //Get the length of the array (Note: This starts at 1 not 0 like the array) var i=0; //Set a counter document.getElementById('textHere').innerHTML =theText[i]; //Fill in the space with the first piece of text time = setTimeout("next()", 2000); function next() { if (i == (arrayRows-1)) { i = 0; }else { i++; } $("#textHere").fadeOut("slow", function(){ document.getElementById('textHere').innerHTML =theText[i]; $("#textHere").fadeIn("slow"); }); } function prev() { if (i <= 0) { // If its below 0 go to the max i = arrayRows-1; }else { i--; } $("#textHere").fadeOut("slow", function(){ //Fade out the area document.getElementById('textHere').innerHTML =theText[i]; //Change the text to the next piece of text $("#textHere").fadeIn("slow"); // Fade in the area }); } $("#prevText").click(function(e) { e.preventDefault(); // Stop the link being a link prev(); }); $("#nextText").click(function(e) { e.preventDefault(); next(); }); }); When i click the links the functions work, however the setTimeout doesnt, can anyone help me figure this out? Hi all, Trying to use a small bit of script to slide open and closed a div. Copied it from another page where I have it working just fine. Coding in coldfusion. When clicked, nothing happens, and firebug pulls an error of DC_ShowDeptStaff is undefined. Script is: Code: <script type="text/javascript"> function DC_ShowDeptStaff(){ if( document.getElementById("testdiv").style.display=="none" ) { Effect.BlindDown("testdiv"); return false; } else { Effect.SlideUp("testdiv"); return false; } } </script> Call is: Code: <a href="javascript:;" onclick="DC_ShowDeptStaff()" return false;>See All Staff in this Department</a> Full code is: Code: <script type="text/javascript"> function DC_ShowDeptStaff(){ if( document.getElementById("testdiv").style.display=="none" ) { Effect.BlindDown("testdiv"); return false; } else { Effect.SlideUp("testdiv"); return false; } } </script> <cfquery name="getStaffProfileDepartments" datasource="#ATTRIBUTES.datasource#" username="#ATTRIBUTES.username#" password="#ATTRIBUTES.password#"> SELECT spd.staffProfileDepartmentName, spd.staffProfileDepartmentId FROM dccom_twstaffprofilesdepartments spd WHERE spd.instanceId = <cfqueryparam value = "#REQUEST.instanceId#"> AND spd.staffProfileDepartmentIsPublished = 'YES' ORDER BY spd.staffProfileDepartmentDisplayOrder, spd.staffProfileDepartmentName </cfquery> <cfif getStaffProfileDepartments.RecordCount NEQ 0> <cfloop query="getStaffProfileDepartments"> <!---INSIDE LOOP ONE---> <cfoutput> <h3>#staffProfileDepartmentName#</h3> <h4><a href="javascript:;" onclick="DC_ShowDeptStaff()" return false;>See All Staff in this Department</a></h4><br> <div class="testdiv" style="display: none"><h3>Test Success!</h3></div> <cfquery name="getStaffProfiles" datasource="#ATTRIBUTES.datasource#" username="#ATTRIBUTES.username#" password="#ATTRIBUTES.password#"> SELECT sp.staffProfileId, sp.staffProfileName, sp.staffProfilePosition, sp.staffProfilePhone, sp.staffProfileMobile, sp.staffProfileEmail, sp.staffProfileDescription, sp.staffProfileImage, sp.staffProfileDisplayOrder, spd.staffProfileDepartmentName, sp.staffProfileIsDepartmentHead, sp.staffProfileIsPublished FROM dccom_twstaffprofiles sp LEFT OUTER JOIN dccom_twstaffprofilesdepartments spd ON sp.staffProfileDepartmentId = spd.staffProfileDepartmentId AND sp.instanceId = spd.instanceId WHERE sp.instanceId = <cfqueryparam value = "#REQUEST.instanceId#"> AND sp.staffProfileIsPublished = 'YES' AND spd.staffProfileDepartmentId = <cfqueryparam value="#staffProfileDepartmentId#"> ORDER BY sp.staffProfileIsDepartmentHead DESC, sp.staffProfileDisplayOrder, sp.staffProfilePosition </cfquery> <cfif getStaffProfiles.RecordCount NEQ 0> <cfloop query="getStaffProfiles"> <cfoutput> <ul> <cfset cStaffProfileDescription = staffProfileDescription> <cfset cStaffProfileDescription = replace(replace(cStaffProfileDescription,chr(13) & chr(10),"<br>","ALL"),chr(10),"<br>","ALL")> <li> <cfif staffProfileIsDepartmentHead EQ 'YES'> <div class="staffInfo"> <h3>#staffProfileName#</h3> <h3>DEPT HEAD</h3> <cfif LEN(#staffProfilePosition#)><h4>#staffProfilePosition#</h4></cfif> <cfif LEN(#staffProfilePosition#)><p>#cStaffProfileDescription#</p></cfif> <cfif LEN(#staffProfilePhone#)><p>Phone: #staffProfilePhone#</p></cfif> <cfif LEN(#staffProfileMobile#)><p>Mobile: #staffProfileMobile#</p></cfif> <cfif LEN(#staffProfileEmail#)><p><a href="mailto:#staffProfileEmail#">#staffProfileEmail#</a></p></cfif> </div> <cfif LEN(#staffProfileImage#)> <div class="staffImage"> <cfif LEN(staffProfileImage) AND fileExists(APPLICATION.siteFilePath & "contentFiles\components\twStaffProfiles\" & REQUEST.instanceId & "\" & staffProfileImage)><img src="contentFiles/components/twStaffProfiles/#REQUEST.instanceId#/#staffProfileImage#" width="100" height="120" alt="#staffProfilePosition#"> </cfif> </div> </cfif> <cfelse> <h3>HIDDEN STAFF PROFILE</h3> <div class="staffInfo2" style="display:none" > <h3>#staffProfileName#</h3> <cfif LEN(#staffProfilePosition#)><h4>#staffProfilePosition#</h4></cfif> <cfif LEN(#staffProfilePosition#)><p>#cStaffProfileDescription#</p></cfif> <cfif LEN(#staffProfilePhone#)><p>Phone: #staffProfilePhone#</p></cfif> <cfif LEN(#staffProfileMobile#)><p>Mobile: #staffProfileMobile#</p></cfif> <cfif LEN(#staffProfileEmail#)><p><a href="mailto:#staffProfileEmail#">#staffProfileEmail#</a></p></cfif> </div> <cfif LEN(#staffProfileImage#)> <div class="staffImage"> <cfif LEN(staffProfileImage) AND fileExists(APPLICATION.siteFilePath & "contentFiles\components\twStaffProfiles\" & REQUEST.instanceId & "\" & staffProfileImage)><img src="contentFiles/components/twStaffProfiles/#REQUEST.instanceId#/#staffProfileImage#" width="100" height="120" alt="#staffProfilePosition#"> </cfif> </div> </cfif> </cfif> </li> </ul> </cfoutput> </cfloop> <cfelse> <cfoutput> <p>There are Currently No Staff Listed in this Department</p> <br> </cfoutput> </cfif> </cfoutput> <!---end loop one---> </cfloop> </cfif> any input would be appreciated Greetings all. Please let me apologize in advance if this is a tremendously stupid question, but I'm new to Jquery and ASP... and I'm suddenly building an entire site made of both. *sigh* I keep getting an error message in Firebug in relation to the accordion menu I created. "$ not defined $(function() {" If the navigation is isolated on its own page, the error does not exist. It only occurs once it is brought into the Store Master page. Working Version: http://www.stephenjosephinc.com/testing/ Non-Working Version: http://74.124.26.78/ The following code is cut from the head in the non-functional page: Code: <head id="ctl00_Head1"> <title>Shop Online</title> <meta http-equiv="Content-Type" content="text/html;charset=utf-8" /> <link rel="icon" href="App_Master/favicon.ico" type="image/x-icon" /> <link rel="shortcut icon" href="App_Master/favicon.ico" type="image/x-icon" /> <link type="text/css" href="App_Master/css/custom-theme/jquery-ui-1.8.4.custom.css" rel="stylesheet" /> <script type="text/javascript" src="js/jquery-1.4.2.min.js"></script> <script type="text/javascript" src="js/jquery-ui-1.8.4.custom.min.js"></script> <link type="text/css" href="App_Master/theme/ui.all.css" media="screen" rel="stylesheet" /> <script type="text/javascript"> $(function() { $("#accordion").accordion({ collapsible: true, autoHeight: false, header: "h3"} ); }); </script> <link href="App_Themes/DefaultTheme/master.css" type="text/css" rel="stylesheet" /> <link href="App_Themes/DefaultTheme/menu.css" type="text/css" rel="stylesheet" /> </head> If it helps at all, you may view the entire code he http://74.124.26.78/full_code.txt Please note: I DID NOT create the code on the aforementioned page. It's an ugly, nightmarish mess (at least to my non-ASP-loving eyes), so please don't hate me for bad form in the body code. The only code that I wrote for this page is the bit you see above and the hrefs for the side nav. Any help would be massively appreciated! Thank you in advance! Hi, I am trying to get this function to work, it looks great in theory but I keep getting the error message file is not defined. What have I done wrong? The code is: Code: <head> <script type="text/javascript"> function loadXMLDoc(File,ID){ if (window.XMLHttpRequest) { xmlhttp=new XMLHttpRequest(); } else { xmlhttp=new ActiveXObject("Microsoft.XMLHTTP"); } xmlhttp.open("POST",FILE,true); xmlhttp.onreadystatechange=function(){ if (xmlhttp.readyState==4 && xmlhttp.status==200){ document.getElementById(ID).innerHTML=xmlhttp.responseText; } } xmlhttp.send(); } </script> </head> <body> <input type="button" value="Test" onclick="loadXMLDoc('getToday.php','txtHint');" > <input type="button" value="Test2" onclick="loadXMLDoc('getYesterday.php','txtHintYest');" > </body> Hi, I have the following script which should work in theory, however I get the error message that file is not defined. I have tried playing around with using variables and I can not work out how to correct this. My code is: Code: <head> <script type="text/javascript"> function loadXMLDoc(File,ID){ if (window.XMLHttpRequest) { xmlhttp=new XMLHttpRequest(); } else { xmlhttp=new ActiveXObject("Microsoft.XMLHTTP"); } xmlhttp.onreadystatechange=function(){ if (xmlhttp.readyState==4 && xmlhttp.status==200){ document.getElementById(ID).innerHTML=xmlhttp.responseText; } } xmlhttp.open("POST",FILE,true); xmlhttp.send(); } </script> </head> <body> <input type="button" value="Test" onclick="loadXMLDoc($File='getToday.php','txtHint');" > <input type="button" value="Test2" onclick="loadXMLDoc($File='getTomorrow.php','txtHintTom');" > I'm getting an '$active is not defined' error, which makes sense because the method that defines it isn't called till 10 seconds after I check if it is defined below. But that's the point. I'm actually checking to see if it is defined, and if it's not, then I defined. However, firebug still gives me the error for this: Code: if ($active == undefined) { $active = $('.paging a.active'); } var triggerID = $active.attr("rel") - 1; var image_reelPosition = triggerID * imageWidth; I also tried: if ($active === undefined) if (!$active) But nothing works. I'm just trying to check if it's not defined, then define it. Yet it won't let me check if it is undefined because it is telling me it's undefined despite the fact I'm checking for that very reason. Thanks for any response. Hi, I have a button that when you click it displays the results of my db in a div. What I am trying to do is to get the results to update every five seconds. I thought setTimeout was the best way to achieve this. However I am getting the error message that ID is not defined on the setTimeout line. I thought it would automatically input ID into the fields marked ID when the onloadXMLDocRefresh('File.php','txtHint') button is clicked? The button works to load the script, but the refreshing the div is not. My script is: Code: <script type="text/javascript"> function loadXMLDocRefresh(File,ID){ if (window.XMLHttpRequest) { xmlhttp=new XMLHttpRequest(); } else { xmlhttp=new ActiveXObject("Microsoft.XMLHTTP"); } xmlhttp.onreadystatechange=function(){ if (xmlhttp.readyState==4 && xmlhttp.status==200){ document.getElementById(ID).innerHTML=xmlhttp.responseText; timer = setTimeout('loadXMLDocRefresh(File,ID)',5000); } } xmlhttp.open("POST",File,true); xmlhttp.send(); } </script> I'm having trouble figuring out this code. I have a isInitialsTextValid function that checks to see if the user enters their initials in the correct format. Then I have a function checkInitials. In the checkInitials function I am supposed (1)to declare a variable to be used for the boolean value returned by the isInitialsTextValid function.(2)call the isInitialsTextValid function.(3)If the value returned is false, place focus back on initials textbox.(4)If the value return is true call the submit function. I'm not sure what I am doing wrong, but I get a checkInitials is no defined error from firefox and it is pointing to my xhtml file. Here is the relevant code. XHTML FILE Code: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <title>Form Example</title> <script type = "text/javascript" src= "Lab17.js"> </script> </head> <body onload="giveInitFocus();"> <form name = "form1" action = ""> <p> <input type = "button" value = "Total Cost" onClick = "checkInitials();" /> <input type = "reset" value = "Reset Order Form" name = "reset" /> </p> <hr /> <p> Please Enter the Cashier's Initials. </p> <p> <label> Cashier's Initials: <input type = "text" name = "initials" id = "initials" /></label> </p> <p> JAVASCRIPT FILE Code: function isInitialsTextValid() { var init = document.form1.initials; var position = init.value.search(/^[A-Z]{2,3}$/); if(position !=0) { alert("Initials must be 2 or 3 capital letters" + "\n Please re-enter"); return false; } else return true; } function checkInitials() { var returned; isInitialsTextValid(); if(returned == false) { document.form1.initials.focus(); } else if(returned == true) { handleSubmitClick(); } } I have a form where I want certain fields to be visible only if the user clicks a checkbox on the form. Specifically, when Presented_to_Goverment_EntityCheckbox0 is checked, these fields should appear. Code: DropDownList ID="GovEntity" Officials_Last_NameTextBox0 Officials_First_NameTextBox0 Officials_TitleTextBox0 I created two different styles, show below; one makes the fields visible and one hides them Code: <style type="text/css"> .hideit { visibility: hidden; overflow: hidden; position: absolute; } .showit { visibility: visible; overflow: visible; position: static; } </style> Then I surrounded the fields with a div ID'ed as wdiv Code: <div class="hideit" id="wdiv"> Type Government Entity: <asp:TextBox ID="Type_Government_EntityTextBox" runat="server" Text='<%# Bind("Type_Government_Entity") %>' /> <br /> Officials Last Name: <asp:TextBox ID="Officials_Last_NameTextBox" runat="server" style="display:none" Text='<%# Bind("Officials_Last_Name") %>' /> <br /> Officials_First_Name: <asp:TextBox ID="Officials_First_NameTextBox" runat="server" Text='<%# Bind("Officials_First_Name") %>' /> <br /> Officials_Title: <asp:TextBox ID="Officials_TitleTextBox" runat="server" Text='<%# Bind("Officials_Title") %>' /> <br /> </div> I am using the following javascript to change the styles in response to an onclick event. Code: <script language="javascript" type="text/javascript"> function changeDiv(wdiv) { thediv = document.getElementById(wdiv); if(thediv.className == 'hideit'){ thediv.className = 'showit'; } else if (thediv.className == 'showit'){ thediv.className = 'showit'; }} </script> I call the Javascript in this line Code: <asp:CheckBox ID="Presented_to_Goverment_EntityCheckBox" onClick="ChangeDiv(wdiv)" runat="server" /> <br /> However nothing happens when I click the checkbox and if I look in Firefox's error console it says ChangeDiv is not defined. Thanks. i keep getting error Call to undefined function codeandurl() below is my code PHP Code: <?php $value= strip_tags(get_field('link',$post)); $resultid=get_field('resultid',$post); codeandurl($resultid,$value); ?> <div id="result"></div> <script type="text/javascript"> function codeandurl(resultid,url){ $( "#result" ).text(resultid); $( "#result" ).dialog({ modal: true, buttons: { Ok: function() { $( this ).dialog( "close" ); } } }); window.open(url); return false; } </script> Hi, I am looking for some help with function below, the $date variable will for months 01-09 return a value of 1-9 leaving out the 0 numerator Code: function reformatDate($Date) { var $date = $Date; months = ["01", "02", "03", "04", "05", "06", "07", "08", "09", "10", "11", "12"]; var parts = $date.split("/"); var m = parts[0]; for ( var i = 0; i < months.length; i++ ) { if (months[i] == m ) { var month = i; } } $date = parts[2] + "-" + (month+1) + "-" + parts[1]; // +1 needs to be appended to month as JavaScript month starts at 0 _log("Date " + $date); //test date is in correct format return $date; } so in above example if i pass a date 01/02/2015 it will return 2015-1-02 whereas i want it to return 2015-01-02 for the purposes of the function i need the $date to return 01,02,03 etc also can anyone explain why the zero is dropped before each number? Reply With Quote 01-22-2015, 03:39 PM #2 sunfighter View Profile View Forum Posts Senior Coder Join Date Jan 2011 Location Missouri Posts 4,830 Thanks 25 Thanked 672 Times in 671 Posts Problem is he Code: for ( var i = 0; i < months.length; i++ ) { if (months[i] == m ) { var month = i; // YOU SET THIS TO A SINGLE DIGIT. USE var month = months[i]; } Whenever I try to compile a script I wrote, I get the error, "class, interface, or enum expected" and it points to a spot in my script that I don't think should create an error... I've tried changing different things in the line it points to, but it doesn't help. Here's are some of the errors: Code: Code: var it = 0; var udt = new array(10); for(it = 0, it < udt.length, it++){ switch(it){ case 0: udt[it] = prompt("Type a name", ""); case 1: udt[it] = prompt("Type a verb", ""); case 2: udt[it] = prompt("Type an adverb", ""); //case 3: udt[it] = prompt("Type a //case 4: udt[it] = prompt("Type a //case 5: udt[it] = prompt("Type a //case 6: udt[it] = prompt("Type a //case 7: udt[it] = prompt("Type a //case 8: udt[it] = prompt("Type a //case 9: udt[it] = prompt("Type a //case 10: udt[it] = prompt("Type a } } document.write(udt[0] + udt[1] + "away as" + udt[2]); Errors: Code: story.java:1: class, interface, or enum expected var it = 0; ^ story.java:2: class, interface, or enum expected var udt = new array(10); ^ story.java:4: class, interface, or enum expected for(it = 0, it < udt.length, it++){ ^ story.java:17: class, interface, or enum expected } ^ I've looked over the first one and I have no idea why that is an error. If the reason is obvious to you, please be polite. I've only been using javascript for about 2 days. Howdy So i am working on a piece that using local storage and saves them to an un ordered list. I have been using Chrome for the console and inspector abilities and it has been going well. I've tested it before in Safari and Opera and I know it works. However, in Firefox (and IE but I don't care about that) I am getting a console error. Here is the code being executed: Code: var i=0; while (localStorage.key(i) != null) { var values = localStorage.getItem(localStorage.key(i)); values = values.split(";"); $("#logscreen").append("<li class='arrow logname'><a href='#' class='direct' onclick='...'>" + values[0] + "</a></li>"); i++; } There is some jQuery thrown in there but basically it says, test for a localStorage key of i, if it is not null create the list item, add one to i and repeat. I am getting the following error in firefox only: Index or size is negative or greater than the allowed amount" code: "1 [Break on this error] while (localStorage.key(i) != null) Any ideas folks? Hi Coders, I have a javascript function which lets a user to choose one of the 7 option buttons on a "mainsub.asp" page and the page will then be forwarded to one of the 7 process pages depending on what has been chosen. The problem is that firefox is angry with the first line ("if" statement) and tells the following in its error console: Error: document.forms[0].C1 is not a function Source File: [localhost...] Line: 117 Here is the code: function fSubmit(){ if (document.forms[0].C1(0).checked) document.forms[0].action="process.asp"; else if (document.forms[0].C1(1).checked) document.forms[0].action="process1.asp"; else if (document.forms[0].C1(2).checked) document.forms[0].action="process2.asp"; else if (document.forms[0].C1(3).checked) document.forms[0].action="process3.asp"; else if (document.forms[0].C1(4).checked) document.forms[0].action="process4.asp"; else if (document.forms[0].C1(5).checked) document.forms[0].action="process5.asp"; else if (document.forms[0].C1(6).checked) document.forms[0].action="process6.asp"; else document.forms[0].action="process.asp"; return; } Internet explorer does not complain about anything and does its job great. But I could not figure out how to change the code to be also compliant with Firefox? Thanks for all the comments. Please help, I'm getting this error, Object expected, Code: 0 in Internet Explorer (not in Firefox, though). Here is the link to the page: http://www.uatparts.com/miva/merchan...Category_Code= I'm worried that my customers might shy away and not buy from me when they see this error. What do I need to do in order to stop this error from appearing? Note: I tried including the code in this thread but it was too long, the forum wouldn't let me. Hi ,, im trying to access cells in the excel , but when iam using variabel inActiveSheet.Cells(1,k) im getting error "Expected :". Could you please help me. Big Thanks in Advance <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=windows-1250" /> <script> function CreateExcel() { var ExcelSheet; var i=0; var ExcelApp = new ActiveXObject("Excel.Application"); //ExcelSheet = new ActiveXObject("Excel.Sheet"); //ExcelSheet.Application.Visible = true; //ExcelSheet.ActiveSheet.Cells(1,1).Value = "C11"; //ExcelSheet.ActiveSheet.Cells(1,2).Value = "C12"; //ExcelSheet.SaveAs("C:\\Book1.xls"); ExcelApp.Visible = false; var i=1; for(i=0;i<10;i++) { var k=i; document.write(ExcelApp.Workbooks.Open("C:\\wiki estimation.xls").ActiveSheet.Cells(1,k).Value); } ExcelApp.Quit(); //ExcelSheet.Application.Quit(); } </script> <input type=button name=mybutton value=ExcelSheet onclick="CreateExcel()"> </head> <body> </body> </html> |