JavaScript - Chinese Flashcard Dhtml App (utf8 Problem)
*** This is FireFox Code - it will not work in IE***
i'm trying to finish up this Chinese Flashcard App (i need to cram for my HSK test). The problem is, whenever i try to load a UTF8 file (has chinese characters in it) i get the following error: "utf8str is null" it is trying to load a file from the C:\ directory. The file is there. If it wasn't there, it wouldn't show up in the directory listing of my app's file browser. since i have the HTML and JS in 4 different files, i uploaded them as a single RAR file to a file sharing website. I'll also post the code he http://www.2shared.com/file/11421487...83b/Final.html any suggestions would be greatly appreciated! main HTML file Code: // Set Global Variables var ChineseCard = new Array(); var PinYinCard = new Array(); var EnglishCard = new Array(); var Records = new Array(); var Know = 0; var DontKnow = 0; var CurrentCard = 0; var NumberOfCards = 0; //var DataFile; var Directory = "C:\\"; var Delimeter = ","; function ClickShowPinYin() { document.getElementById("PinYin").value = PinYinCard[CurrentCard]; } function ClickShowEnglish() { document.getElementById("English").value = EnglishCard[CurrentCard]; } function ClickKnow() { Know = Know + 1; if(CurrentCard == NumberOfCards) { // Display the score alert("You scored " + Know + " out of " + NumberOfCards -1); CurrentCard = 0; Know = 0; DontKnow = 0; // clear all textboxes and put index(0) chinese character into the chinese character textbox } CurrentCard = CurrentCard + 1; document.getElementById("PinYin").value = ""; document.getElementById("English").value = ""; document.getElementById("ChineseCharacter").value = ChineseCard[CurrentCard]; } function ClickDontKnow() { DontKnow = DontKnow + 1 if(CurrentCard == NumberOfCards) { // Display the score alert("You scored " + Know + " out of " + NumberOfCards -1); CurrentCard = 0; Know = 0; DontKnow = 0; // clear all textboxes and put index(0) chinese character into the chinese character textbox } CurrentCard = CurrentCard + 1; document.getElementById("PinYin").value = ""; document.getElementById("English").value = ""; document.getElementById("ChineseCharacter").value = ChineseCard[CurrentCard]; } function ClearEditor() { // Clear all the text boxes in the editor document.getElementById("EditChinese").value = ""; document.getElementById("EditPinYin").value = ""; document.getElementById("EditEnglish").value = ""; } function WriteData() { // Conicate the Record data var WriteData = document.getElementById("EditChinese").value + Delimeter + document.getElementById("EditPinYin").value + Delimeter + document.getElementById("EditEnglish").value + Delimeter + "\r"; // Load the data file's current contents var OldData = LoadFromDisk(DataFile); if (OldData == null) { var WriteDataUTF8 = utf8Encode(WriteData); // The file was blank, so don't try to append null content data SaveToDisk(DataFile, WriteDataUTF8 + "\n"); } else { var OldDataUTF8 = utf8Decode(OldData); var AppendData = OldDataUTF8 + WriteData + "\n"; var UTF8data = utf8Encode(AppendData) // Write the data to the file SaveToDisk(DataFile, UTF8data); } // Clear the TextBoxes to prepare for the next entry ClearEditor(); } function LoadFlashCard(DataFile) { // Hide the file browser document.getElementById("FileBrowser").style.visibility = "hidden"; // Show the Flashcard Player DIV and load the current flashcard datafile document.getElementById("FlashCardPlayer").style.visibility = "visible"; // Add the directory path onto the Filename DataFiletmp = Directory + DataFile; DataFile = DataFiletmp; // Load the FlashCard Information from the DataFile into the Arrays var LoadData = LoadFromDisk(DataFile); // Convert the Datafile from UTF8 to ASCII var LoadDataUTF8 = utf8Decode(LoadData); Records = LoadDataUTF8.split(Delimeter); // Load the Elements in to the ChineseText, PinYin, and English Arrays NumberOfCards = (Records.length -1) / 3; // Load the Chinese Characters var Ptr = 0; for (var x = 0; x < NumberOfCards * 3; x = x + 3) { ChineseCard[Ptr] = Records[x]; Ptr++; } Ptr = 0; // Load the PinYin for (var x = 1; x < NumberOfCards * 3; x = x + 3) { PinYinCard[Ptr] = Records[x]; Ptr++; } Ptr = 0; // Load the English for (var x = 2; x < NumberOfCards * 3; x = x + 3) { EnglishCard[Ptr] = Records[x]; Ptr++; } // Load the First Flashcard Showing the Chinese Character First document.getElementById("ChineseCharacter").value = ChineseCard[CurrentCard]; } here's Menu.js Code: function init() { document.getElementById("FlashCardPlayer").style.visibility = "hidden"; document.getElementById("FlashCardEditor").style.visibility = "hidden"; document.getElementById("MainMenu").style.visibility = "visible"; } function ShowPlayer() { document.getElementById("MainMenu").style.visibility = "hidden"; document.getElementById("FlashCardEditor").style.visibility = "hidden"; // Display the File Browse Dialogue to choose a Data File document.getElementById("FileBrowser").style.visibility = "visible"; document.getElementById("FileBrowserToolbar").style.visibility = "visible"; FileBrowser("FileBrowser", Directory); } function ShowEditor() { document.getElementById("FlashCardEditor").style.visibility = "visible"; document.getElementById("FlashCardPlayer").style.visibility = "hidden"; document.getElementById("MainMenu").style.visibility = "hidden"; } function ShowMain() { document.getElementById("MainMenu").style.visibility = "visible"; document.getElementById("FlashCardPlayer").style.visibility = "hidden"; document.getElementById("FlashCardEditor").style.visibility = "hidden"; document.getElementById("FileBrowser").style.visibility = "hidden"; document.getElementById("FileBrowserToolbar").style.visibility = "hidden"; } function FileBrowser(div, Path) { // Get a list of files in the directory var FileList = new Array(); GetFileList(Directory, FileList) // Generate the HTML data for the DIV var HTMLdata; for(var x = 0; x < FileList.length -1; x++) { // Strip the Filename Extension off of the eBook File Name var LableName = FileList[x]; LableName = LableName.replace(Directory, ""); if ( FileList[x].search('csv') > -1) { HTMLdata = HTMLdata + "<input type='button' value='" + LableName + "'" + " onClick=LoadFlashCard('" + FileList[x] + "')><br>"; } } // firefox puts 'undefined' into the first string - for no logical reason // this will remove it HTMLdata = HTMLdata.replace("undefined", ""); // Write the HTML data to the DIV document.getElementById(div).innerHTML = HTMLdata } function FileManager(div, Path) { // Get a list of files in the directory var FileList = new Array(); GetFileList(Directory, FileList) // Generate the HTML data for the DIV var HTMLdata; for(var x = 0; x < FileList.length -1; x++) { // Strip the Filename Extension off of the eBook File Name var LableName = FileList[x]; LableName = LableName.replace(Directory, ""); var FileClass = "<input type='button' value='" + LableName + "'> "; var RenameButton = "<img src='delete.png' onClick='RemoteFile('" + FileList[x] + "');'>" var DeleteButton = "<img src='rename.png' onClick='RenameFile('" + FileList[x] + "');'>" HTMLdata = HTMLdata + FileClass + RenameButton + DeleteButton + "<br>"; } // firefox puts 'undefined' into the first string - for no logical reason // this will remove it HTMLdata = HTMLdata.replace("undefined", ""); // Write the HTML data to the DIV document.getElementById(div).innerHTML = HTMLdata // Hide the Top-Level DIV document.getElementById("MainMenu").style.visibility = "hidden"; document.getElementById("FlashCardEditor").style.visibility = "hidden"; // Display the FileBrowser DIV document.getElementById("FileBrowser").style.visibility = "visible"; document.getElementById("FileBrowserToolbar").style.visibility = "visible"; } function RenameFile(FileName) { // Display the Rename File Dialogue Box document.getElementById("RenameBox").style.visibility = "visible"; // // Reload the Filemanager with updated content FileManager("FileBrowser", Directory); } function RemoveFile(FileName) { // Delete the file from the file system DeleteFile(FileName) alert("File Deleted"); // Reload the Filemanager with updated content FileManager("FileBrowser", Directory); } here's Flashcard.js Code: // Set Global Variables var ChineseCard = new Array(); var PinYinCard = new Array(); var EnglishCard = new Array(); var Records = new Array(); var Know = 0; var DontKnow = 0; var CurrentCard = 0; var NumberOfCards = 0; //var DataFile; var Directory = "C:\\"; var Delimeter = ","; function ClickShowPinYin() { document.getElementById("PinYin").value = PinYinCard[CurrentCard]; } function ClickShowEnglish() { document.getElementById("English").value = EnglishCard[CurrentCard]; } function ClickKnow() { Know = Know + 1; if(CurrentCard == NumberOfCards) { // Display the score alert("You scored " + Know + " out of " + NumberOfCards -1); CurrentCard = 0; Know = 0; DontKnow = 0; // clear all textboxes and put index(0) chinese character into the chinese character textbox } CurrentCard = CurrentCard + 1; document.getElementById("PinYin").value = ""; document.getElementById("English").value = ""; document.getElementById("ChineseCharacter").value = ChineseCard[CurrentCard]; } function ClickDontKnow() { DontKnow = DontKnow + 1 if(CurrentCard == NumberOfCards) { // Display the score alert("You scored " + Know + " out of " + NumberOfCards -1); CurrentCard = 0; Know = 0; DontKnow = 0; // clear all textboxes and put index(0) chinese character into the chinese character textbox } CurrentCard = CurrentCard + 1; document.getElementById("PinYin").value = ""; document.getElementById("English").value = ""; document.getElementById("ChineseCharacter").value = ChineseCard[CurrentCard]; } function ClearEditor() { // Clear all the text boxes in the editor document.getElementById("EditChinese").value = ""; document.getElementById("EditPinYin").value = ""; document.getElementById("EditEnglish").value = ""; } function WriteData() { // Conicate the Record data var WriteData = document.getElementById("EditChinese").value + Delimeter + document.getElementById("EditPinYin").value + Delimeter + document.getElementById("EditEnglish").value + Delimeter + "\r"; // Load the data file's current contents var OldData = LoadFromDisk(DataFile); if (OldData == null) { var WriteDataUTF8 = utf8Encode(WriteData); // The file was blank, so don't try to append null content data SaveToDisk(DataFile, WriteDataUTF8 + "\n"); } else { var OldDataUTF8 = utf8Decode(OldData); var AppendData = OldDataUTF8 + WriteData + "\n"; var UTF8data = utf8Encode(AppendData) // Write the data to the file SaveToDisk(DataFile, UTF8data); } // Clear the TextBoxes to prepare for the next entry ClearEditor(); } function LoadFlashCard(DataFile) { // Hide the file browser document.getElementById("FileBrowser").style.visibility = "hidden"; // Show the Flashcard Player DIV and load the current flashcard datafile document.getElementById("FlashCardPlayer").style.visibility = "visible"; // Add the directory path onto the Filename DataFiletmp = Directory + DataFile; DataFile = DataFiletmp; // Load the FlashCard Information from the DataFile into the Arrays var LoadData = LoadFromDisk(DataFile); // Convert the Datafile from UTF8 to ASCII var LoadDataUTF8 = utf8Decode(LoadData); Records = LoadDataUTF8.split(Delimeter); // Load the Elements in to the ChineseText, PinYin, and English Arrays NumberOfCards = (Records.length -1) / 3; // Load the Chinese Characters var Ptr = 0; for (var x = 0; x < NumberOfCards * 3; x = x + 3) { ChineseCard[Ptr] = Records[x]; Ptr++; } Ptr = 0; // Load the PinYin for (var x = 1; x < NumberOfCards * 3; x = x + 3) { PinYinCard[Ptr] = Records[x]; Ptr++; } Ptr = 0; // Load the English for (var x = 2; x < NumberOfCards * 3; x = x + 3) { EnglishCard[Ptr] = Records[x]; Ptr++; } // Load the First Flashcard Showing the Chinese Character First document.getElementById("ChineseCharacter").value = ChineseCard[CurrentCard]; } here's JSxpcom.js: Code: function SaveToDisk(filepath, content) { try { netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect"); } catch (e) { alert("Permission to save file was denied."); } var file = Components.classes["@mozilla.org/file/local;1"] .createInstance(Components.interfaces.nsILocalFile); file.initWithPath( filepath ); if ( file.exists() == false ) { file.create( Components.interfaces.nsIFile.NORMAL_FILE_TYPE, 420 ); } var outputStream = Components.classes["@mozilla.org/network/file-output-stream;1"] .createInstance( Components.interfaces.nsIFileOutputStream ); outputStream.init( file, 0x04 | 0x08 | 0x20, 420, 0 ); var output = content; var result = outputStream.write( output, output.length ); outputStream.close(); } function LoadFromDisk(filePath) { if(window.Components) try { netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect"); var file = Components.classes["@mozilla.org/file/local;1"].createInstance(Components.interfaces.nsILocalFile); file.initWithPath(filePath); if (!file.exists()) return(null); var inputStream = Components.classes["@mozilla.org/network/file-input-stream;1"].createInstance(Components.interfaces.nsIFileInputStream); inputStream.init(file, 0x01, 00004, null); var sInputStream = Components.classes["@mozilla.org/scriptableinputstream;1"].createInstance(Components.interfaces.nsIScriptableInputStream); sInputStream.init(inputStream); return(sInputStream.read(sInputStream.available())); } catch(e) { //alert("Exception while attempting to load\n\n" + e); return(false); } return(null); } function GetFileList(Directory, FileList) { netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect"); var _nsILocalFile = Components.classes["@mozilla.org/file/local;1"] .createInstance(Components.interfaces.nsILocalFile); // initialize path to work with _nsILocalFile.initWithPath(Directory); // get file interface implemenation // this means that an XPCOM Class can implement multiple interface var lv_oFile = _nsILocalFile.QueryInterface(Components.interfaces.nsIFile); var lv_oEntries = lv_oFile.directoryEntries; while(lv_oEntries.hasMoreElements()) { var lv_cFile = lv_oEntries.getNext() .QueryInterface(Components.interfaces.nsIFile).path; FileList.push(lv_cFile); } } function GetSystemPath(ApplicationName) { // This function should Detect the system directory of the app // and return that string as the SystemPath variable // You must supply the filename of the HTML file that it is being called from // I suppose later i could add the code to detect the HTML's actual file name // It's on the ToDo List... var GetSysPath = self.location; GetSysPath = GetSysPath + ""; Get = GetSysPath.replace("file:///" , ""); Get = Get.replace(/\//g , "\\"); Get = Get.replace(ApplicationName, ""); SystemPath = Get; return SystemPath; } function DeleteFile(FileName) { // Delete a local file netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect"); var aFile = Components.classes["@mozilla.org/file/local;1"].createInstance(); if (aFile instanceof Components.interfaces.nsILocalFile) { aFile.initWithPath(FileName); aFile.remove(false); } } and here is the UTF8.js file: Code: // ***************** The following are the functions for UTF8 *************************** // if these are removed or modified in any way, the foreign language characters might not display correctly or at all // Use utf8Encode(str) to Encode data to UTF8 format // Use utf8Decode(utf8Str) to Decode data to ASCII format //an alias of String.fromCharCode function chr(code) { return String.fromCharCode(code); } //returns utf8 encoded charachter of a unicode value. //code must be a number indicating the Unicode value. //returned value is a string between 1 and 4 charachters. function code2utf(code) { if (code < 128) return chr(code); if (code < 2048) return chr(192+(code>>6)) + chr(128+(code&63)); if (code < 65536) return chr(224+(code>>12)) + chr(128+((code>>6)&63)) + chr(128+(code&63)); if (code < 2097152) return chr(240+(code>>18)) + chr(128+((code>>12)&63)) + chr(128+((code>>6)&63)) + chr(128+(code&63)); } //it is a private function for internal use in utf8Encode function function _utf8Encode(str) { var utf8str = new Array(); for (var i=0; i<str.length; i++) { utf8str[i] = code2utf(str.charCodeAt(i)); } return utf8str.join(''); } //Encodes a unicode string to UTF8 format. function utf8Encode(str) { var utf8str = new Array(); var pos,j = 0; var tmpStr = ''; while ((pos = str.search(/[^\x00-\x7F]/)) != -1) { tmpStr = str.match(/([^\x00-\x7F]+[\x00-\x7F]{0,10})+/)[0]; utf8str[j++] = str.substr(0, pos); utf8str[j++] = _utf8Encode(tmpStr); str = str.substr(pos + tmpStr.length); } utf8str[j++] = str; return utf8str.join(''); } //it is a private function for internal use in utf8Decode function function _utf8Decode(utf8str) { var str = new Array(); var code,code2,code3,code4,j = 0; for (var i=0; i<utf8str.length; ) { code = utf8str.charCodeAt(i++); if (code > 127) code2 = utf8str.charCodeAt(i++); if (code > 223) code3 = utf8str.charCodeAt(i++); if (code > 239) code4 = utf8str.charCodeAt(i++); if (code < 128) str[j++]= chr(code); else if (code < 224) str[j++] = chr(((code-192)<<6) + (code2-128)); else if (code < 240) str[j++] = chr(((code-224)<<12) + ((code2-128)<<6) + (code3-128)); else str[j++] = chr(((code-240)<<18) + ((code2-128)<<12) + ((code3-128)<<6) + (code4-128)); } return str.join(''); } //Decodes a UTF8 formated string function utf8Decode(utf8str) { var str = new Array(); var pos = 0; var tmpStr = ''; var j=0; while ((pos = utf8str.search(/[^\x00-\x7F]/)) != -1) { tmpStr = utf8str.match(/([^\x00-\x7F]+[\x00-\x7F]{0,10})+/)[0]; str[j++]= utf8str.substr(0, pos) + _utf8Decode(tmpStr); utf8str = utf8str.substr(pos + tmpStr.length); } str[j++] = utf8str; return str.join(''); } Similar Tutorialsthis is my DHTML Flashcard App that i'm working on. And it seems to work alright so far. For some reason when i am writing the data to the local disk, it is not writing the UTF8 character correctly. It's just substituting a Comma in it's place. So this is causing a significant problem for displaying chinese language characters in the data file. I am using Notepad++ for writing my code, and when i manually write chinese characters into the code, they display correctly, but it seems to not be working when JavaScript does the writing. Any ideas? here's my code: Code: <html> <head> <meta http-equiv="Content-Type" content="text/html;charset=UTF-8"> <script language="javascript"> // Set Global Variables var Know = 0; var DontKnow = 0; var CurrentCard = 0; var ChineseCard = new Array(); var PinYinCard = new Array(); var EnglishCard = new Array(); var NumberOfCards = 0; var DataFile = "C:" + String.fromCharCode(92) + "FlashCard.txt"; var Delimeter = ","; var EndOfRecordTerminationCharacter = "."; function init() { document.getElementById("FlashCardPlayer").style.visibility = "hidden"; document.getElementById("FlashCardEditor").style.visibility = "hidden"; document.getElementById("MainMenu").style.visibility = "visible"; } function ShowPlayer() { document.getElementById("FlashCardPlayer").style.visibility = "visible"; document.getElementById("MainMenu").style.visibility = "hidden"; document.getElementById("FlashCardEditor").style.visibility = "hidden"; LoadFlashCard(); } function ShowEditor() { document.getElementById("FlashCardEditor").style.visibility = "visible"; document.getElementById("FlashCardPlayer").style.visibility = "hidden"; document.getElementById("MainMenu").style.visibility = "hidden"; } function ShowMain() { document.getElementById("MainMenu").style.visibility = "visible"; document.getElementById("FlashCardPlayer").style.visibility = "hidden"; document.getElementById("FlashCardEditor").style.visibility = "hidden"; } function btnClickShowPinYin() { document.getElementById("PinYin").value = PinYinCard[CurrentCard]; } function btnClickShowEnglish() { document.getElementById("English").value = EnglishCard[CurrentCard]; } function ClearEditor() { // Clear all the text boxes in the editor document.getElementById("EditChinese").value = ""; document.getElementById("EditPinYin").value = ""; document.getElementById("EditEnglish").value = ""; } function WriteDataOld() { // Conicate the Record data var WriteData = document.getElementById("EditChinese").value + Delimeter + document.getElementById("EditPinYin").value + Delimeter + document.getElementById("EditEnglish").value + EndOfRecordTerminationCharacter + "\n"; // Load the data file's current contents var OldData = LoadFromDisk(DataFile); var AppendData = OldData + WriteData + "\n"; // Write the data to the file SaveToDisk(DataFile, AppendData); // Clear the TextBoxes to prepare for the next entry ClearEditor(); } var Records = new Array(); var Elements = new Array(); function WriteData() { // Conicate the Record data var WriteData = document.getElementById("EditChinese").value + Delimeter + document.getElementById("EditPinYin").value + Delimeter + document.getElementById("EditEnglish").value + "\r"; // Load the data file's current contents var OldData = LoadFromDisk(DataFile); if (OldData == null) { // The file was blank, so don't try to append null content data SaveToDisk(DataFile, WriteData + "\n"); } else { var AppendData = OldData + WriteData + "\n"; // Write the data to the file SaveToDisk(DataFile, AppendData); } // Clear the TextBoxes to prepare for the next entry ClearEditor(); } var Records = new Array(); function LoadFlashCard() { // Load the FlashCard Information from the DataFile into the Arrays LoadData = LoadFromDisk(DataFile); Records = LoadData.split(","); // Load the Elements in to the ChineseText, PinYin, and English Arrays NumberOfCards = 3 / Records.length; // Load the Chinese Characters "12, 123, 1234, 12345, 123456, 1234567 var Ptr = 0; for (var x = 0; x < Records.length; x = x + 3) { ChineseCard[Ptr] = Elements[x]; Ptr++; } Ptr = 0; // Load the PinYin for (var x = 1; x < Records.length; x = x + 3) { PinYinCard[Ptr] = Elements[x]; Ptr++; } Ptr = 0; // Load the English for (var x = 2; x < Records.length; x = x + 3) { EnglishCard[Ptr] = Elements[x]; Ptr++; } } function btnClickKnow() { Know = Know + 1; if(CurrentCard == NumberOfCards) { // Display the score alert("You scored " + Know + " out of " + NumberOfCards); CurrentCard = 0; Know = 0; DontKnow = 0; // clear all textboxes and put index(0) chinese character into the chinese character textbox } CurrentCard = CurrentCard + 1; document.getElementById("PinYin").value = ""; document.getElementById("English").value = ""; document.getElementById("ChineseCharacter").value = ChineseCard[CurrentCard]; } function btnClickDontKnow() { DontKnow = DontKnow + 1 if(CurrentCard == NumberOfCards) { // Display the score alert("You scored " + Know + " out of " + NumberOfCards); CurrentCard = 0; Know = 0; DontKnow = 0; // clear all textboxes and put index(0) chinese character into the chinese character textbox } CurrentCard = CurrentCard + 1; document.getElementById("PinYin").value = ""; document.getElementById("English").value = ""; document.getElementById("ChineseCharacter").value = ChineseCard[CurrentCard]; } function SaveToDisk(FileName, Content) { try { netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect"); } catch (e) { alert("Permission to save file was denied."); } var file = Components.classes["@mozilla.org/file/local;1"] .createInstance(Components.interfaces.nsILocalFile); file.initWithPath( FileName ); if ( file.exists() == false ) { file.create( Components.interfaces.nsIFile.NORMAL_FILE_TYPE, 420 ); } var outputStream = Components.classes["@mozilla.org/network/file-output-stream;1"] .createInstance( Components.interfaces.nsIFileOutputStream ); outputStream.init( file, 0x04 | 0x08 | 0x20, 420, 0 ); var output = Content; var result = outputStream.write( output, output.length ); outputStream.close(); } function LoadFromDisk(filePath) { if(window.Components) try { netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect"); var file = Components.classes["@mozilla.org/file/local;1"].createInstance(Components.interfaces.nsILocalFile); file.initWithPath(filePath); if (!file.exists()) return(null); var inputStream = Components.classes["@mozilla.org/network/file-input-stream;1"].createInstance(Components.interfaces.nsIFileInputStream); inputStream.init(file, 0x01, 00004, null); var sInputStream = Components.classes["@mozilla.org/scriptableinputstream;1"].createInstance(Components.interfaces.nsIScriptableInputStream); sInputStream.init(inputStream); return(sInputStream.read(sInputStream.available())); } catch(e) { //alert("Exception while attempting to load\n\n" + e); return(false); } return(null); } </script> </head> <body onload="init()"> <!-- ***************************************** Flash Card Player ***************************************** --> <div id="FlashCardPlayer" style="position: absolute; left: 0px; top: 0px;" > <input id="ChineseCharacter" type="textbox" style="position: absolute; left: 75px; top: 5px; width: 100px; height: 100px; font-size: 35px;"> <input id="PinYin" type="textbox" style="position: absolute; left: 5px; top: 110px; width: 225px;" > <input id="English" type="textbox" style="position: absolute; left: 5px; top: 135px; width: 225px;"> <input type="button" value="Know" style="position: absolute; left: 5px; top: 170px; width: 100px; height: 30px;" onclick="btnClickKnow();"> <input type="button" value="Dont Know" style="position: absolute; left: 125px; top: 170px; width: 100px; height: 30px;" onclick="btnClickDontKnow();"> <input type="button" value="PinYin" style="position: absolute; left: 5px; top: 210px; width: 100px; height: 30px;" onclick="btnClickShowPinYin();"> <input type="button" value="English" style="position: absolute; left: 125px; top: 210px; width: 100px; height: 30px;" onclick="btnClickShowEnglish();"> <a href="" style="position: absolute; left:10px; top: 245px;" onclick="ShowMain();">Home</a> </div> <!-- ****************************************** Flashcard Editor ****************************************** --> <div id="FlashCardEditor" style="position: absolute; left: 0px; top: 0px;"> <input id="EditChinese" style="position: absolute; left: 75px; top: 5px; width: 100px; height: 100px; font-size: 35px;" type="textbox"> <input id="EditPinYin" style="position:absolute; left: 5px; top: 110px; width: 225px;" type="textbox"> <input id="EditEnglish" style="position:absolute; left: 5px; top: 135px; width: 225px;" type="textbox"> <input id="EditClearTextButton" value="Clear" style="position:absolute; left: 5px; top: 180px; width: 100px; height: 30px;" onclick="ClearEditor();" type="button"> <input name="EditOKButton" value="OK" style="position: absolute; left: 125px; top: 180px; width: 100px; height: 30px;" onclick="WriteData();" type="button"> <a href="" style="position: absolute; left:10px; top: 225px;" onclick="javascript:Alert("*sigh* i'm getting to it!");">New</a> <a href="" style="position: absolute; left:10px; top: 245px;" onclick="btnClickShowMain();">Home</a> <br> </div> <!-- ****************************************** Define the Layer for the Main menu ****************************************** --> <div id="MainMenu" style="position: absolute; left: 0px; top: 0px;"> These are the instructions for the Flashcard App. In the future, there should be a score board and a selection of word lists and other such things. However, it's blank for now until i finish this app :) <input value="Study Flashcards" style="position: absolute; left: 50px; top: 170px; width: 120px; height: 30px;" onclick="javascript:ShowPlayer();" type="button"> <input value="Edit Flashcards" style="position: absolute; left: 50px; top: 210px; width: 120px; height: 30px;" onclick="ShowEditor();" type="button"> </div> </body> </html> Hey Guys! I'm new to the site but, I am building a site that has a small area of scrollable text on the page. Basically, my scrollbar is created using layers and styles and it runs an external .js file. It has been working great up until about 6 months ago where it was incompatible in all browsers. I have no idea why. I'm literally pulling out my hair thinking about it. Any help would be nice. The external .js file is below <code> // variables var mouseover = false; var scrolldirection; var scrollratio; var theheartbeat, scrolling; var menuOffsetTop = menuOffsetLeft = menuMaxHeight = 0; var currentX = currentY = 0; var whichIt = null; // events document.onmousedown = grabIt; document.onmousemove = moveIt; document.onmouseup = dropIt; // switch direction scroller will move while pressing a button function switchit(obj, cmd) { if (cmd == 'in') { mouseover = true; if (obj.getAttribute('id') == "scrollup") { scrolldirection = -1; } else { scrolldirection = 1; } } else { mouseover = false; } } function scroll() { if (((scrollbox.style.pixelTop + menuOffsetTop + scrolldirection) >= menuOffsetTop) && ((scrollbox.style.pixelTop + menuOffsetTop + scrolldirection) <= (menuOffsetTop + menuMaxHeight - scrollbox.style.pixelHeight))) { scrollbox.style.pixelTop += scrolldirection; } } function heartBeat() { data.style.pixelTop = -1 * scrollratio * (scrollbox.style.pixelTop + menuOffsetTop - menuOffsetTop); } function grabIt(e) { if (event.button == 1) { if (mouseover) scrolling = window.setInterval("scroll();",1); else { whichIt = event.srcElement; while (whichIt.id.indexOf("scrollbox") == -1) { whichIt = whichIt.parentElement; if (whichIt == null) { return true; } } // whichIt.style.pixelLeft = whichIt.offsetLeft; whichIt.style.pixelTop = whichIt.offsetTop; currentX = (event.clientX + document.body.scrollLeft); currentY = (event.clientY + document.body.scrollTop); } theheartbeat = window.setInterval("heartBeat()",1); } } function moveIt(e) { if (whichIt == null) { return false; } newX = (event.clientX + document.body.scrollLeft); newY = (event.clientY + document.body.scrollTop); distanceX = (newX - currentX); distanceY = (newY - currentY); currentX = newX; currentY = newY; if (((scrollbox.style.pixelTop + menuOffsetTop + distanceY) >= menuOffsetTop) && ((scrollbox.style.pixelTop + menuOffsetTop + distanceY) <= (menuOffsetTop + menuMaxHeight - scrollbox.style.pixelHeight))) { scrollbox.style.pixelTop += distanceY; } event.returnValue = false; return false; } function dropIt() { clearInterval(scrolling); clearInterval(theheartbeat); whichIt = null; } function init() { menuOffsetTop = floater.style.pixelTop; menuMaxHeight = floater.style.pixelHeight; getscrollinc(); } function getscrollinc() { var contentinc; var scrollerinc; var contentHeight = data.offsetHeight; var scrollerHeight = content.style.pixelHeight; if (scrollerHeight < contentHeight) { contentinc = content.style.pixelHeight / contentHeight; scrollerinc = floater.style.pixelHeight*contentinc; scrollratio = contentHeight / floater.style.pixelHeight; } else { scrollerinc = floater.style.pixelHeight; contentinc = 1; } scrollbox.style.height = scrollerinc; } </code> An example of a page I was trying to use it on is (http://desifraternity.org/history.html) Thanks you in advance! Hello all I'm working on a simple feedback form (well not so simple for me) for the last page of my site. In the text area I expect to get normal western text PLUS (or even just) Chinese xharacters my question is how do you validate Chinese character input? low tech I'm back from a web dev hiatus. I'm writing a new site but have found myself a bit rusty. I'm trying to change the visibility of an element with no luck. nothing happens. I'll supply the code. Don't lick the kitten. My js is external. Any non-condescending help is welcome. html Code: <div id="windows"><p>Windows</p> <a name="windowsitem">test1</a> <a>test2</a> </div> javascript a.k.a js (js stands for whispering ponies) Code: function filter() { if ( windowscb.checked==1 ) windowsitem.style.visibility='visible'; else windowsitem.style.visibility='hidden'; } If Ashton Kutcher is reading this, I should be married to Demi Moore. Not you!! I have some code that creates a DHML window, I'll call that code MyDHTMLWin . Now what happens is I create a new MyDHTMLWin object and what happens inside that is it creates an iFrame. Now in my init method I do this.. this.iFrameObj.dhtmlWinObj = this; What I what to do is from inside the file loaded in the iFrame is be able to get the object that opened the window. I did used to do var newWin = new dhtmlWinObj(....); and then parent.newWin.anything() but this is no longer fit for purpose as I reuse this code and the variable names will change. But no matter what I try I just can't seem to get that object that should be stored in the iFrames dhtmlWinObj attribute. I thought it would be this.dhtmlWinObj but that doesn't work How can I get the object that opened my DHTML window??? TIA, Dale sorry if this is in the wrong place, but it does include js and ajax. hi all, ive downloaded the DHTML window script from here : http://www.dynamicdrive.com/dynamici...ndow/index.htm and have it running on my site. i also have a DTHML / ajax chat running on the site which is currently on the main page in an iframe. im trying to put this iframe inside the DHTML window, i have tried all 4 of the window types and for each one i either get the items in the directory or the source code eg if i put the link as test/ i get the list of files in that directory, if i put test/index.php i get <php? source code blah blah ?> it works fine with .html files i assume its because they are .php ? any ideas ? thanks Hey, I am having some difficulties and wondered if anyone could help, i have created a keyboard that works and inputs the values pressed into a text box, i have then tried to expand on this and create a keyboard with multiple layouts that dynamically change when a button is pressed, i have done this by having an iframe within the page and calling the parent function but it will no longer input the text into the textbox. The CSS styling also works in Safari but won't on firefox, any help would be much appreciated Here is my 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"> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> <title>Untitled Document</title> <script type='text/javascript'> function addtotextbox(i) { if(document.getElementById('keyboardsearchbox').value.length==0) var node = document.getElementbyId('keyboard').document.getElementById(i).firstChild.nodeValue else node = document.getElementbyId('keyboard').document.getElementById(i).firstChild.nodeValue.toLowerCase() if(node == "space") document.getElementbyId('keyboard').document.getElementById("keyboardsearchbox").value += " " else document.getElementbyId('keyboard').document.getElementById('keyboardsearchbox').value += node } function resettext() { document.getElementById('keyboardsearchbox').value = "" } function backspace(){ var currentvalue=document.getElementById("keyboardsearchbox").value var newvalue=currentvalue.substr(0,currentvalue.length-1) document.getElementById("keyboardsearchbox").value=newvalue } var keyboardstyle='<html><head><style type="text/css">.orangebox{background-color:#F60;}.keyboard {font-family: Arial, Helvetica, sans-serif;text-align:center;font-size: 25px;font-weight: bold;color: #000;background-color: #F60;}.keyboard:hover {font-family: Arial, Helvetica, sans-serif;text-align:center;font-size: 25px;font-weight: bold;color: #000;background-color: #F90;}body {margin-left: 0px;margin-top: 0px;}.textboxstyle {font-family:Arial, Helvetica, sans-serif;font-size:20px;font-weight:normal;color:#F60;}</style></head><body>' function qwerty(){ var style=keyboardstyle var s= style + '<table width="900" border="1" cellpadding="0" cellspacing="0" class="borderbox"><tr><td><table border="0" cellpadding="0" cellspacing="1"><tr><td width="90" align="center" class="keyboard" id="1" onclick="parent.addtotextbox(this.id)">1</td><td width="90" align="center" class="keyboard" id="2" onclick="parent.addtotextbox(this.id)">2</td><td width="90" align="center" class="keyboard" id="3" onclick="parent.addtotextbox(this.id)">3</td><td width="90" align="center" class="keyboard" id="4" onclick="parent.addtotextbox(this.id)">4</td><td width="90" align="center" class="keyboard" id="5" onclick="parent.addtotextbox(this.id)">5</td><td width="90" align="center" class="keyboard" id="6" onclick="parent.addtotextbox(this.id)">6</td><td width="90" align="center" class="keyboard" id="7" onclick="parent.addtotextbox(this.id)">7</td><td width="90" align="center" class="keyboard" id="8" onclick="parent.addtotextbox(this.id)">8</td><td width="90" align="center" class="keyboard" id="9" onclick="parent.addtotextbox(this.id)">9</td><td width="90" align="center" class="keyboard" id="0" onclick="parent.addtotextbox(this.id)">0</td></tr><tr><td id="q" width="90" align="center" class="keyboard" onclick="parent.addtotextbox(this.id)">Q</td><td id="w" width="90" align="center" class="keyboard" onclick="parent.addtotextbox(this.id)">W</td><td width="90" align="center" class="keyboard" id="e" onclick="parent.addtotextbox(this.id)">E</td><td id="r" width="90" align="center" class="keyboard" onclick="parent.addtotextbox(this.id)">R</td><td id="t" width="90" align="center" class="keyboard" onclick="parent.addtotextbox(this.id)">T</td><td id="y" width="90" align="center" class="keyboard" onclick="parent.addtotextbox(this.id)">Y</td><td id="u" width="90" align="center" class="keyboard" onclick="parent.addtotextbox(this.id)">U</td><td id="i" width="90" align="center" class="keyboard" onclick="parent.addtotextbox(this.id)">I</td><td id="o" width="90" align="center" class="keyboard" onclick="parent.addtotextbox(this.id)">O</td><td id="p" width="90" align="center" class="keyboard" onclick="parent.addtotextbox(this.id)">P</td></tr><tr><td id="space" width="90" rowspan="2" align="center" class="keyboard" onclick="parent.addtotextbox(this.id)">space</td><td id="a" width="90" align="center" class="keyboard" onclick="parent.addtotextbox(this.id)">A</td><td id="s" width="90" align="center" class="keyboard" onclick="parent.addtotextbox(this.id)">S</td><td id="d" width="90" align="center" class="keyboard" onclick="parent.addtotextbox(this.id)">D</td><td id="f" width="90" align="center" class="keyboard" onclick="parent.addtotextbox(this.id)">F</td><td id="g" width="90" align="center" class="keyboard" onclick="parent.addtotextbox(this.id)">G</td><td id="h" width="90" align="center" class="keyboard" onclick="parent.addtotextbox(this.id)">H</td><td id="j" width="90" align="center" class="keyboard" onclick="parent.addtotextbox(this.id)">J</td><td id="k" width="90" align="center" class="keyboard" onclick="parent.addtotextbox(this.id)">K</td><td id="l" width="90" align="center" class="keyboard" onclick="parent.addtotextbox(this.id)">L</td></tr><tr><td align="center" valign="middle" bgcolor="#F60" id="box1"></td><td align="center" valign="middle" bgcolor="#F60" id="box2"></td><td id="z" width="90" align="center" class="keyboard" onclick="parent.addtotextbox(this.id)">Z</td><td id="x" width="90" align="center" class="keyboard" onclick="parent.addtotextbox(this.id)">X</td><td id="c" width="90" align="center" class="keyboard" onclick="parent.addtotextbox(this.id)">C</td><td id="v" width="90" align="center" class="keyboard" onclick="parent.addtotextbox(this.id)">V</td><td id="b" width="90" align="center" class="keyboard" onclick="parent.addtotextbox(this.id)">B</td><td id="n" width="90" align="center" class="keyboard" onclick="parent.addtotextbox(this.id)">N</td><td id="m" width="90" align="center" class="keyboard" onclick="parent.addtotextbox(this.id)">M</td></tr></table></td></tr></table></body></html>' with(document.getElementById('keyboard').contentDocument){ open() write(s) close() } } function dorvak(){ var style=keyboardstyle var s= style + '<table width="900" border="1" cellpadding="0" cellspacing="0" class="borderbox"><tr><td><table border="0" cellpadding="0" cellspacing="1"><tr><td width="90" align="center" class="keyboard" id="1" onclick="parent.addtotextbox(this.id)">1</td><td width="90" align="center" class="keyboard" id="2" onclick="parent.addtotextbox(this.id)">2</td><td width="90" align="center" class="keyboard" id="3" onclick="parent.addtotextbox(this.id)">3</td><td width="90" align="center" class="keyboard" id="4" onclick="parent.addtotextbox(this.id)">4</td><td width="90" align="center" class="keyboard" id="5" onclick="parent.addtotextbox(this.id)">5</td><td width="90" align="center" class="keyboard" id="6" onclick="parent.addtotextbox(this.id)">6</td><td width="90" align="center" class="keyboard" id="7" onclick="parent.addtotextbox(this.id)">7</td><td width="90" align="center" class="keyboard" id="8" onclick="parent.addtotextbox(this.id)">8</td><td width="90" align="center" class="keyboard" id="9" onclick="parent.addtotextbox(this.id)">9</td><td width="90" align="center" class="keyboard" id="0" onclick="parent.addtotextbox(this.id)">0</td></tr><tr><td id="q" width="90" align="center" bgcolor="#F60" > </td><td id="w" width="90" align="center" bgcolor="#F60"> </td><td width="90" align="center" bgcolor="#F60" id="e" > </td><td id="p" width="90" align="center" class="keyboard" onclick="parent.addtotextbox(this.id)">P</td><td id="y" width="90" align="center" class="keyboard" onclick="parent.addtotextbox(this.id)">Y</td><td id="f" width="90" align="center" class="keyboard" onclick="parent.addtotextbox(this.id)">F</td><td id="g" width="90" align="center" class="keyboard" onclick="parent.addtotextbox(this.id)">G</td><td id="c" width="90" align="center" class="keyboard" onclick="parent.addtotextbox(this.id)">C</td><td id="r" width="90" align="center" class="keyboard" onclick="parent.addtotextbox(this.id)">R</td><td id="l" width="90" align="center" class="keyboard" onclick="parent.addtotextbox(this.id)">L</td></tr><tr><td id="a" width="90" align="center" class="keyboard" onclick="parent.addtotextbox(this.id)">A</td><td id="o" width="90" align="center" class="keyboard" onclick="parent.addtotextbox(this.id)">O</td><td id="e" width="90" align="center" class="keyboard" onclick="parent.addtotextbox(this.id)">E</td><td id="u" width="90" align="center" class="keyboard" onclick="parent.addtotextbox(this.id)">U</td><td id="i" width="90" align="center" class="keyboard" onclick="parent.addtotextbox(this.id)">I</td><td id="d" width="90" align="center" class="keyboard" onclick="parent.addtotextbox(this.id)">D</td><td id="h" width="90" align="center" class="keyboard" onclick="parent.addtotextbox(this.id)">H</td><td id="t" width="90" align="center" class="keyboard" onclick="parent.addtotextbox(this.id)">T</td><td id="n" width="90" align="center" class="keyboard" onclick="parent.addtotextbox(this.id)">N</td><td id="s" width="90" align="center" class="keyboard" onclick="parent.addtotextbox(this.id)">S</td></tr><tr><td id="space" width="90" align="center" class="keyboard" onclick="parent.addtotextbox(this.id)">space</td><td id="q" width="90" align="center" class="keyboard" onclick="parent.addtotextbox(this.id)">Q</td><td id="j" width="90" align="center" class="keyboard" onclick="parent.addtotextbox(this.id)">J</td><td id="k" width="90" align="center" class="keyboard" onclick="parent.addtotextbox(this.id)">K</td><td id="x" width="90" align="center" class="keyboard" onclick="parent.addtotextbox(this.id)">X</td><td id="b" width="90" align="center" class="keyboard" onclick="parent.addtotextbox(this.id)">B</td><td id="m" width="90" align="center" class="keyboard" onclick="parent.addtotextbox(this.id)">M</td><td id="w" width="90" align="center" class="keyboard" onclick="parent.addtotextbox(this.id)">W</td><td id="v" width="90" align="center" class="keyboard" onclick="parent.addtotextbox(this.id)">V</td><td id="z" width="90" align="center" class="keyboard" onclick="parent.addtotextbox(this.id)">Z</td></tr></table></td></tr></table></body></html>' with(document.getElementById('keyboard').contentDocument){ open() write(s) close() } } function alphabet(){ var style=keyboardstyle var s= style + '<table width="900" border="1" cellpadding="0" cellspacing="0" class="borderbox"><tr><td><table border="0" cellpadding="0" cellspacing="1"><tr><td width="90" align="center" class="keyboard" id="a" onclick="parent.addtotextbox(this.id)">A</td><td width="90" align="center" class="keyboard" id="b" onclick="parent.addtotextbox(this.id)">B</td><td width="90" align="center" class="keyboard" id="c" onclick="parent.addtotextbox(this.id)">C</td><td width="90" align="center" class="keyboard" id="d" onclick="parent.addtotextbox(this.id)">D</td><td width="90" align="center" class="keyboard" id="e" onclick="parent.addtotextbox(this.id)">E</td><td width="90" align="center" class="keyboard" id="f" onclick="parent.addtotextbox(this.id)">F</td><td width="90" align="center" class="keyboard" id="g" onclick="parent.addtotextbox(this.id)">G</td><td width="90" align="center" class="keyboard" id="h" onclick="parent.addtotextbox(this.id)">H</td><td width="90" align="center" class="keyboard" id="i" onclick="parent.addtotextbox(this.id)">I</td><td width="90" align="center" class="keyboard" id="j" onclick="parent.addtotextbox(this.id)">J</td></tr><tr><td id="k" width="90" align="center" class="keyboard" onclick="parent.addtotextbox(this.id)">K</td><td id="l" width="90" align="center" class="keyboard" onclick="parent.addtotextbox(this.id)">L</td><td width="90" align="center" class="keyboard" id="m" onclick="parent.addtotextbox(this.id)">M</td><td id="n" width="90" align="center" class="keyboard" onclick="parent.addtotextbox(this.id)">N</td><td id="o" width="90" align="center" class="keyboard" onclick="parent.addtotextbox(this.id)">O</td><td id="p" width="90" align="center" class="keyboard" onclick="parent.addtotextbox(this.id)">P</td><td id="q" width="90" align="center" class="keyboard" onclick="parent.addtotextbox(this.id)">Q</td><td id="r" width="90" align="center" class="keyboard" onclick="parent.addtotextbox(this.id)">R</td><td id="s" width="90" align="center" class="keyboard" onclick="parent.addtotextbox(this.id)">S</td><td id="t" width="90" align="center" class="keyboard" onclick="parent.addtotextbox(this.id)">T</td></tr><tr><td id="space" width="90" rowspan="2" align="center" class="keyboard" onclick="parent.addtotextbox(this.id)">space</td><td id="u" width="90" align="center" class="keyboard" onclick="parent.addtotextbox(this.id)">U</td><td id="v" width="90" align="center" class="keyboard" onclick="parent.addtotextbox(this.id)">V</td><td id="w" width="90" align="center" class="keyboard" onclick="parent.addtotextbox(this.id)">W</td><td id="x" width="90" align="center" class="keyboard" onclick="parent.addtotextbox(this.id)">X</td><td id="y" width="90" align="center" class="keyboard" onclick="parent.addtotextbox(this.id)">Y</td><td id="z" width="90" align="center" class="keyboard" onclick="parent.addtotextbox(this.id)">Z</td><td id="z" bgcolor="#F60" width="90" align="center"></td><td id="k" width="90" align="center" bgcolor="#F60" ></td><td id="l" width="90" align="center" class="keyboard" ></td></tr><tr><td align="center" valign="middle" bgcolor="#F60" id="box1"></td><td align="center" valign="middle" bgcolor="#F60" id="box2"></td><td id="z" width="90" align="center" bgcolor="#F60" ></td><td id="x" width="90" align="center" bgcolor="#F60" ></td><td id="c" width="90" align="center" bgcolor="#F60" ></td><td id="v" width="90" align="center" bgcolor="#F60" ></td><td id="b" width="90" align="center" bgcolor="#F60" ></td><td id="n" width="90" align="center" bgcolor="#F60" ></td><td id="m" width="90" align="center" bgcolor="#F60" ></td></tr></table></td></tr></table></body></html>' with(document.getElementById('keyboard').contentDocument){ open() write(s) close() } } </script> <style type="text/css"> .titles { font-family:Arial, Helvetica, sans-serif; text-align:center; font-size:18px; font-weight:bold; color:#F60; background-color:#FFF; } .textboxstyle { font-family:Arial, Helvetica, sans-serif; font-size:20px; font-weight:normal; color:#F60; } .borderbox { border: #666; } .borderboxorange { border:#666; background-color:#F60; } body { margin-left: 0px; margin-top: 0px; } </style> </head> <body> <table width="900" border="1" cellpadding="0" cellspacing="0" class="borderbox"> <tr> <td><table width="900" border="0" cellpadding="0" cellspacing="1"> <tr> <td width="403" height="30" colspan="3" align="center" valign='middle' bgcolor="#F60" id="textbox"><form id="form1"> <input name="keyboardsearchbox" type="text" class="textboxstyle" id="keyboardsearchbox" size="70"/> </form></td> <td width="150" align="center" valign='middle' bgcolor="#F60" id="textbox"><input type="submit" name="reset" id="reset" value=" Reset " onclick="resettext()" /></td> </tr> <tr> <td height="30" align="center" valign='middle' bgcolor="#F60" id="reset"><input type="submit" name="qwerty" id="qwertybutton" value=" Qwerty " onclick="qwerty()" /></td> <td align="center" valign='middle' bgcolor="#F60" id="qwerty"><input type="submit" name="dorvak" id="dorvakbutton" value=" Dorvak " onclick="dorvak()" /></td> <td align="center" valign='middle' bgcolor="#F60" id="dorvak"><input type="submit" name="alphabet" id="alphabetbutton" value=" alphabet " onclick="alphabet()" /></td> <td align="center" valign='middle' bgcolor="#F60" id="alphabet"><input type="submit" name="backspace" id="backspace" value=" backspace " onclick="backspace()" /></td> </tr> <tr> <td height="30" colspan="4" align="center" valign='middle' id="iframe"><iframe id='keyboard' width='900'></iframe></td> </tr> </table></td> </tr> </table> </body> </html> Thanks! Joe Scroll down to the bottom. Click on an "X" button to bring up a DHTML popup. Select an item. When the DHTML closes and the original HTML is updated the browser scrolls to top. Is there a way to stop this by wrapping it somehow in a container, since you can't stop the scroll event?
Code: <html> <head> <title> Vendor Management</title> </head> <body> <table border="0" width="100%"> <tr> <td></td> <td></td> <td></td> </tr> <tr> <td colspan="2" align="left" valign="top"> <img src=""/> </td> <td><img src=""/></td> </tr> <tr> <td align="left" valign="top"> <a href=""/></a> <a href=""/></a> <a href=""/></a> </td> <td align="left"> <img src=""/> </td> <td> <img src=""/> </td> </tr> <tr> <td> <span class="pageHeading" align="left"> Web Administrator </span> </td> </tr> </table> <br/> <form name="form" method="post" action=""> <table width="100%"> <tr> <td width="5%"></td> <td align="left"> <p class="filter"> All<br/> All<br/> </p> </td> <td> <table width="40%" border="1" > <tr> <td class="h" colspan="2">Color Key </td> </tr> <tr> <td class="S "> </td><td class="small">The is being negotiated. The administrator may finalize the when it is complete.</td> </tr> <tr> <td class="SAVA">Awaiting Vendor Approval </td><td class="small">The has been finalized and is waiting for the Vendor to sign it.</td> </tr> <tr> <td class="SLocked">Locked</td><td class="small">The has been finalized and signed. All the Locked items in the will be in the show.</td> </tr> </table> </td> </tr> <tr> <td colspan="3"> <table align="center"> <tr> <td>Search:</td> <td> <input name="searchValue" id = "searchValue" type="text" size="24" value=""> </td> <td> By </td> <td> <select name="searchColumn" id="searchColumn"> <option value="VENDOR_NAME" SELECTED> Vendor Name</option> <option value="VENDOR_NUMBER" > Vendor Number</option> </select> </td> <td> And </td> <td> <select name="searchQualifier" id="searchQualifier"> <option value="CONTAINS" SELECTED>Contains</option> <option value="STARTS_WITH" >Starts With</option> <option value="ENDS_WITH" >Ends With</option> </select> </td> <td> <input type="button" name="SearchButton" id="SearchButton" value="Search" onClick="onVendorSearch()"> </td> <td> <input type="button" name="ClearSearchButton" id="ClearSearchButton" value="Clear" onClick="onVendorClear()"> </td> </tr> </table> </td> </table> <table width="90%" align="center" > <tr align="center"> <td colspan="3"> <br> <input name="reference" type="hidden" value="viewVendorUsersCheck"> <input name="action" type="hidden" value="delete"> </td> </tr> </table> <table id="results" width="100%" border="1" style="border-color:black" align="left"> <!-- START OF DATA --> <tr class="S "> <td> <a name="">005890</a></td> <td> Ivy-Dry, Inc</td> <td> </td> <td> </td> <td> <table> <tr> <td> <input type="text" id="vendorBooth_005890" name="vendorBooth_005890" readonly title="" /> </td> <td> <input type="button" value="X" name="vendorBoothBtn_005890" id="vendorBoothBtn_005890" onclick="DCCshowBoothList(this.id)" </td> </tr> </table> <td> <a href=""> </a> </td> <td>8</td> <td>0</td> <td>0</td> <td></td> <td>20141</td> <td></td> <td></td> <td></td> </tr> <tr class="S "> <td> <a name="006867">006867</a></td> <td> Pacific World Corporation</td> <td> </td> <td> </td> <td> <table> <tr> <td> <input type="text" id="vendorBooth_006867" name="vendorBooth_006867" readonly title="" /> </td> <td> <input type="button" value="X" name="vendorBoothBtn_006867" id="vendorBoothBtn_006867" onclick="DCCshowBoothList(this.id)" </td> </tr> </table> <td>0</td> <td>0</td> <td>0</td> <td></td> <td>20154</td> <td></td> <td></td> <td></td> </tr> <tr class="S "> <td> <a name="">006952</a></td> <td> Prince Of Peace Enterprises</td> <td></td> <td></td> <td> <table> <tr> <td> <input type="text" id="vendorBooth_006952" name="vendorBooth_006952" readonly title="" /> </td> <td> <input type="button" value="X" name="vendorBoothBtn_006952" id="vendorBoothBtn_006952" onclick="DCCshowBoothList(this.id)" </td> </tr> </table> <td>0</td> <td>0</td> <td>0</td> <td></td> <td>20155</td> <td></td> <td></td> <td></td> <td></td> </tr> <tr class="S "> <td> <a name="">006996</a></td> <td> Bayer , Division</td> <td></td> <td></td> <td> <table> <tr> <td> <input type="text" id="vendorBooth_006996" name="vendorBooth_006996" readonly title="" /> </td> <td> <input type="button" value="X" name="vendorBoothBtn_006996" id="vendorBoothBtn_006996" onclick="DCCshowBoothList(this.id)" </td> </tr> </table> <td>21</td> <td>0</td> <td>0</td> <td></td> <td>20156</td> <td></td> <td></td> <td></td> <td></td> </tr> <tr class="S "> <td> <a name="">007003</a></td> <td> Kerr Group, Inc. / Kerr </td> <td></td> <td></td> <td> <table> <tr> <td> <input type="text" id="vendorBooth_007003" name="vendorBooth_007003" readonly title="" /> </td> <td> <input type="button" value="X" name="vendorBoothBtn_007003" id="vendorBoothBtn_007003" onclick="DCCshowBoothList(this.id)" </td> </tr> </table> <td>92</td> <td>0</td> <td>0</td> <td></td> <td>20157</td> <td></td> <td></td> <td></td> </tr> <tr class="S "> <td> <a name="">007010</a></td> <td> Unilever</td> <td></td> <td></td> <td> <table> <tr> <td> <input type="text" id="vendorBooth_007010" name="vendorBooth_007010" readonly title="" /> </td> <td> <input type="button" value="X" name="vendorBoothBtn_007010" id="vendorBoothBtn_007010" onclick="DCCshowBoothList(this.id)" </td> </tr> </table> <td>160</td> <td>0</td> <td>0</td> <td></td> <td>20158</td> <td></td> <td></td> <td></td> </tr> <tr class="S "> <td> <a name="">007057</a></td> <td> Pfizer </td> <td></td> <td></td> <td> <table> <tr> <td> <input type="text" id="vendorBooth_007057" name="vendorBooth_007057" readonly title="" /> </td> <td> <input type="button" value="X" name="vendorBoothBtn_007057" id="vendorBoothBtn_007057" onclick="DCCshowBoothList(this.id)" </td> </tr> </table> <td>9</td> <td>0</td> <td>0</td> <td></td> <td>20159</td> <td></td> <td></td> <td></td> </tr> <tr class="S "> <td> <a name="">007060</a></td> <td> Johnson & </td> <td></td> <td></td> <td> <table> <tr> <td> <input type="text" id="vendorBooth_007060" name="vendorBooth_007060" readonly title="" /> </td> <td> <input type="button" value="X" name="vendorBoothBtn_007060" id="vendorBoothBtn_007060" onclick="DCCshowBoothList(this.id)" </td> </tr> </table> <td>71</td> <td>0</td> <td>0</td> <td></td> <td>20160</td> <td></td> <td></td> <td></td> </tr> <tr class="S "> <td> <a name="">007112</a></td> <td> Colgate-Palmolive </td> <td></td> <td></td> <td> <table> <tr> <td> <input type="text" id="vendorBooth_007112" name="vendorBooth_007112" readonly title="" /> </td> <td> <input type="button" value="X" name="vendorBoothBtn_007112" id="vendorBoothBtn_007112" onclick="DCCshowBoothList(this.id)" </td> </tr> </table> <td>39</td> <td>0</td> <td>0</td> <td></td> <td></td> <td></td> <td></td> <td></td> </tr> <tr class="S "> <td> <a name="">007120</a></td> <td> W.F. Young, </td> <td></td> <td></td> <td> <table> <tr> <td> <input type="text" id="vendorBooth_007120" name="vendorBooth_007120" readonly title="" /> </td> <td> <input type="button" value="X" name="vendorBoothBtn_007120" id="vendorBoothBtn_007120" onclick="DCCshowBoothList(this.id)" </td> </tr> </table> <td>0</td> <td>0</td> <td>0</td> <td></td> <td>20162</td> <td></td> <td></td> <td></td> </tr> <tr class="S "> <td> <a name="">007120</a></td> <td> W.F. Young, </td> <td></td> <td></td> <td> <table> <tr> <td> <input type="text" id="vendorBooth_007120" name="vendorBooth_007120" readonly title="" /> </td> <td> <input type="button" value="X" name="vendorBoothBtn_007120" id="vendorBoothBtn_007120" onclick="DCCshowBoothList(this.id)" </td> </tr> </table> <td> <a href=""> </a> </td> <td>0</td> <td>0</td> <td>0</td> <td></td> <td>20162</td> <td></td> <td></td> <td></td> </tr> <tr class="S "> <td> <a name="">007120</a></td> <td> W.F. Young, </td> <td></td> <td></td> <td> <table> <tr> <td> <input type="text" id="vendorBooth_007120" name="vendorBooth_007120" readonly title="" /> </td> <td> <input type="button" value="X" name="vendorBoothBtn_007120" id="vendorBoothBtn_007120" onclick="DCCshowBoothList(this.id)" </td> </tr> </table> <td>0</td> <td>0</td> <td>0</td> <td></td> <td>20162</td> <td></td> <td></td> <td></td> </tr> <tr class="S "> <td> <a name="">007120</a></td> <td> W.F. Young, </td> <td></td> <td></td> <td> <table> <tr> <td> <input type="text" id="vendorBooth_007120" name="vendorBooth_007120" readonly title="" /> </td> <td> <input type="button" value="X" name="vendorBoothBtn_007120" id="vendorBoothBtn_007120" onclick="DCCshowBoothList(this.id)" </td> </tr> </table> <td> </td> <td>0</td> <td>0</td> <td>0</td> <td></td> <td></td> <td> </td> <td> </td> <td> </td> <td></td> </tr> <tr class="S "> <td> <a name="">007167</a></td> <td> 3M </td> <td></td> <td></td> <td> <table> <tr> <td> <input type="text" id="vendorBooth_007167" name="vendorBooth_007167" readonly title="" /> </td> <td> <input type="button" value="X" name="vendorBoothBtn_007167" id="vendorBoothBtn_007167" onclick="DCCshowBoothList(this.id)" </td> </tr> </table> <td>0</td> <td>0</td> <td>0</td> <td></td> <td>20163</td> <td></td> <td></td> <td></td> <td></td> </tr> <tr class="S "> <td> <a name="008877">008877</a></td> <td> x Brands</td> <td></td> <td></td> <td> <table> <tr> <td> <input type="text" id="vendorBooth_008877" name="vendorBooth_008877" readonly title="" /> </td> <td> <input type="button" value="X" name="vendorBoothBtn_008877" id="vendorBoothBtn_008877" onclick="DCCshowBoothList(this.id)" </td> </tr> </table> <td>3</td> <td>0</td> <td>0</td> <td></td> <td>20168</td> <td></td> <td></td> <td></td> </tr> <tr align="center" bgcolor="9999FF" class="e"> <td></td> </tr> <tr bgcolor="9999FF" class="h"> <td colspan="11" class="h"> Vendor Users and s: </td> <td class="h" align="center"><input type="submit" name="Submit" value="Submit"></td> <td colspan="4" class="h"></td> </tr> </table> <script type="text/javascript"> window.onload = function () { DCCinitPage(); }; function DCCinitPage() { var IE = document.all?true:false; if (!IE) document.captureEvents(Event.MOUSEDOWN); document.onmousedown = DCCmousePosition; } function DCCmousePosition(e) { var IE = document.all?true:false; var tempX = 0; var tempY = 0; if (IE) { tempX = event.clientX + document.body.scrollLeft; tempY = event.clientY + document.body.scrollTop; } else { tempX = e.pageX; tempY = e.pageY; } if (tempX < 0){tempX = 0;} if (tempY < 0){tempY = 0;} DCCmouse.setLeft(tempX); DCCmouse.setTop(tempY); return true; } function DCCmouseClass() { this.left = 0; this.top = 0; this.setLeft = function (left) { this.left = left; } this.getLeft = function() { return this.left; } this.setTop = function (top) { this.top = top; } this.getTop = function() { return this.top; } } var DCCmouse = new DCCmouseClass(); function DCCshowBoothList(thisId) { var indexOfNumber = thisId.indexOf("vendorBoothBtn_"); var thisNumber = thisId.substring(indexOfNumber + 15); document.forms[0].tempVendorNumber.value = thisNumber; document.getElementById("DCCboothList").style.top = (DCCgetWindowTop() + 20) + "px"; document.getElementById("DCCboothList").style.left = (DCCmouse.getLeft() + 15) + "px"; document.getElementById("DCCboothList").style.display=""; } function DCCcloseBoothList() { document.getElementById("DCCboothList").style.display="none"; } function DCCboothSelected(boothId) { document.getElementById("DCCboothList").style.display="none"; var indexOfNumber = boothId.indexOf("boothNumber_"); var indexOfIndex = boothId.indexOf("index_"); var indexOfName = boothId.indexOf("name_"); var boothNumber = boothId.substring(indexOfNumber + 12, indexOfIndex); var boothIndex = boothId.substring(indexOfIndex + 6, indexOfName); var boothName = boothId.substring(indexOfName + 5); var vendorNumber = document.getElementById("tempVendorNumber").value; var displayBoothNumber = "vendorBooth_" + vendorNumber; document.getElementById(displayBoothNumber).value = boothNumber; document.getElementById(displayBoothNumber).name = displayBoothNumber + "_dirty"; document.getElementById(displayBoothNumber).title = boothName; } function DCCgetWindowTop() { var winTop = 0; if( typeof( window.pageYOffset ) == 'number' ) { winTop = window.pageYOffset; } else if( document.body && ( document.body.scrollLeft || document.body.scrollTop ) ) { winTop = document.body.scrollTop; } else if( document.documentElement && ( document.documentElement.scrollLeft || document.documentElement.scrollTop ) ) { winTop = document.documentElement.scrollTop; } return winTop; } function DCCgetWindowLeft() { var winLeft = 0; if( typeof( window.pageXOffset ) == 'number' ) { winLeft = window.pageXOffset; } else if( document.body && ( document.body.scrollLeft || document.body.scrollTop ) ) { winLeft = document.body.scrollLeft; } else if( document.documentElement && ( document.documentElement.scrollLeft || document.documentElement.scrollTop ) ) { winLeft = document.documentElement.scrollLeft; } return winLeft; } </script> <style> .DCChiglightHover:hover { background-color: rgb(200,200,200); } </style> <div id="DCCboothList" style=" position: absolute; top: 200px; left: 350px; height: 360px; width: 300px; background-image: url(/DCC5/pages/shared/images/transp.gif); display: none; "> <input type="hidden" name="tempVendorNumber" id="tempVendorNumber" value="" /> <p align="right" style="padding: 0; margin: 0;"> <input style="height: 18px; width: 20px; background-image: url(dummy.gif); border-top: 1px solid rgb(210,210,210); border-left: 1px solid rgb(210,210,210); border-right: 1px solid rgb(210,210,210); border-top: 0px solid rgb(210,210,210); color: rgb(210,0,0);" type="button" id="closeBoothList" name="closeBoothList" value ="X" onclick="DCCcloseBoothList()" /> </p> <div id="DCCboothListInner" style="background: rgb(240,240,240); border: 1px solid rgb(130,130,130); height: 334px; overflow: auto; "> <p style="padding: 0; margin: 0"> <a href="" class="DCChiglightHover" id="boothNumber_D010index_0name_Beef Booth" style="text-decoration: none; color: black;" onclick="DCCboothSelected(this.id)">D010Beef Booth</a> </p> <p style="padding: 0; margin: 0"> <a href="" class="DCChiglightHover" id="boothNumber_D006index_1name_DCC Test Booth D006" style="text-decoration: none; color: black;" onclick="DCCboothSelected(this.id)">D006DCC Test Booth D006</a> </p> <p style="padding: 0; margin: 0"> <a href="" class="DCChiglightHover" id="boothNumber_D005index_2name_DCC Test Booth D005" style="text-decoration: none; color: black;" onclick="DCCboothSelected(this.id)">D005DCC Test Booth D005</a> </p> <p style="padding: 0; margin: 0"> <a href="" class="DCChiglightHover" id="boothNumber_D004index_3name_DCC Test Booth D004" style="text-decoration: none; color: black;" onclick="DCCboothSelected(this.id)">D004DCC Test Booth D004</a> </p> <p style="padding: 0; margin: 0"> <a href="" class="DCChiglightHover" id="boothNumber_269index_92name_ARCHTECH" style="text-decoration: none; color: black;" onclick="DCCboothSelected(this.id)">269ARCHTECH</a> </p> </div> </div> <!-- End code for custom booth list drop down --> </form> </body> </html> NOTE: If you are tempted to respond "validate your code" or some other useless response, save your breath. This is a real world problem. The code is an fragment output from a JSP. I don't have the luxury of updating 2000 jsp files to make it up to standard. I used the script from this website to create an expanding and collapsing sitemap bar at the bottom of my page. What I can't find is a solution to the menu expanding up over the content instead of expanding downwards. I'm wondering if it's not a javascript thing at all? ANY help is so much appreciated. Collapsed Expanded Code: <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> <title>Switch menu</title> <style type="text/css"> <!-- body { text-align:center; margin:30px; } #wrapper { text-align:left; margin:0 auto; width:500px; min-height:100px; border:1px solid #ccc; padding:30px; } a { color:blue; cursor:pointer; } #myvar { border:1px solid #ccc; background:#f2f2f2; padding:20px; } --> </style> <script type="text/javascript"> <!-- function switchMenu(obj) { var el = document.getElementById(obj); if ( el.style.display != "none" ) { el.style.display = 'none'; } else { el.style.display = ''; } } //--> </script> </head> <body> <div id="wrapper"> <p><a href="http://www.dustindiaz.com/dhtml-expand-and-collapse-div-menu/" title="DHTML expand and collapse Menu">Return to "DHTML expand and collapse div menu" article"</a></p> <p><a onclick="switchMenu('myvar');" title="Switch the Menu">Switch it now</a></p> <div id="myvar"> <p>This is paragraph text that is all up in this place that does some pretty cool stuff</p> <p>This is paragraph text that is all up in this place that does some pretty cool stuff</p> <p>This is paragraph text that is all up in this place that does some pretty cool stuff</p> <p>This is paragraph text that is all up in this place that does some pretty cool stuff</p> </div> </div> </body> </html> Hello: I have a Fire Fox 3.5.2 error console message regarding a DHTML script: Error: uncaught exception: [Exceptions: ... "Not enough arguments" nsresult "0x8057001 (NS_ERROR_XPC_NOT_ENOUGH_ARGS)" Location: "JS frame :: (file path) upHandler :: line 102" no data] The line referenced is: document.removeEventListener('mouseup', upHandler); It is part of a drag function that is applied to a container div. I have successfull used this code block, copied from Orielly's Javascript: The Definitive Guide, 4th Edition in another project. The only real difference is that the code in the working use is div tags hard coded. In the one giving me problems, the div tags are written using document.write() in a function that is called in the body of the document when the page loads. I could supply the code context, but it is several hundred lines. The project is not available at present on the web to surf to but the one project that works is jekillen.com/jekillen/content/web_design/OOP_panel/test_OOP_DEV_ALT.php The code in question is 'beginDrag'. There is a panel called fortune cookie which the user can drag, and a panel called 'Advisory' that the user can also drag around after clicking button labeled 'message'. Any info, suggestions, advice? Thanks in advance. Jeff K Hey guys! First of all I dont want anyone to do it all for me, tho if u want to sure! "Else please help me out with just saying where I should start." I have done some simple dice games etc with JS and thats about it. Anyways, Im trying to do a DHTML menu/form with JS, if u click on one option only the menu it self should change so u dont get into another HTML file coz I wanna put it all on the same file ( exept for the "SEND" link ). (Check the pictures I uploaded) If u press "contact" the menu it self should get larger with the contact adress bellow, And if u press SEND u should get into another contact form where u have to fill out ur information. And when u filled out ur name the contact form should get even bigger with more questions to fill out. - Once again check the pictures I uploaded if u dont know what im talking about pic1: http://i403.photobucket.com/albums/pp115/kyth1/send.jpg pic2: http://i403.photobucket.com/albums/p...yth1/send2.jpg Thx - / Jul Hi pals, I am really tired in this problem of event keyup. I given same in my keyup function like: $(document).ready(function () { alert("GGG"+parseInt(jQuery.browser.version)); //To display test value working $("#find_text").keyup(function(e) { if(e.which == 13) { alert('Enter key was pressed'); //enter Here alert("FFF"+parseInt(jQuery.browser.version)); //Here got Error } }); }); I got Error : jQuery is not defined alert("FFF"+parseInt(jQuery.browser.version)); I use keycode,which , but no help, It's Work nicely in Chrome Browser but not in FF. Please give a Solution reply ASAP, I am really Tired.The code enter the Condition But that jQuery part make error. Thankfully Anes P.A I am creating a page which redirects automatically depending on the date. What I've done so far is below, but how would I make it go switch to exceeded_year.htm on 25th March 2011 for example? I will also include other dates and later put this page in a header frame and controlling the frame below so its constantly open. <html> <script type="text/javascript"> <!-- var currentTime = new Date() var date = currentTime.getDate() var month = currentTime.getMonth() + 1 var year = currentTime.getFullYear() if (year > 2011 ) {window.location = "exceeded_year.htm"; } else window.location="#" //--> </script> </html> Hi, so I thought I could mash two bits of code together like this: Code: <div><label for="or">From:</label> <select name="or" style="width:200px; float: right" id="or" onchange="populate(this)"> <option value="Choose">Select your starting point</option> <option value="Guatemala">Guatemala City</option> <option value="Xela">Quetzaltenango</option> <option value="Antigua">Antigua</option> <option value="Rio Dulce">Rio Dulce</option> <option value="Coban">Coban</option> </select></div> <div> <label for="de">To:</label> <select name="de" style="width:200px; float: right" id="de"></select> </div> <div> <br> <input type="button" onclick="searchLocations()" value="Show route" /> </div> </div> </div> </div> <script type="text/javascript"> if (GBrowserIsCompatible()) { var gpolylines = []; function populate(o) { d=document.getElementById('de'); if(!d){return;} var mitems=new Array(); mitems['Choose']=['']; mitems['Guatemala']=['Select Destination','Antigua','El Rancho junction','San Pedro La Laguna','Panajachel','Coban','Rio Hondo','Chiquimula','Esquipulas','Copan Ruinas (Honduras)','La Ruidosa junction','Rio Dulce','Flores (via Rio Dulce)','Puerto Barrios','Flores (via Coban)','Quetzaltenango']; mitems['Xela']=['Select Destination','Guatemala City','Antigua','Chichicastenango','Huehuetenango','Panajachel','San Pedro La Laguna']; mitems['Antigua']=['Select Destination','Guatemala City','Quetzaltenango','Escuintla','Monterrico','San Pedro la Laguna','Panajachel','Chichicastenango']; mitems['Rio Dulce']=['Select Destination','Guatemala City','Flores','Lanquin','Coban','Puerto Barrios']; mitems['Coban']=['Select Destination','Lanquin','Rio Dulce','Laguna Lachua NP','Flores']; d.options.length=0; cur=mitems[o.options[o.selectedIndex].value]; if(!cur){return;} d.options.length=cur.length; for(var i=0;i<cur.length;i++) { d.options[i].text=cur[i]; d.options[i].value=cur[i]; } } function searchLocations() { var found = false; var from = document.getElementById('or').value; var to = document.getElementById('de').value; for (var a = 0; a < gpolylines.length; a++) { if (gpolylines[a].myname.toLowerCase() == to.toLowerCase() && gpolylines[a].mycategory.toLowerCase() == from.toLowerCase()) { found = true; gpolylines[a].show(); } } if ( ! found ) alert("No matches found. Please check your spelling or refine your search."); } the first bit, which populates the select boxes works fine, as you can see here but the second bit (the searchLocations function) is giving me a bit more trouble. What it's supposed to be doing is saying that if there's a polyline whose category xml attribute matches the text from the 1st select box AND whose name attribute matches the 2nd select box, it should be shown. The methods have worked in the past, there are no errors reported - the only problem is I get the alert regardless of which option I am selecting. I suspect that the problem is in the if (gpolylines[a].myname.toLowerCase() == to.toLowerCase() && gpolylines[a].mycategory.toLowerCase() == from.toLowerCase()) line, as it's the only one that I really came up with on my own... or can I not get the "or" and "de" elements in that way? Or is it something else entirely? thanks in advance for any suggestions... Hi, i can't get my new logo to work in IE, it's working fine in Chrome and FireFox, it must be a JavaScript problem. here it is: http://danishwebart.com/logo/logo.php And the JavaScrip: $(function() { var canvas = $("#c"); var canvasHeight; var canvasWidth; var ctx; var dt = 0.1; var pointCollection; function init() { updateCanvasDimensions(); var g = [new Point(27, 34, 0.0, 1, "#ed9d33"), new Point(26, 38, 0.0, 1, "#d44d61"), new Point(25, 41, 0.0, 1, "#4f7af2"), new Point(22, 44, 0.0, 1, "#ef9a1e"), new Point(18, 46, 0.0, 2, "#4976f3"), new Point(12, 44, 0.0, 2.5, "#269230"), new Point(7, 41, 0.0, 2, "#1f9e2c"), new Point(5, 37, 0.0, 1, "#36b641"), new Point(4, 33, 0.0, 1, "#2e5def"), new Point(4, 29, 0.0, 1, "#d53747"), new Point(5, 25, 0.0, 1, "#eb676f"), new Point(6, 22, 0.0, 1, "#f9b125"), new Point(8, 19, 0.0, 1, "#de3646"), new Point(11, 16, 0.0, 1, "#5f8af8"), new Point(13, 14, 0.0, 1, "#efa11e"), new Point(16, 12, 0.0, 1, "#2e55e2"), new Point(19, 10, 0.0, 1, "#4167e4"), new Point(23, 8, 0.0, 1.5, "#4869e3"), new Point(28, 6, 0.0, 2, "#10a11d"), new Point(33, 5, 0.0, 2, "#cf4055"), new Point(38, 5, 0.0, 2, "#cd4359"), new Point(44, 6, 0.0, 3, "#ca273c"), new Point(51, 8, 0.0, 3, "#2650e1"), new Point(57, 11, 0.0, 3, "#4a7bf9"), new Point(63, 16, 0.0, 3.5, "#f47875"), new Point(68, 23, 0.0, 4, "#f36764"), new Point(71, 31, 0.0, 3.5, "#1d4eeb"), new Point(72, 38, 0.0, 3, "#698bf1"), new Point(72, 44, 0.0, 2.5, "#fac652"), new Point(72, 49, 0.0, 2, "#ee5257"), new Point(71, 54, 0.0, 2, "#5681f5"), new Point(70, 59, 0.0, 2, "#f8c247"), new Point(68, 64, 0.0, 2, "#4577f6"), new Point(65, 68, 0.0, 2, "#f7b326"), new Point(62, 72, 0.0, 2, "#facb5e"), new Point(59, 75, 0.0, 2, "#e02e3d"), new Point(55, 77, 0.0, 2, "#f16d6f"), new Point(53, 78, 0.0, 2.5, "#507bf2"), new Point(47, 79, 0.0, 3, "#5683f7"), new Point(40, 77, 0.0, 3.5, "#3158e2"), new Point(33, 74, 0.0, 3.5, "#f0696c"), new Point(27, 73, 0.0, 2.5, "#3769f6"), new Point(22, 73, 0.0, 2, "#6084ef"), new Point(19, 76, 0.0, 1.5, "#2a5cf4"), new Point(17, 79, 0.0, 1, "#f4716e"), new Point(25, 70, 0.0, 2, "#f8c247"), new Point(29, 67, 0.0, 2, "#ec4147"), new Point(33, 64, 0.0, 2, "#4876f1"), new Point(36, 59, 0.0, 2.5, "#2552ea"), new Point(38, 53, 0.0, 3, "#4779f7"), new Point(38, 46, 0.0, 3.5, "#4b78f1"), new Point(38, 38, 0.0, 3.5, "#4b78f1"), new Point(37, 31, 0.0, 2.5, "#4b78f1"), new Point(38, 25, 0.0, 2, "#4b78f1"), new Point(40, 20, 0.0, 2, "#4b78f1"), new Point(42, 16, 0.0, 1.5, "#4b78f1"), new Point(45, 14, 0.0, 1, "#4b78f1"), new Point(48, 12, 0.0, 1, "#4b78f1"), new Point(59, 82, 0.0, 1, "#ed9d33"), new Point(62, 80, 0.0, 1.5, "#d44d61"), new Point(66, 77, 0.0, 2, "#4f7af2"), new Point(70, 73, 0.0, 2, "#4976f3"), new Point(73, 69, 0.0, 2, "#269230"), new Point(76, 65, 0.0, 2, "#1f9e2c"), new Point(79, 60, 0.0, 2, "#36b641"), new Point(80, 55, 0.0, 1.5, "#2e5def"), new Point(81, 65, 0.0, 2.5, "#eb676f"), new Point(83, 71, 0.0, 3, "#f9b125"), new Point(84, 77, 0.0, 2.5, "#de3646"), new Point(82, 82, 0.0, 2, "#de3646"), new Point(88, 74, 0.0, 1.5, "#efa11e"), new Point(90, 70, 0.0, 1.5, "#2e55e2"), new Point(92, 66, 0.0, 1.5, "#4869e3"), new Point(93, 62, 0.0, 1.5, "#4869e3"), new Point(95, 53, 0.0, 1, "#10a11d"), new Point(95, 57, 0.0, 2, "#cf4055"), new Point(97, 62, 0.0, 2.5, "#cd4359"), new Point(100, 68, 0.0, 3, "#ca273c"), new Point(102, 74, 0.0, 2.5, "#2650e1"), new Point(101, 80, 0.0, 2, "#4a7bf9"), new Point(105, 78, 0.0, 1, "#f36764"), new Point(107, 75, 0.0, 1, "#1d4eeb"), new Point(109, 72, 0.0, 1, "#698bf1"), new Point(110, 69, 0.0, 1, "#fac652"), new Point(111, 66, 0.0, 1, "#ee5257"), new Point(112, 63, 0.0, 1, "#5681f5"), new Point(112, 60, 0.0, 1.5, "#f8c247"), new Point(112, 56, 0.0, 1.5, "#4577f6"), new Point(110, 52, 0.0, 2, "#f7b326"), new Point(107, 48, 0.0, 2.5, "#facb5e"), new Point(102, 45, 0.0, 2.5, "#e02e3d"), new Point(97, 43, 0.0, 2, "#f16d6f"), new Point(110, 83, 0.0, 1, "#507bf2"), new Point(112, 80, 0.0, 1, "#5683f7"), new Point(114, 77, 0.0, 1.5, "#3158e2"), new Point(116, 73, 0.0, 1.5, "#f0696c"), new Point(118, 69, 0.0, 1.5, "#3769f6"), new Point(119, 65, 0.0, 1.5, "#6084ef"), new Point(119, 61, 0.0, 1.5, "#2a5cf4"), new Point(119, 57, 0.0, 1.5, "#f4716e"), new Point(118, 53, 0.0, 1.5, "#f8c247"), new Point(116, 50, 0.0, 1, "#ec4147"), new Point(120, 51, 0.0, 1, "#4876f1"), new Point(123, 53, 0.0, 1, "#2552ea"), new Point(126, 55, 0.0, 1, "#4779f7"), new Point(129, 58, 0.0, 1.5, "#4b78f1"), new Point(132, 61, 0.0, 1.5, "#4b78f1"), new Point(135, 65, 0.0, 1.5, "#4b78f1"), new Point(138, 69, 0.0, 1.5, "#4b78f1"), new Point(140, 73, 0.0, 2, "#4b78f1"), new Point(142, 78, 0.0, 2, "#4b78f1"), new Point(143, 83, 0.0, 2, "#4b78f1"), new Point(121, 70, 0.0, 1, "#4b78f1"), new Point(124, 71, 0.0, 1, "#4b78f1"), new Point(127, 71, 0.0, 1, "#4b78f1"), new Point(130, 71, 0.0, 1.5, "#4b78f1"), new Point(134, 70, 0.0, 1.5, "#4b78f1"), new Point(142, 68, 0.0, 1.5, "#4b78f1"), new Point(146, 68, 0.0, 1, "#4b78f1"), new Point(149, 69, 0.0, 1, "#4b78f1")]; gLength = g.length; for (var i = 0; i < gLength; i++) { g[i].curPos.x = (canvasWidth/2 - 0) + g[i].curPos.x; g[i].curPos.y = (canvasHeight/2 - 0) + g[i].curPos.y; g[i].originalPos.x = (canvasWidth/2 - 0) + g[i].originalPos.x; g[i].originalPos.y = (canvasHeight/2 - 0) + g[i].originalPos.y; }; pointCollection = new PointCollection(); pointCollection.points = g; initEventListeners(); timeout(); }; function initEventListeners() { $(window).bind('resize', updateCanvasDimensions).bind('mousemove', onMove); canvas.get(0).ontouchmove = function(e) { e.preventDefault(); onTouchMove(e); }; canvas.get(0).ontouchstart = function(e) { e.preventDefault(); }; }; function updateCanvasDimensions() { canvas.attr({height: $(window).height(), width: $(window).width()}); canvasWidth = canvas.width(); canvasHeight = canvas.height(); draw(); }; function onMove(e) { if (pointCollection) pointCollection.mousePos.set(e.pageX, e.pageY); }; function onTouchMove(e) { if (pointCollection) pointCollection.mousePos.set(e.targetTouches[0].pageX, e.targetTouches[0].pageY); }; function timeout() { draw(); update(); setTimeout(function() { timeout() }, 30); }; function draw() { var tmpCanvas = canvas.get(0); if (tmpCanvas.getContext == null) { return; }; ctx = tmpCanvas.getContext('2d'); ctx.clearRect(0, 0, canvasWidth, canvasHeight); if (pointCollection) pointCollection.draw(); }; function update() { if (pointCollection) pointCollection.update(); }; function Vector(x, y, z) { this.x = x; this.y = y; this.z = z; this.addX = function(x) { this.x += x; }; this.addY = function(y) { this.y += y; }; this.addZ = function(z) { this.z += z; }; this.set = function(x, y, z) { this.x = x; this.y = y; this.z = z; }; }; function PointCollection() { this.mousePos = new Vector(0, 0); this.points = new Array(); this.newPoint = function(x, y, z) { var point = new Point(x, y, z); this.points.push(point); return point; }; this.update = function() { var pointsLength = this.points.length; for (var i = 0; i < pointsLength; i++) { var point = this.points[i]; if (point == null) continue; var dx = this.mousePos.x - point.curPos.x; var dy = this.mousePos.y - point.curPos.y; var dd = (dx * dx) + (dy * dy); var d = Math.sqrt(dd); if (d < 80) { point.targetPos.x = (this.mousePos.x < point.curPos.x) ? point.curPos.x - dx : point.curPos.x - dx; point.targetPos.y = (this.mousePos.y < point.curPos.y) ? point.curPos.y - dy : point.curPos.y - dy; } else { point.targetPos.x = point.originalPos.x; point.targetPos.y = point.originalPos.y; }; point.update(); }; }; this.draw = function() { var pointsLength = this.points.length; for (var i = 0; i < pointsLength; i++) { var point = this.points[i]; if (point == null) continue; point.draw(); }; }; }; function Point(x, y, z, size, colour) { this.colour = colour; this.curPos = new Vector(x, y, z); this.friction = 0.8; this.originalPos = new Vector(x, y, z); this.radius = size; this.size = size; this.springStrength = 0.1; this.targetPos = new Vector(x, y, z); this.velocity = new Vector(0.0, 0.0, 0.0); this.update = function() { var dx = this.targetPos.x - this.curPos.x; var ax = dx * this.springStrength; this.velocity.x += ax; this.velocity.x *= this.friction; this.curPos.x += this.velocity.x; var dy = this.targetPos.y - this.curPos.y; var ay = dy * this.springStrength; this.velocity.y += ay; this.velocity.y *= this.friction; this.curPos.y += this.velocity.y; var dox = this.originalPos.x - this.curPos.x; var doy = this.originalPos.y - this.curPos.y; var dd = (dox * dox) + (doy * doy); var d = Math.sqrt(dd); this.targetPos.z = d/100 + 1; var dz = this.targetPos.z - this.curPos.z; var az = dz * this.springStrength; this.velocity.z += az; this.velocity.z *= this.friction; this.curPos.z += this.velocity.z; this.radius = this.size*this.curPos.z; if (this.radius < 1) this.radius = 1; }; this.draw = function() { ctx.fillStyle = this.colour; ctx.beginPath(); ctx.arc(this.curPos.x, this.curPos.y, this.radius, 0, Math.PI*2, true); ctx.fill(); }; }; init(); }); Hi, I have html variable as below: html += "<div class='quickSearchResultDivUnselected' style='width:" + divWidh + "px;max-width:" + divWidh + "px'><a href='#' OnClick='javascript:test('" + title + "')>" + title + "</a></div>"; The problem is with OnClick='javascript:test('" + title + "')>". How to make this link as <a OnClick='javascript:test("VALUE")'></a>, because now as result it looks like this and it doesn't work: <a OnClick='javascript:test('value')'></a>; So the problem is with ' and ". How to make it correctly in this long line of html variable ? Please help. Hey guys! :-) How do i translate this javascript sentense in to "real working" javascript. PHP Code: if(a1 "its a box/this is just for info" = got a value written){ c1 also a box = disabled; } How do i write this so it works? My first thought was: PHP Code: if(document.GetElementById(a1).value = true){ document.GetElementById(c1).disabled = true; } But cant get it working - is there somebody there could help me? :-) //Morten Larsen // Denmark. I really don't even know if I'm posting this question in the right section. I am using javascript to make a drop-down menu for a website. I really don't have any experience with javascript. The problem I'm having is that when I go to the page, the drop down menu is already dropped down. If you then hover over it, it pulls up and then hover over it again and it drops back down. It works fine after the initial glitch. Didn't know if anyone had run into this problem or if I'm just being stupid, here is the code that I'm using. Thanks in advance for any help. <a href="/mainpage.html" onMouseOver="show()" onMouseOut="hide()" ><img src="pic.png" border="0" width="90" height="24"></a></br> <div id="div1"><a href="/notherpage.html" onMouseOver="show()" onMouseOut="hide()" ><img src="pic2.png"><br><a href="/notherpage2.html" onMouseOver="show()" onMouseOut="hide()" ><img src="pic3.png"><br><a href="/lastpage.html" onMouseOver="show()" onMouseOut="hide()" ><img src="pic4.png"></div> <script type="text/javascript"> function show(){ document.getElementById("div1").style.display="block"; } function hide(){ document.getElementById("div1").style.display="none"; } </script> this is coder javascript : textneu = textneu.replace(/haha/,"<img src='../images/21.gif'>"); Result: <img src='../images/21.gif'> why? i want result is : <img src='../images/21.gif'> |