JavaScript - Error File Is Not Defined
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> Similar TutorialsHi, 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');" > 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! 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. 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. 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> 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. 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. Hi, I'm trying to call a Js function from a test.js located in a HTML file. I'm getting error message "Object has no method..." in Chrome. But no issues are seen in Firefox. Can any one please let me know how i can fix this. <html> <head> .... .... .... <div> <html> <head> <script src="test.js"></script> <script> function aFunc() { alert ("Inside aFunc"); } </script> </head> <body> </html> .... .... .... </div> </head> </html> test.js function bFunc () { aFunc (); } 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> Hello 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 I am recieving an error of Access Denied in a HTA file when the self.ResizeTo is called in the following code on Line 59 any help would be great. <html> <title>Personal Folder Creator</title> <HTA:APPLICATION ID="objPersonalFolderCreator" APPLICATIONNAME="PersonalFolderCreator" WINDOWSTATE="normal" > <head> <style> BODY { font-family: verdana; font-size: 8pt; } H2 { color: blue; } .Table { font-size: 10pt; border-width: thin; border-style: solid; padding: 10px; } .ResultsTable { border-width: thin; border-style: solid; font-size: 8pt; } </style> '******************************************************************** '* BEGIN_SCRIPT '******************************************************************** <script language="vbscript"> Option Explicit Dim objShell, objFSO Dim strServer, strPath strServer = "TWB-FLS-PR-01" strPath = "Personal" Sub Window_Onload Set objShell = CreateObject("WScript.Shell") Set objFSO = CreateObject("Scripting.FileSystemObject") ParentFolder.Disabled = True SubmitButton.Disabled = True PopulateParentFolders self.Focus() self.ResizeTo 720,410 UserID.Focus() End Sub Sub PopulateParentFolders Dim objFolder, objTempFolder, strTempPath strTempPath = "\\" & strServer & "\" & strPath Set objFolder = objFSO.GetFolder(strTempPath) For Each objTempFolder In objFolder.SubFolders Dim objoption Set objOption = Document.CreateElement("OPTION") objOption.Text = objTempFolder.Name objOption.Value = objTempFolder.Name ParentFolder.Add(objOption) Next End Sub Sub LookupButton_OnClick() Dim objUser Set objUser = GetObject("WinNT://PRDS/" & UserID.Value) lblUserName.innerText = objUser.FullName If InStr(lblUserName.innerText, "(") > 0 Then lblSubFolder.innerText = Mid(lblUserName.innerText, 1, InStr(lblUserName.innerText, "(") - 1) ElseIf InStr(lblUserName.innerText, "[") > 0 Then lblSubFolder.innerText = Mid(lblUserName.innerText, 1, InStr(lblUserName.innerText, "[") - 1) End If ParentFolder.Disabled = False SubmitButton.Disabled = False LookupButton.Disabled = True UserID.Disabled = True lblStatus.innerHTML = "Select Parent Folder - DEFAULT is PERSONAL." End Sub Sub SubmitButton_OnClick() Dim strCommand Dim intReturn If objFSO.FolderExists(lblTargetFolder.innerText) Then MsgBox "Folder Already Exists!", vbExclamation lblStatus.innerHTML = "<font color='red'>Folder Already Exists.</font>" Exit Sub Else If MsgBox("Create the Personal Folder:" & vbNewLine & lblTargetFolder.innerText, vbYesNo + vbQuestion) = vbNo Then Exit Sub End If End If objFSO.CreateFolder(lblTargetFolder.innerText) strCommand = "SUBINACL /file """ & lblTargetFolder.innerText & """ /perm /grant=Administrators=F /grant=SYSTEM=F /grant=PRDS\sor-A-Admins=F /grant=PRDS\" & UserID.Value & "=C /setowner=Administrators" intReturn = objShell.Run(strCommand, 7, True) If intReturn <> 0 Then MsgBox "Error modifying permissions on folder: " & lblTargetFolder.innerText,vbExclamation Else SubmitButton.Disabled = True ParentFolder.Disabled = True MsgBox "Personal Folder Created and Permissions have been set accordingly." & vbNewLine & "Advise Customer the Path to their Personal Folder.", vbInformation lblStatus.innerHTML = "<font color='green'>Folder Created Successfully.</font>" End If End Sub Sub ResetButton_OnClick() ParentFolder.Disabled = True SubmitButton.Disabled = True LookupButton.Disabled = False UserID.Disabled = False ParentFolder.Value = "NUL" lblUserName.innerText = "" lblSubFolder.innerText = "" lblTargetFolder.innerText = "" UserID.Value = "" UserID.Focus() lblStatus.innerHTML = "Enter User ID and Click Lookup." End Sub Sub ParentFolder_OnChange() If ParentFolder.Value = "NUL" Then lblTargetFolder.innerText = "" lblStatus.innerHTML = "Select Parent Folder." Else lblTargetFolder.innerText = "\\" & strServer & "\" & strPath & "\" & ParentFolder.Value & "\" & lblSubFolder.innerText lblStatus.innerHTML = "Ready to Create Folder." End If End Sub </script> '**************************************************************************** '* END_SCRIPT '**************************************************************************** </head> '**************************************************************************** '* HTML Section '**************************************************************************** <body> <h2 align="center">Personal Folder Creator - TWB-FLS-PR-01</h2> <table id='tblInput' class='Table' width="670"> <tr><td><b>User ID: </b></td><td rowspan="2"><input type='text' name='UserID' size='10'><button name='LookupButton'>Lookup</button> <p><select name='ParentFolder'><option value='NUL'>Select</option></select></td> <td rowspan="2"> </td><td rowspan="2" width="324"> <img border="0" src="http://sor-app-pr-01:78/_layouts/images/IT_support.gif" width="324" height="103"></td></tr> <tr><td><b>Parent Folder: </b></td></tr> </table> <br/> <table id='tblSummary' class='Table' width="670"> <tr><td><b>User Name: </b></td><td><div id='lblUserName'> </div></td></tr> <tr><td><b>Personal Folder: </b></td><td><div id='lblSubFolder'> </div></td></tr> <tr><td width='15%'><b>Target Folder: </b></td><td width='85%'><div id='lblTargetFolder'></div></td></tr> <tr><td><b><font color="#FF0000">Status:</font> </b></td><td><font color='red'><div id='lblStatus'>Enter User ID and Click Lookup.</div></font></td></tr> </table> <br/> <div align="left"> <table id='tblButtons' class='Table' style="border-style: solid"> <tr><td> <p align="center"><button name='SubmitButton'> <p align="left">Create Folder</button></td><td> <p align="center"><button name='ResetButton'>Reset</button></td><td> <p align="center"><button name='ExitButton' onClick='self.Close()'>Exit</button></td></tr> </table> </div> <br/> Version 1.1(SOR) : Last Modified 11-08-2008 by Steve Dudley : ITO SOR <br/> Version 1.0 : Created on 04-01-07 by Adam Rutt : ISB DTSG </body> </html> Hi I'm reading a text file, manipulating the string that I've read, and then writing to a new text file called temp. The error that I am getting is basically reading past the end of the file. function SpaceFileEntries() { fso = new ActiveXObject("Scripting.FileSystemObject"); filename = "NDELPROF.txt"; path1 = document.getElementById("lblDataOutputDirectory").innerText + "\\" + filename; path2 = document.getElementById("lblDataOutputDirectory").innerText + "\\temp.txt"; s = fso.OpenTextFile(path1); j = fso.CreateTextFile(path2 , true); do { text = s.readLine(); partOne = text.substring(0,34); lastPart = text.substring(35, 54); space = " "; j.write(partOne); j.write(space); j.writeline(lastPart); } while ( text != null ) s.Close(); j.Close(); } Can someone please help me find this bug in the code. I know it's got to do with the while statement, but can't think or find good alternatives. Thanks. Daniel Hi I have written the following code to read contents of a text file using FileReader object of HTML 5 for Google Chrome. Quote: <script> function handle_files(files) { var i; if (checkBrowser("Chrome")) { for (i = 0; i < files.length; i++) { file = files[i]; var reader = new FileReader(); ret = []; reader.onload = function (e) { console.log(e.target.result) } reader.onerror = function (stuff) { console.log("error", stuff) console.log(stuff.getMessage()) } text = reader.readAsText(file[i]); alert(text); } } } </script> ---------------------- <input type="file" multiple="multiple" onchange="handle_files(this.files)"> Unfortunately, the variable text always displays as undefined. Everything above the line text = reader.readAsText(file[0]); works fine. How can I fix it?. Or is there any other solution to read a text file using HTML5/JavaScript on Chrome? Thanks in advance. JavaScript: Code: function test() { alert('dsd'); } HTML: Code: <a href="#" onClick="test()">Test Link</a> JS Error: Code: Error ``ReferenceError: test is not defined'' [x-] in file ``file:///C:/Users/Martyn%20Ball/Desktop/test.php#'', line 1, character 0. Okay wtf. I am writing a greasemonkey userscript that simply just takes the underlying width of a td tag, and prints the text in white font over the table so it is viewable to everyone. I wrote the following code Code: function main() { var page = document.getElementById("container"); var td = page.getElementsByTagName("td"); for(i=0; i<td.length; i++) { if(td[i].background-color != "") { td[i].style.color = "#ffffff"; td[i].innerHTML = td[i].width; } } } however, When i installed the script.. firefox tells me that "color" is not defined. Is there another way of doing this? Just wanting the width is white font. Here is my function: Code: function mod_selection(val1,val2) { if( -1 != navigator.userAgent.indexOf ("MSIE") ) { var range = document.selection.createRange(); var stored_range = range.duplicate(); if(stored_range.length > 0) { stored_range.moveToElementText(textArea); stored_range.setEndPoint('EndToEnd', range); textArea.selectionStart = stored_range.text.length - range.text.length; textArea.selectionEnd = textArea.selectionStart + range.text.length; } alert('hi'); // Get the text area var textArea = $("#text_edit"); textArea.hover(function() {alert('hi');}) // Do we even have a selection? if (typeof(textArea.selectionStart) != "undefined") { // Split the text in three pieces - the selection, and what comes before and after. var begin = textArea.value.substr(0, textArea.selectionStart); var selection = textArea.value.substr(textArea.selectionStart, textArea.selectionEnd - textArea.selectionStart); var end = textArea.value.substr(textArea.selectionEnd); // Insert the tags between the three pieces of text. textArea.value = begin + val1 + selection + val2 + end; } } } Basically what it does is insert BBCode tags for whatever text you have highlighted. Here is my HTML for it: Code: <div class="two-row"> <label>Content: </label> <a href="#" onclick="mod_selection('','');return false;">B</a> <input type="button" value="I" onclick="mod_selection('','')" /> <input type="button" value="U" onclick="mod_selection('','')" /><br /> <textarea id="text_edit" name="body" rows="25" cols="51"><?php if(isset($_POST['submit']) || isset($_POST['preview'])) { echo $_POST['body']; }else { echo $news_body; } ?></textarea> </div> It says the mod_selection is not defined. I'm doing alert('hi'); for testing purposes and it won't print hi.. sooooo I feel like I need a second pair of eyes. I want it to at least recognize the function before I debug it any further. |