JavaScript - Help With Changing Innertext And Tags Javascript, Language Translator
Hi, I'm currently trying to get javascript to work with internet explorer. I managed to get one part of the translation file to work. It's a javascript to change some of the words on Facebook from English to Secwepemc (native american language). The original file works in Firefox and Chrome but not in safari. I knew it was because internet explorer has its own parameters. A file works completely for FF and chrome but not for IE. So, I changed the language a bit so that IE can understand it. Now I have one part of the translation working but not the others. I am wondering if it would be better to use ID's, names, and class all together to get the english words I want to change. I am using grease monkey for IE to use this script. I know firefox and chrome are much better but the plan is for everyone to use and some people still use IE. I know that if I have part of the words translating, then it must be the wrong identifiers. If someone can either help me find the right identifiers or if I missed changing syntax from FF and Chrome to IE, that would be amazing! Here is the javascript file.
Code: var es = new Array(); es["Home"] = "Tsitcw"; es["News Feed"] = "Lexeyem"; es["Friends"] = "Kweselkten"; es["Like"] = "Xwexwisten"; es[" likes this."] = " r xwexwistes."; es["Today"] = "Pyin Te Sitqt"; es["Say hello."] = "Say weytk."; es["Say hi."] = "Say weytk."; es["Tomorrow"] = "Pexweyt"; es["What are you planning?"] = "Me7 Stemi ke7 tsuwet?"; es["Where?"] = "T'he7en"; es["Who's invited?"] = "Sweti7?"; es["What's on your mind?"] = "Stemi ke7 peti'nesme?"; function loadSecwepemc() { var fbelem = document.getElementsByTagName('a'); for (var i = 0; i < fbelem.length; i++) { var thisElem = fbelem[i]; if (thisElem.innerText in es) { thisElem.innerText = es[thisElem.innerText]; } } var fbelem = document.getElementsByTagName('span'); for (var i = 0; i < fbelem.length; i++) { var thisElem = fbelem[i]; if (thisElem.innerText in es) { thisElem.innerText = es[thisElem.innerText]; } } var fbelem = document.getElementsByClassName('ego_social_context'); for (var i = 0; i < fbelem.length; i++) { var thisElem = fbelem[i]; if (thisElem.innerText in es) { thisElem.innerText = es[thisElem.innerText]; } } var fbelem = document.getElementsByTagName('input'); for (var i = 0; i < fbelem.length; i++) { var thisElem = fbelem[i]; if (thisElem.getAttribute('placeholder') in es) { thisElem.setAttribute('placeholder',es[thisElem.getAttribute('placeholder')]); } if (thisElem.getAttribute('value') in es) { thisElem.setAttribute('value',es[thisElem.getAttribute('value')]); } } var fbelem = document.getElementsByTagName('textarea'); for (var i = 0; i < fbelem.length; i++) { var thisElem = fbelem[i]; if (thisElem.getAttribute('placeholder') in es) { thisElem.setAttribute('placeholder',es[thisElem.getAttribute('placeholder')]); } if (thisElem.getAttribute('title') in es) { thisElem.setAttribute('title',es[thisElem.getAttribute('title')]); } if (thisElem.innerText in es) { thisElem.innerText = es[thisElem.innerText]; } } var fbelem = document.getElementsByTagName('h3'); for (var i = 0; i < fbelem.length; i++) { var thisElem = fbelem[i]; if (thisElem.innerText in es) { thisElem.innerText = es[thisElem.innerText]; thisElem.attachEvent( "onClick", loadSecwepemc()); // capture phase } } var fbelem = document.getElementsByTagName('h2'); for (var i = 0; i < fbelem.length; i++) { var thisElem = fbelem[i]; if (thisElem.innerText in es) { icon = thisElem.childNodes[0] thisElem.innerText = es[thisElem.innerText]; thisElem.appendChild(icon) } } } loadSecwepemc(); function changedNode(e) { var fbelem = e.target.getElementsByTagName('a'); for (var i = 0; i < fbelem.length; i++) { var thisElem = fbelem[i]; if (thisElem.innerText in es) { thisElem.innerText = es[thisElem.innerText]; } } var fbelem = e.target.getElementsByTagName('span'); for (var i = 0; i < fbelem.length; i++) { var thisElem = fbelem[i]; if (thisElem.innerText in es) { thisElem.innerText = es[thisElem.innerText]; thisElem.attachEvent( "onLoad", loadSecwepemc()); // capture phase } } var fbelem = e.target.getElementsByClassName('ego_social_context'); for (var i = 0; i < fbelem.length; i++) { var thisElem = fbelem[i]; if (thisElem.innerText in es) { thisElem.innerText = es[thisElem.innerText]; } } var fbelem = e.target.getElementsByTagName('input'); for (var i = 0; i < fbelem.length; i++) { var thisElem = fbelem[i]; if (thisElem.getAttribute('placeholder') in es) { thisElem.setAttribute('placeholder',es[thisElem.getAttribute('placeholder')]); } if (thisElem.getAttribute('value') in es) { thisElem.setAttribute('value',es[thisElem.getAttribute('value')]); } } var fbelem = document.getElementsByTagName('textarea'); for (var i = 0; i < fbelem.length; i++) { var thisElem = fbelem[i]; if (thisElem.getAttribute('placeholder') in es) { thisElem.setAttribute('placeholder',es[thisElem.getAttribute('placeholder')]); } if (thisElem.getAttribute('title') in es) { thisElem.setAttribute('title',es[thisElem.getAttribute('title')]); } if (thisElem.innerText in es) { thisElem.innerText = es[thisElem.innerText]; } } var fbelem = e.target.getElementsByTagName('h3'); for (var i = 0; i < fbelem.length; i++) { var thisElem = fbelem[i]; if (thisElem.innerText in es) { thisElem.innerText = es[thisElem.innerText]; thisElem.attachEvent( "onClick", loadSecwepemc()); // capture phase } } var fbelem = e.target.getElementsByTagName('h2'); for (var i = 0; i < fbelem.length; i++) { var thisElem = fbelem[i]; if (thisElem.innerText in es) { icon = thisElem.childNodes[0] thisElem.innerText = es[thisElem.innerText]; thisElem.appendChild(icon) } } } document.attachEvent('onNodeInserted', changedNode()); Similar TutorialsSo I have an assignment where I need to make a program to make a simple translator. Where I insert a text box for the user to input i.e. "Hello" and the other textbox to display the word in spanish. Problem is im having trouble displaying the output and having a textbox to out put it too. Also i dont think my button is functioning correctly. Please help! It would be greatly appreciated! <html> <h2> English to Spanish Translator </h2> <head> <script type = "text/javascript"> PHRASES = [["hello", "hola"], ["hi, hola"], ["how are you", "como estas"], ["sorry", "lo siento"], ["thank you", "gracias"], ["please", "por favor"], ["how are you doing today"], ["como estas hoy"], ["I love you", "te amo"], ["hey, eh"], ["welcome", "bienvenido"], ["my name is", "mi nombre es"], [ "good morning", "buenos dias"], ["goodbye","adios"], ["i don't know", "no se"], ["help", "ayudame"], ["happy birthday", "feliz cumpleanos"]] function capitalize (str) { return str.charAt(0).toUpperCase() + str.substring(1); } function translate (text) { for (var i = 0; i < PHRASES.length; i++) { var toReplace = new RegExp("\\b" + PHRASES[i][0] + "\\b", "i"); var index = text.search(toReplace); while (index != -1) { if (text.charAt(index) >= "A" && text.charAt(index) <= "Z") { text = text.replace(toReplace, capitalize(PHRASES[i][1])); } else { text = text.replace(toReplace),PHRASES[i][1]); } index = text.search(toReplace); } } return text; } </script> </head> <body> <form name = "ButtonForm"> <p> Enter a word or phrase </p> <input type = "text" name = "input" value = "" /> <br></br> <input type = "button" value = "Translate" onClick = "translate();" /> <br> </br> </form> </body> </html> Reply With Quote 02-03-2015, 10:12 PM #2 jmrker View Profile View Forum Posts Senior Coder Join Date Aug 2006 Location FL Posts 3,175 Thanks 39 Thanked 510 Times in 504 Posts I have not tested your entire array of words, but this should get you started. NOTES: 1. You did not pass a word to 'translate()' for it to check 2. You did not have a place to store the returned value of the translation 3. You should not use reserved words as variables (ie, text as a function parameter) Code: <html> <h2> English to Spanish Translator </h2> <head> <script type = "text/javascript"> PHRASES = [ ["hello", "hola"], ["hi, hola"], ["how are you", "como estas"], ["sorry", "lo siento"], ["thank you", "gracias"], ["please", "por favor"], ["how are you doing today"], ["como estas hoy"], ["I love you", "te amo"], ["hey, eh"], ["welcome", "bienvenido"], ["my name is", "mi nombre es"], ["good morning", "buenos dias"], ["goodbye","adios"], ["i don't know", "no se"], ["help", "ayudame"], ["happy birthday", "feliz cumpleanos"] ]; function capitalize (str) { return str.charAt(0).toUpperCase() + str.substring(1); } function translate (txt) { for (var i=0; i<PHRASES.length; i++) { var toReplace = new RegExp("\\b" + PHRASES[i][0] + "\\b", "i"); var index = txt.search(toReplace); while (index != -1) { if (txt.charAt(index) >= "A" && txt.charAt(index) <= "Z") { txt = txt.replace(toReplace, capitalize(PHRASES[i][1])); } else { txt = txt.replace(toReplace,PHRASES[i][1]); } index = txt.search(toReplace); } } return txt; } </script> </head> <body> <form name="ButtonForm" action="" method="post" onsubmit="return false"> <p> Enter a word or phrase </p> <input type="text" name="inText" id="inText" value="" /> <p> <input type="button" value="Translate" onClick = "document.getElementById('outText').value = translate(document.getElementById('inText').value)" /> <p> <input type="text" name="outText" id="outText" value="" /> </form> </body> </html> BTW, you should enclose your script between [ code] and [ /code] tags (without the spaces) to retain formatting and make it easier for forum members to read, test, debug, etc. Good Luck! I would like to ask people's opinions as to which "offline" language is most similar to javascript? I don't program for a living, but I have been learning javascript in my spare time. I would now like to have a shot at making a desktop application, and I think it would help to choose one which is most similar, if at all possible, to javascript? e.g. python, ruby, C#, visual basic ... I have no idea and haven't had much luck googling this Thanks Matt i have an onclick function, but after debuging i found that firefox and only firefox blocks at the line " individualNames = names.childNodes[0].innerText; " is there somthin im missing please help. function searchForm() { var change = 0; var searchValue = document.getElementById("searchValue").value.toLowerCase(); var count = document.getElementById("excelTable").rows.length; var once = true; myArray = new Array(); if(searchValue == ""){alert("Please enter a value"); return false} for(i=0;i<=count;i++){ names = document.getElementById("excelTable").rows[i]; individualNames = names.childNodes[0].innerText; //only by last name of the file coming in format == "LastName, FirstName" lastName = individualNames.split(", "); //only by last name lowerCaseNames = lastName[0].toLowerCase(); names.style.backgroundColor = "#FFF"; if(lowerCaseNames.indexOf(searchValue) != -1) { names.style.backgroundColor = "#999"; //make the first result with the search apear on screen than stop after the first if(once==true){document.getElementById("excelTable").rows[i].scrollIntoView(true); once=false;} myArray[change] = document.getElementById("excelTable").rows[i];//fill a passing array to next function change++;//make the array go to next slot document.getElementById("nextButton").disabled = false; document.getElementById("searchTitle").scrollIntoView(true); } } } Hey guys! I need a simple JavaScript word translator where the user can type a sentence into a text box and then be presented with what they just typed in on the page but with any programmed word replacements. I want to be able to programme in the words myself for replacement so no Google; this will be a personal offline thing and isn't used to translate a language. For example, if I programmed the word " chocolate " to be replaced with " strawberry ", and " a lot " to be replaced with " loads ", and typed into the text-box: "I like chocolate sauce a lot ". It would then display the sentence on the page, but with the word alterations. Therefore looking like this: "I like strawberry sauce loads ". That being just an example. I want to be able to easily add additional word replacements without hassle using only JavaScript, I don't want it to translate the text on the page or anything, just what you type into the text-box. So let's pretend the words were programmed as follows: . cat = dog, . love = adore . very much = a lot And I typed into the text-box the following: "I have a cat, and I love her very much. " On the same page, it would then display this text: "I have a dog, and I adore him a lot. " I cannot use other code as I am only fond with JavaScript. I would need the text-box to automatically be selected by default everytime the page is loaded, and then for it to clear everytime you click 'Submit' or press the [Enter] key, ready for the next sentence to be typed in. I know this is a lot to ask but I didn't know who else to turn to. Anyways, I know you'll know this WAY better than me, ha; hope you can help! Cheers guys!!! I have a successful translator that has random letter, number and symbols assigned to various letters problem is it only lets assign 1 character to 1 letter when i want to assign 4 characters to each letter to ensure the code cant be broken here is a snipet of what im working with its different then normal translators....
Code: <script language="javascript"> function translate() { if (document.form1.elements[0].checked == true) { EtoA() } else if (document.form1.elements[1].checked == true) { AtoE() } else { } } function EtoA() { var toggle = "false" var xlate = document.form1.elements[4].value var xlation = "" document.form1.elements[5].value = "" for (var i = 0; i <= xlate.length; i++) { tempa = xlate.charAt(i) if ( tempa == "[") { toggle = "true" i++ } else if ( tempa == "]") { toggle = "false" i++ } tempa = xlate.charAt(i) if (toggle == "true") { tempb = tempa } else if(tempa == "a") { tempb = "9" } else if(tempa == "b") { tempb = "a" } else if(tempa == "c") { tempb = "0" } else if(tempa == "d") { tempb = "c" } else if(tempa == "e") { tempb = "3" } else if(tempa == "f") { tempb = "b" } else if(tempa == "g") { tempb = "4" } else if(tempa == "h") { tempb = "?" } else if(tempa == "i") { tempb = "5" } else if(tempa == "j") { tempb = "6" } else if(tempa == "k") { tempb = "e" } else if(tempa == "l") { tempb = "+" } else if(tempa == "m") { tempb = "x" } else if(tempa == "n") { tempb = "7" } else if(tempa == "o") { tempb = "v" } else if(tempa == "p") { tempb = "1" } else if(tempa == "q") { tempb = "t" } else if(tempa == "r") { tempb = "q" } else if(tempa == "s") { tempb = "g" } else if(tempa == "t") { tempb = "n" } else if(tempa == "u") { tempb = "<" } else if(tempa == "v") { tempb = ">" } else if(tempa == "w") { tempb = "^" } else if(tempa == "x") { tempb = "!" } else if(tempa == "y") { tempb = "@" } else if(tempa == "z") { tempb = "#" } else if(tempa == "A") { tempb = "9" } else if(tempa == "B") { tempb = "a" } else if(tempa == "C") { tempb = "0" } else if(tempa == "D") { tempb = "c" } else if(tempa == "E") { tempb = "3" } else if(tempa == "F") { tempb = "b" } else if(tempa == "G") { tempb = "4" } else if(tempa == "H") { tempb = "h" } else if(tempa == "I") { tempb = "5" } else if(tempa == "J") { tempb = "6" } else if(tempa == "K") { tempb = "e" } else if(tempa == "L") { tempb = "f" } else if(tempa == "M") { tempb = "x" } else if(tempa == "N") { tempb = "7" } else if(tempa == "O") { tempb = "v" } else if(tempa == "P") { tempb = "1" } else if(tempa == "Q") { tempb = "t" } else if(tempa == "R") { tempb = "q" } else if(tempa == "S") { tempb = "g" } else if(tempa == "T") { tempb = "n" } else if(tempa == "U") { tempb = "<" } else if(tempa == "V") { tempb = ">" } else if(tempa == "W") { tempb = "^" } else if(tempa == "X") { tempb = "!" } else if(tempa == "Y") { tempb = "@" } else if(tempa == "Z") { tempb = "#" } else if(tempa == "1") { tempb = "}" } else if(tempa == "2") { tempb = "{" } else if(tempa == "3") { tempb = "(" } else if(tempa == "4") { tempb = "'" } else if(tempa == "5") { tempb = "|" } else if(tempa == "6") { tempb = "`" } else if(tempa == "7") { tempb = ":" } else if(tempa == "8") { tempb = ";" } else if(tempa == "9") { tempb = "=" } else if(tempa == "0") { tempb = ")" } else if(tempa == "~") { tempb = "R" } else if(tempa == "!") { tempb = "T" } else if(tempa == "@") { tempb = "F" } else if(tempa == "#") { tempb = "Y" } else if(tempa == "$") { tempb = "K" } else if(tempa == "%") { tempb = "J" } else if(tempa == "^") { tempb = "H" } else if(tempa == "&") { tempb = "G" } else if(tempa == "*") { tempb = "X" } else if(tempa == "_") { tempb = "V" } else if(tempa == "-") { tempb = "B" } else if(tempa == "+") { tempb = "M" } else if(tempa == "=") { } else if(tempa == "<") { tempb = "N" } else if(tempa == ">") { tempb = "U" } else if(tempa == ".") { tempb = "S" } else if(tempa == ",") { tempb = "W" } else if(tempa == "?") { tempb = "." } else if(tempa == ":") { tempb = "," } else if(tempa == ";") { tempb = "$" } else { tempb = tempa } xlation = document.form1.elements[5].value document.form1.elements[5].value = xlation + tempb } } function AtoE() { var toggle = "false" var xlate = document.form1.elements[4].value var xlation = "" document.form1.elements[5].value = "" for (var i = 0; i <= xlate.length; i++) { tempa = xlate.charAt(i) if ( tempa == "[") { toggle = "true" i++ } else if ( tempa == "]") { toggle = "false" i++ } tempa = xlate.charAt(i) if (toggle == "true") { tempb = tempa } else if(tempa == "9") { tempb = "a" } else if(tempa == "a") { tempb = "b" } else if(tempa == "0") { tempb = "c" } else if(tempa == "c") { tempb = "d" } else if(tempa == "3") { tempb = "e" } else if(tempa == "b") { tempb = "f" } else if(tempa == "4") { tempb = "g" } else if(tempa == "?") { tempb = "h" } else if(tempa == "5") { tempb = "i" } else if(tempa == "6") { tempb = "j" } else if(tempa == "e") { tempb = "k" } else if(tempa == "+") { tempb = "l" } else if(tempa == "x") { tempb = "m" } else if(tempa == "7") { tempb = "n" } else if(tempa == "v") { tempb = "o" } else if(tempa == "1") { tempb = "p" } else if(tempa == "t") { tempb = "q" } else if(tempa == "q") { tempb = "r" } else if(tempa == "g") { tempb = "s" } else if(tempa == "n") { tempb = "t" } else if(tempa == "<") { tempb = "u" } else if(tempa == ">") { tempb = "v" } else if(tempa == "^") { tempb = "w" } else if(tempa == "!") { tempb = "x" } else if(tempa == "@") { tempb = "y" } else if(tempa == "#") { tempb = "z" } else if(tempa == "9") { tempb = "A" } else if(tempa == "a") { tempb = "B" } else if(tempa == "0") { tempb = "C" } else if(tempa == "c") { tempb = "D" } else if(tempa == "3") { tempb = "E" } else if(tempa == "b") { tempb = "F" } else if(tempa == "4") { tempb = "G" } else if(tempa == "?") { tempb = "H" } else if(tempa == "5") { tempb = "I" } else if(tempa == "6") { tempb = "J" } else if(tempa == "e") { tempb = "K" } else if(tempa == "+") { tempb = "L" } else if(tempa == "x") { tempb = "M" } else if(tempa == "7") { tempb = "N" } else if(tempa == "v") { tempb = "O" } else if(tempa == "1") { tempb = "P" } else if(tempa == "t") { tempb = "Q" } else if(tempa == "q") { tempb = "R" } else if(tempa == "g") { tempb = "S" } else if(tempa == "n") { tempb = "T" } else if(tempa == "<") { tempb = "U" } else if(tempa == ">") { tempb = "V" } else if(tempa == "^") { tempb = "W" } else if(tempa == "!") { tempb = "X" } else if(tempa == "@") { tempb = "Y" } else if(tempa == "#") { tempb = "Z" } else if(tempa == "}") { tempb = "1" } else if(tempa == "{") { tempb = "2" } else if(tempa == "(") { tempb = "3" } else if(tempa == "'") { tempb = "4" } else if(tempa == "|") { tempb = "5" } else if(tempa == "`") { tempb = "6" } else if(tempa == ":") { tempb = "7" } else if(tempa == ";") { tempb = "8" } else if(tempa == "=") { tempb = "9" } else if(tempa == ")") { tempb = "0" } else if(tempa == "R") { tempb = "~" } else if(tempa == "T") { tempb = "!" } else if(tempa == "F") { tempb = "@" } else if(tempa == "Y") { tempb = "#" } else if(tempa == "K") { tempb = "$" } else if(tempa == "J") { tempb = "%" } else if(tempa == "H") { tempb = "^" } else if(tempa == "G") { tempb = "&" } else if(tempa == "X") { tempb = "*" } else if(tempa == "V") { tempb = "_" } else if(tempa == "B") { tempb = "-" } else if(tempa == "M") { tempb = "+" } else if(tempa == "N") { tempb = "<" } else if(tempa == "U") { tempb = ">" } else if(tempa == "S") { tempb = "." } else if(tempa == "W") { tempb = "," } else if(tempa == ".") { tempb = "?" } else if(tempa == ",") { tempb = ":" } else if(tempa == "$") { tempb = ";" } else { tempb = tempa } xlation = document.form1.elements[5].value document.form1.elements[5].value = xlation + tempb } } Can anyone help me out in assigning more then one character? Multple characters work when going english to my custom assignments but it cant translate back from my custom assignments to english. hai....any of you got free javascripts text Translator code...i really need it ASAP..tq.. i got one but it not work very good when i put 1000++ words...example : Code: <script type="text/javascript"> function translate(phrase) { phrase = document.getElementById('input').value; phrase = phrase.replace(/why/g, "y"); phrase = phrase.replace(/are/g, "r"); phrase = phrase.replace(/you/g, "u"); phrase = phrase.replace(/for/g, "4"); phrase = phrase.replace(/to/g, "2"); document.getElementById('output').value = phrase; } </script> <textarea id="input"></textarea><br /> <input type="button" value="translate" onClick="translate();" /><br /> <textarea id="output"></textarea> I have tried using Microsofts translator widget but it messes up my menu that I wish it to sit beside, the widget is almost twice the height if my menu bar. I am after a widget that is just text and the user clicks it to open up a select language box. Does anyone have other widgets they use that is based on a single line selector not more than say 15px high or some thing like that ? hi all,, actually i used ajax api script.the problem is, the code works well in mozilla and other browser but in IE the dropdown list not showing.. its showing the error google/default+en.I.js line114 (c.g) object not defined.. the code is <script type="text/javascript" src="js/jquery.js"></script> <script src="js/jquery.translate-1.3.7.min.js" type="text/javascript"></script> <script type="text/javascript"> jQuery(function($){ //when DOM is ready $.translate(function(){ //when the Google Language API is loaded function translateTo( destLang ){ //this can be declared in the global scope too if you need it somewhere else $('body').translate( 'english', destLang, { //translate from english to the selected language not: '.jq-translate-ui, .header', //by default the generated element has this className fromOriginal:true //always translate from english (even after the page has been translated) }); } $.translate.ui('select', 'option') .appendTo('#aj') //insert the element to the page .change(function(){ //when selecting another language translateTo( $(this).val() ); return false; //prevent default browser action }); }); }); </script> <div id="aj"></div> I am trying to write a translator box for my website. So far, I've been able to get working code from a tutorial: Code: <input id="ori" type="text" /> <button onclick="translate();">Translate</button> <div id="trans"></div> <script> var languageFrom = "en"; var languageTo = "fr"; function translate() { document.getElementById('trans').innerHTML="Translating... please wait"; var text= document.getElementById('ori').value; window.mycallback = function(response) { document.getElementById('trans').innerHTML=response; } var s = document.createElement("script"); s.src = "http://api.microsofttranslator.com/V2/Ajax.svc/Translate?oncomplete=mycallback&appId=<MY-APP-ID>&from=" + languageFrom + "&to=" + languageTo + "&text=" + text; document.getElementsByTagName("head")[0].appendChild(s); } </script> (Script it from he http://wizardsoweb.com/microsoftbing...itcher=desktop) Basically, once I fill in my APPID, it will translate the text in the ori text box to French. Of course, this all works fine, but here's what I'm trying to do: I want there to be two drop down menus. One will populate the languageFrom variable with a specified language, and another drop down menu which will populate the languageTo variable with a specified language. I've already posted about this matter in a different post: http://stackoverflow.com/questions/8...from-drop-down (It's on stackoverflow). That way, when you select a value from the drop down menu, it populates the variable. I have a working example of this on jsFiddle: http://jsfiddle.net/charlescarver/hk2bJ/1/ (This includes my working API key so I it's easy to work on) SO, I think the problem with this is that the script which controls the translation is loaded when the variables are empty, and then doesn't update when a drop down option is selected. I think this can be fixed by calling the script when the button is clicked, instead of when the page is loaded. How can this be accomplished? The Microsoft support is poorly documented and I can't find a solution there or on google. Here's a link to the API documentation: http://msdn.microsoft.com/en-us/library/ff512385.aspx Where to put the <ol>&&</ol> tags so everytime i run the javascript it numbers each indivdiual items which the javascript is looping. Code: <table border="2"table align="center" cellpadding="40"> <tr> <th width="80%"> Questions & Time</th> <th>Status</th> </tr> <tr> <td><% for (int i=0; i < theList.size(); i++) {%> <tr> <td><%= theList.elementAt(i)+ " " + theTime.elementAt(i) %> <% }%> </td> <td>Where is the pending goes:</td> </tr> <tr> </table> I have the following HTML code: Quote: <form id="registration" action="/cgi-bin/registration.cgi" method="POST" onsubmit="return control()"> <fieldset> <legend>Legend 1</legend> <label>......</label> <input ..../><br/> <label>......</label> <input ....onclick="return orgreg()"/><br/> </fieldset> <fieldset> <legend>Legend 2</legend> <label>......</label> <input ..../><br/> <label>......</label> <input ..../><br/> <label>......</label> <input ..../><br/> <label>......</label> <input ..../><br/> <label>......</label> <input ..../><br/> </fieldset> ........ ........ and the following javascript code: Quote: function orgreg() { if (document.getElementById) { alert(document.getElementById("registration").firstChild); } } The output of alert window is [Object Text]. My question is: first child is first fieldset tag or not. Because I want insert (with insertBefore) an other fieldset block after first child. Okay, I am relatively new to Java and am going to be taking a class on it next fall. For now though, I am trying to code for a client I am currently working with and am hopelessly lost. The client I am working with has an ecommerce site with Network Solutions which uses aspx. It allows you to code html and link to css, java (pretty much anything except php). The problem I am having is that they currently have their product descriptions coded in div tags: <div id='alternatebg'> <div id='detailsgreybox'><div id='alternatename'><p>Alternate Name</p></div></div> <div id='pd2'><p>Not Available</p></div> </div> <div id='usebg'> <div id='detailsgreybox'><div id='use'><p>Use</p></div></div> <div id='pd3'><p>Chemicals</p></div> </div> What they want to happen is for the sections that have 'Not Available' as the answer to not show up on the live page. I have tried to use <ns:if condition="..."> but do not know how to call for it to see if the div says 'Not Available'. Any help is greatly appreciated as I can not move forward until I can figure this out. I came across some embedded JavaScript code and I noticed some weird “HTML comment-like tags” within embedded JavaScript that are getting rendered in FireFox but not IE. Specifically the closing tag "//-->" And the JavaScript code between these tags is functional (not commented out)! Code: <SCRIPT type=text/javascript> <!-- .... //--> </SCRIPT> What are these? Example usage: Code: <SCRIPT type=text/javascript> <!-- var zz, zv, d, fTSR; d = new Date(); fTSR=0; zv = d.getTime(); zz = "&zz="+zv; var gBF=false; function GoTo(u){window.top.location = u + zz;} function Go(u){window.top.location = u;} .... //--> </SCRIPT> Hi, I wanna make a form that receives: textbox URL And textbox Anchor and result will be two anchors one <a href, and one phpBB Example: Url: www.pushpin.co.il Anchor: pushpin Results: <a href="http://www.pushpin.co.il">pushpin</a> [ url = http://www.pushpin.co.il/ ] pushpin[ /url ] Help? How to I create the following code... Code: #moving { position:absolute; float:right; top:100px; left:50px; } #movingword { position:absolute; float:right; top:0px; left:0px; } ... and this code ... Code: <div id="movingword"> <font color="yellow"><font size="3"><b>This is the place</b></font><br>Welcome!</font> </div> ... programmatically using Javascript? (I will need a X number of "movingwords" and "moving", where X is a number and examples are "movingwords0", "movingwords1", "movingwords2" ... movingwordsX) Here the full code: Code: <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"> <html lang="en"> <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> <meta name="language" content="english"> <meta http-equiv="Content-Style-Type" content="text/css"> <script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.6.4/jquery.min.js"></script> <title></title> <style type="text/css"> body { background-color:#000; } #scenery { position:relative; } #moving { position:absolute; float:right; top:100px; left:50px; } #movingword { position:absolute; float:right; top:0px; left:0px; } </style> <script type="text/javascript"> var t=125; var l=20; $(document).ready(function() { document.getElementById("movingword").style.top = t + "px"; document.getElementById("movingword").style.left = l + "px"; }); </script> </head> <body> <font color=white><h1> Hello World </h1></font> <div id="scenery"> <img src="http://www.deshow.net/d/file/travel/2009-10/new-zealand-scenery-738-20.jpg" alt=""> <div id="moving"> <img src="http://cdn1.iconfinder.com/data/icons/gloss-basic-icons-by-momentum/32/bullet-yellow.png" alt=""> </div> <div id="movingword"> <font color="yellow"><font size="3"><b>This is the place</b></font><br>Welcome!</font> </div> </div> </body> </html> Is it possible to use Javascript to dynamically change the PHP file used for an include? For example, if I have a php doc like Code: <html> <body> <div>other stuff</div> <div> <?php include('onefile.php'); ?> </div> <div>more other stuff</div> </body> </html> I can get Javascript to remove the included stuff, but I can't figure out how to change the <?php include('onefile.php'); ?> into <?php include('otherfile.php'); ?>. What would be the best way to do that? hi i am totally frustrated !! i have been using this on my webpage. http://www.barelyfitz.com/projects/tabber/ if u see under the advanced section there is a code for changing tabs dynamically. Code: document.getElementById('mytab1').tabber.tabShow(0); this doesn't work. basically i have a webpage internet.htm. which has a menubar with loads of menu items. if i click one of the submenu items this code should change the dynamic tabs in admin.htm. the code i have defined for the submenu click is: Code: <li><a href="admin.htm" onClick="document.getElementById('Admin').tabber.tabShow(0)" >Forms</a></li> the full code is: Code: <ul id="QualityMenuBar" class="MenuBarHorizontal"> <li><a class="MenuBarItemSubmenu" href="#"><strong>Admin</strong></a> <ul> <li><a href="AdminDocuments.htm" onClick="document.getElementById("Admin").tabber.tabShow(0)" >Forms</a></li> <li><a href="AdminDocuments.htm" >Guidance</a></li> <li><a href="AdminDocuments.htm" onClick="document.getElementById("Admin").tabber.tabShow(2)" >Organisation Chart</a></li> <li><a href="AdminDocuments.htm">Plans</a></li> <li><a href="AdminDocuments.htm">Procedures</a></li> </ul> </li> this is what the admindocuments.htm contains, based on the website link i have borrowed the code from. Code: <div class="tabber" id="admin"> <div class="tabbertab"> <h2>Forms</h2> <script type="text/javascript" src="adminForms.js"></script> </div> <div class="tabbertab"> <h2>Guidance</h2> <script type="text/javascript" src="adminGuidance.js"></script> </div> <div class="tabbertab"> <h2>Org. Chart</h2> <script type="text/javascript" src="adminOrg.js"></script> </div> <div class="tabbertab"> <h2>Plans</h2> <script type="text/javascript" src="adminPlans.js"></script> </div> <div class="tabbertab"> <h2>Procedures</h2> <script type="text/javascript" src="adminProc.js"></script> </div> </div> whenever i click the submenu they all point to the first tab only. it doesn't change inspite of the code. what am i doing wrong here? please advice. Many thanks. Hello All. I'm trying to create a file upload page with pre-uploading preview, and using JS to change the images src upon selecting a local file. this works great, but unfortunatelly only for some image files, even though files were taken by the same camera,the same size, and created on the same date. I can't figure out for the life of me what is going on. The Code : <script> function changeImage(newSrc) var str = newSrc.toLowerCase(); cImg=document.getElementById("chngImg"); cImg.src=str; </script> <HTML> <BODY BGCOLOR="#FFFFFF"> <FORM METHOD="POST" ENCTYPE="multipart/form-data" ACTION="UploadScript1.asp" rel="nofollow" target="newWnd"> File 1:<INPUT TYPE=FILE NAME="FILE1" onchange="changeImage(this.value);"> <INPUT TYPE=SUBMIT VALUE="Upload!"> </FORM> <div><img src="oren1.jpg" id="chngImg"></div> </BODY> </HTML> Best Regards Oren Pildus I am embedding a flash photo gallery object in an html page. The flash gallery has a param "thumbVisibility" that allows you to set the visibility of the thumbnails with the options "NEVER" and "ALWAYS." I have it set to "NEVER" so that the thumbs do not show when the object loads. That is how I want it. However, I would like to build a javascript method to create a toggle button to switch between "NEVER" and "ALWAYS" so that the thumbnails can be turned on and off by the end user. As a first step, I know that javascript can be used to pass params to flash objects but as a js noob I haven't been able to find a clear and concise tut to figure out how to do this. Of course, the second step is how to do this in a function where I could switch between the two options using a single toggle button. I would greatly appreciate it if someone could suggest an approach to the javascript required to solve this problem. Thanks in advamce for your assistance. |