JavaScript - Javascript Function Not Called In Php
Hi guys,
calling a php page through AJAX. and it works Aok. I wanted the ajax backend php file to call a function in the front end page. even a simple alert from the backend php file wont work. Any help is greatly appreciated. My code to call the alert and parent's javascript functions are below. Simple alert Code: echo "<script language='javascript'>alert('Please Help Me');</script>"; Calling Front End Page Function Code: echo "<script language='javascript'>frontend_function();</script>"; Cheers Elabuwa Similar Tutorials(PS: I had no idea what to call this thread so, hopefully it's okay) I'm trying to make a time script for an app I'm making (this is not an HTML document; it's a .js file to be used with Titanium) however I'm having trouble getting the function to display and update. Code: function updateClock() { setInterval ( 'kiTime()', 1000 ); } function kiTime () { //Get current date and time var currentTime = new Date (); //Create variables for hours, minutes, and seconds from current time var currentHours = currentTime.getHours (); var currentMinutes = currentTime.getMinutes (); var currentSeconds = currentTime.getSeconds (); //Add a leading zero to minutes and seconds if less than ten currentMinutes = ( currentMinutes < 10 ? "0" : "" ) + currentMinutes; currentSeconds = ( currentSeconds < 10 ? "0" : "" ) + currentSeconds; //Create the string of time data currentTimeString = currentHours + ":" + currentMinutes + ":" + currentSeconds; return currentTimeString; } var win3 = Titanium.UI.createWindow({ title:'Clock', backgroundColor:'#fff' }); var tab3 = Titanium.UI.createTab({ icon:'clock.png', title:'Clock', window:win3 }); var label3 = Titanium.UI.createLabel({ color:'#999', text:updateClock(), font:{fontSize:20,fontFamily:'Helvetica Neue'}, textAlign:'center', width:'auto' }); win3.add(label3); If I use kiTime() under the text field I will get the current time (or at least the time the app was opened), however if I call updateClock() it's blank. Hi! I'm trying to run this script on Firefox. I'm copying and pasting the whole thing in here just to be safe, but I'm mostly concerned with getting the findLegendary function to call catchPok(). The script executes fine, goes into the battle, but then...does nothing. It runs the catchPok function if I manually click and deselect the "Find Legendary" window option, so alternately, if somebody knows how to make the program automatically click the element at that point to stop repeating the function (maybe?) and it works, I'd be just as happy with that. My best guess is that the autoContinue function might be interfering somehow, since it runs that portion of the code with the manual findLegendary shutoff, but to be honest I'm pretty clueless. What I want it to do is run the catch function through, catch the game pixel, and then go back to repeating. I don't care how this is accomplished as long as it can feasibly loop. The game rules allow botting, so this isn't against any site rules, either. Any and all help/advice is much appreciated! Code: // ==UserScript== // @name Pokemon Vortex Tool // @namespace vortexrising.tk // @include http://*pokemonvortex.org/* // @exclude http://*pokemonvortex.org/adv.php* // ==/UserScript== var legends = [ // Custom // Grass 'Shaymin (Sky)', 'Celebi', 'Latios', 'Latias', 'Rayquaza', 'Shaymin', 'Mew', 'Cresselia', 'Azelf', 'Uxie', 'Mesprit', 'Virizion', 'Genesect', // Grass (water) 'Manaphy', 'Phione', 'Suicune', 'Keldeo', // Ice 'Articuno', 'Suicune', 'Lugia', 'Regice', 'Kyurem', // Cave (land) 'Groudon', 'Arceus', 'Regigigas', 'Palkia', 'Dialga', 'Deoxys', 'Jirachi', 'Registeel', 'Regirock', 'Mewtwo', 'Cobalion', 'Terrakion', 'Virizion', 'Reshiram', 'Zekrom', 'Kyurem', 'Genesect', 'Tornadus', 'Landorus', // Cave (water) 'Kyogre', 'Lugia', 'Keldeo', // Ghost 'Mew', 'Giratina', 'Rotom', 'Mesprit', 'Azelf', 'Uxie', 'Celebi', 'Darkrown', 'Darkrai', // Electric 'Zapdos', 'Raikou', 'Jirachi', 'Darkrai', 'Darkrown', 'Thundurus', 'Zekrom', 'Genesect', // Fire 'Heatran', 'Ho-oh', 'Moltres', 'Entei', 'Reshiram', 'Victini' ]; var settings = { 'keys': ['autoBattle', 'findRare', 'findLegendary','catchPok','findNewpoke'], 'data': {}, 'save': function() { for (var i = 0; i < this.keys.length; i++) { GM_setValue(this.keys[i], this.data[this.keys[i]]); } }, 'load': function() { for (var i = 0; i < this.keys.length; i++) { this.data[this.keys[i]] = GM_getValue(this.keys[i], false); } } }; var movPos = 0; function moveAround() { movPos += 10; if (movPos > 360) { movPos = 0; } var xpos = parseInt(Math.sin(movPos * (Math.PI / 180))*10); var ypos = parseInt(Math.cos(movPos * (Math.PI / 180))*10); unsafeWindow.PlayRequest(xpos + 14, ypos + 14, parseInt(Math.random()*8)+1); /* var btnArrow = unsafeWindow.document.querySelector('#arrows img[onclick]') if (btnArrow) { btnArrow.click(); } else { unsafeWindow.console.info('No buttons?'); }*/ } function catchPok() { try { var btnPo = unsafeWindow.document.querySelector('#battleForm input[type="submit"][value="Continue"]'); if (btnPo) { btnPo.click(); } var radMaster = unsafeWindow.document.querySelector('#itemForm input[type="radio"][value="Master Ball"]'); if (radMaster) { radMaster.click(); } var btnItem = unsafeWindow.document.querySelector('#itemForm input[type="submit"][value="Use Item"]'); if (btnItem) { btnItem.click(); } var btnCont2 = unsafeWindow.document.querySelector('#battleForm input[type="submit"][value="Continue!"]'); if (btnCont2) { btnCont2.click(); } var linkReturnToMap = unsafeWindow.document.querySelector('.optionsList a'); if (linkReturnToMap && linkReturnToMap.textContent.trim() == 'Return to the Map') { settings.data.nextBattle = new Date().getTime() + 10000; unsafeWindow.location.href = linkReturnToMap.href; } }catch (e) { unsafeWindow.console.warn('Exception: ', e); } } function findNewpoke() { var aPoke = unsafeWindow.document.querySelector('#appear p'); var oldPoke = unsafeWindow.document.querySelector('#appear strong'); var searchPoke = unsafeWindow.document.querySelector('#alert p') if (!aPoke) { moveAround(); return; } else if (oldPoke) { moveAround(); return; } else if (searchPoke) { moveAround(); return; } else { var btnDo = unsafeWindow.document.querySelector('input[type="submit"][value="Battle!"]'); if (btnDo) { btnDo.click(); } catchPok(); return; } } function findLegendary() { var wildText = unsafeWindow.document.querySelector('#appear p'); if (!wildText) { moveAround(); return; } wildText = wildText.textContent.trim(); for (var i = 0; i < legends.length; i++) { if (wildText.match(legends[i])) { var btnDo = unsafeWindow.document.querySelector('input[type="submit"][value="Battle!"]'); if (btnDo) { btnDo.click(); } catchPok(); return; } } moveAround(); } function findRare() { var wildText = unsafeWindow.document.querySelector('#appear p'); if (!wildText) { moveAround(); return; } wildText = wildText.textContent.trim(); if (!wildText.match(/Wild (Shiny|Shaymin (Sky)|Celebi|Latios|Latias|Rayquaza|Shaymin|Mew|Cresselia|Azelf|Uxie|Mesprit|Virizion|Genesect|Manaphy|Phione|Suicune|Keldeo|Articuno|Lugia|Regice|Kyurem|Groudon|Arceus|Regigigas|Palkia|Dialga|Deoxys|Jirachi|Registeel|Regirock|Mewtwo|Cobalion|Terrakion|Reshiram|Zekrom|Tornadus|Landorus|Kyogre|Giratina|Rotom|Zapdos|Raikou|Darkrai|Darkrown|Thundurus|Heatran|Ho-oh|Moltres|Entei|Victini)/)) { moveAround(); return; } unsafeWindow.console.info('Rare found ', wildText); } function autoBattle() { try { var btnContinue = unsafeWindow.document.querySelector('#battleForm input[type="submit"][value="Continue"]'); if (btnContinue) { btnContinue.click(); } var btnContinue2 = unsafeWindow.document.querySelector('#battleForm input[type="submit"][value="Continue!"]'); if (btnContinue2) { btnContinue2.click(); } var btnAttack = unsafeWindow.document.querySelector('#battleForm input[type="submit"][value="Attack!"]'); if (btnAttack) { btnAttack.click(); } var linkReturnToMap = unsafeWindow.document.querySelector('.optionsList a'); if (linkReturnToMap && linkReturnToMap.textContent.trim() == 'Return to the Map') { settings.data.nextBattle = new Date().getTime() + 10000; unsafeWindow.location.href = linkReturnToMap.href; } // check for battle button var btnBattle = unsafeWindow.document.querySelector('#appear form input[type="submit"][value="Battle!"]'); var linkRebattle = unsafeWindow.document.querySelector('.optionsList a'); if (btnBattle) { // wait until 10 seconds since last battle //var delay = GM_getValue('lastBattle'); window.setTimeout(function() { btnBattle.click(); }, 10000); } else if (linkRebattle && linkRebattle.textContent.trim() == 'Rebattle Opponent') { window.setTimeout(function() { unsafeWindow.location.href = linkRebattle.href; }, 10000); } else { // if not found, click a direction var btnArrow = unsafeWindow.document.querySelector('#arrows img[onclick]') console.info('arrow', btnArrow); if (btnArrow) { btnArrow.click(); } } } catch (e) { unsafeWindow.console.warn('Exception: ', e); } } function autoContinue() { if (settings.data.findRare) { findRare(); } if (settings.data.autoBattle) { autoBattle(); } if (settings.data.findLegendary) { findLegendary(); } if (settings.data.catchPok) { catchPok(); } if (settings.data.findNewpoke) { findNewpoke(); } } unsafeWindow.AjaxRequest = function () { if (!this.xmlhttp) { try { // Try to create object for Firefox, Safari, IE7, etc. this.xmlhttp = new XMLHttpRequest(); } catch (e) { try { // Try to create object for later versions of IE. this.xmlhttp = new ActiveXObject('MSXML2.XMLHTTP'); } catch (e) { try { // Try to create object for early versions of IE. this.xmlhttp = new ActiveXObject('Microsoft.XMLHTTP'); } catch (e) { // Could not create an XMLHttpRequest object. return false; } } } } this.method = 'post'; this.async = true; this.url; this.query = ''; this.data = ''; this.reponseText; this.reponseXML; this.responseHandler; this.abortHandler; this.showLoading = false; this.send = function () { if (this.method && this.url) { var self = this; this.xmlhttp.onreadystatechange = function () { if (self.xmlhttp.readyState == 4) { if (self.xmlhttp.status && (self.xmlhttp.status == 200 || self.xmlhttp.status == 304)) { //unsafeWindow.console.info('success', self); self.responseText = self.xmlhttp.responseText; if (self.xmlhttp.responseXML) { self.responseXML = self.xmlhttp.responseXML; } else { self.responseXML = null; } if (self.responseHandler) { self.responseHandler(); var evt = document.createEvent('Event'); evt.initEvent('gm:ajaxhook', false, true); document.dispatchEvent(evt); //autoContinue(); } } else { showAlert('<p>An error occured while requesting the data.</p><p>Status Msg: ' + self.xmlhttp.statusText + '</p><p><input type="button" name="ok" value="OK" onclick="removeAlert();" id="alertFocus"></p>'); } if (self.showLoading && self.loading) { self.loading.style.visibility = 'hidden'; } } } if (this.showLoading) { this.displayLoading(); } this.xmlhttp.open(this.method, this.url + '?' + encodeURI(this.query), this.async); if (this.method == 'post') { this.xmlhttp.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded'); } this.xmlhttp.send(encodeURI(this.data)); } else { showAlert("<p>An error occured while requesting the data.</p><p>No method, URL, and/or query string provided.</p><p><input type=\"button\" name=\"ok\" value=\"OK\" onclick=\"removeAlert();\" id=\"alertFocus\"></p>"); } } this.abort = function () { this.xmlhttp.onreadystatechange = function () {}; this.xmlhttp.abort(); if (this.abortHandler) { this.abortHandler(); } } this.getFormValues = function (form) { for (i = 0; i < form.elements.length; i++) { switch (form.elements[i].type) { case 'text': case 'hidden': case 'password': case 'textarea': this.data += form.elements[i].name + "=" + form.elements[i].value + "&"; break; case 'checkbox': case 'radio': if (form.elements[i].checked) this.data += form.elements[i].name + "=" + form.elements[i].value + "&"; break; case 'select-one': this.data += form.elements[i].name + "=" + form.elements[i].options[form.elements[i].selectedIndex].value + "&"; break; } } this.data = this.data.substr(0, (this.data.length - 1)); } this.appendHTML = function (object, flag) { if (this.xmlhttp.responseText) { if (flag) { object.innerHTML = this.responseText; } else { object.innerHTML += this.responseText; } } else {} } this.displayLoading = function () { if (this.showLoading == 'sidebar') { this.loading = document.getElementById('sidebarLoading'); this.loading.style.height = document.getElementById('sidebar').offsetHeight - 2 + 'px'; this.loading.style.width = document.getElementById('sidebarContent').offsetWidth + 'px'; this.loading.innerHTML = '<p style="text-align: center; margin-top: 150px;"><img src="http://static.pokemonvortex.org/images/loading.gif" width="100" height="100" alt="Loading..." /></p>'; } else if (this.showLoading == 'message') // message { this.loading = document.getElementById('messageContent'); this.loading.style.height = document.getElementById('message').offsetHeight + 'px'; this.loading.style.width = document.getElementById('message').offsetWidth + 'px'; this.loading.innerHTML = '<p style="text-align: center; margin-top: 75px;"><img src="http://static.pokemonvortex.org/images/loading.gif" width="100" height="100" alt="Loading..." /></p>'; } else if (this.showLoading == 'messageList') // message list { this.loading = document.getElementById('messageList'); this.loading.style.height = document.getElementById('messageList').offsetHeight + 'px'; this.loading.style.width = document.getElementById('messageList').offsetWidth + 'px'; this.loading.innerHTML = '<p style="text-align: center; margin-top: 50px;"><img src="http://static.pokemonvortex.org/images/loading.gif" width="100" height="100" alt="Loading..." /></p>'; } else if (this.showLoading == 'map') // map { this.loading = document.getElementById('mapLoading') this.loading.innerHTML = '<p style="text-align: center; margin-top: 150px;"><img src="http://static.pokemonvortex.org/images/loading_white.gif" width="100" height="100" alt="Loading..." /></p>'; } else if (this.showLoading == 'live') { this.loading = document.getElementById('loading'); this.loading.style.height = document.getElementById('scroll').offsetHeight + 'px'; if (document.getElementById('scrollContent')) { this.loading.style.width = document.getElementById('scrollContent').offsetWidth + 'px'; } else { this.loading.style.width = document.getElementById('scroll').offsetWidth + 'px'; } this.loading.innerHTML = '<p class="large" style="margin-top: 75px; text-align: center;"><strong>Waiting for the other user to respond...</strong></p><p style="text-align: center;">You have been waiting <span id="waitTime">0 seconds</span>.</p>'; waitTime(0); } else // main { this.loading = document.getElementById('loading'); this.loading.style.height = document.getElementById('scroll').offsetHeight + 'px'; if (document.getElementById('scrollContent')) { this.loading.style.width = document.getElementById('scrollContent').offsetWidth + 'px'; } else { this.loading.style.width = document.getElementById('scroll').offsetWidth + 'px'; } this.loading.innerHTML = '<p style="text-align: center; margin-top: 150px;"><img src="http://static.pokemonvortex.org/images/loading.gif" width="100" height="100" alt="Loading..." /></p>'; } this.loading.style.visibility = 'visible'; } } function createToggler(container, title, varname) { var toggleEnable = unsafeWindow.document.createElement('p'); container.appendChild(toggleEnable); toggleEnable.innerHTML = title + ' <b>' + (settings.data[varname] ? 'Enabled' : 'Disabled') + '</b>'; toggleEnable.addEventListener('click', function() { settings.data[varname] = !settings.data[varname]; toggleEnable.innerHTML = title + ' <b>' + (settings.data[varname] ? 'Enabled' : 'Disabled') + '</b>'; settings.save(); autoContinue(); }, false); } function init() { var iframes = unsafeWindow.document.getElementsByTagName('iframe'); for (var i = 0; i < iframes.length; i++) { iframes[i].parentNode.removeChild(iframes[i]); } var sty = unsafeWindow.document.createElement('style'); unsafeWindow.document.querySelector('head').appendChild(sty); sty.textContent = '#fscctrl { background: green; border: 1px solid yellow; cursor:pointer; margin: auto; padding: 10px; width: 1010px; } #fscctrl p { margin: 0; } #alert{position:absolute; z-index: 1; background:#ffc; padding: 0 10px; right: 0; width: 100px;} #alert p { margin: 0; } #loading {z-index: 0; top: 0; height: 200px;} #loading p {margin-top:0 !important;} #header{ height: 70px; }'; unsafeWindow.disableSubmitButton = function(form) { for (i = 0; i < form.elements.length; i++) { if (form.elements[i].type == 'submit') { form.elements[i].value = 'Please Wait... or click again - by rockingdo'; } } return true; } settings.load(); document.addEventListener('gm:ajaxhook', function() { autoContinue(); }, false); var container = unsafeWindow.document.createElement('div'); unsafeWindow.document.body.insertBefore(container, unsafeWindow.document.body.firstChild); container.setAttribute('id', 'fscctrl'); createToggler(container, 'Auto-battle', 'autoBattle'); createToggler(container, 'Find Rare', 'findRare'); createToggler(container, 'Find Legendary', 'findLegendary'); createToggler(container, 'Catch Pokemon', 'catchPok'); createToggler(container, 'Find New Pokemon', 'findNewpoke'); autoContinue(); } init(); Hey everyone, I wanted to write my own script for a fade-in animation, since the ones I have found have got too many options or need some framework, which makes them unnecessarily big. I wanted to learn too. Unfortunately, the code didn't work as I wanted, and I commented some things so as to find out what's happening. The only function called from outside is fadeIn with a string as argument (in the example, this string is: d1296668690535). This is the code: Code: var fadems = 500; // Anim. duration in milliseconds var fps = 20; // Frames per second function fadeIn(elemId){ var frames = fadems/1000 * fps; var delay = 1000 / fps; var incrOp = 1 / frames; //document.getElementById(elemId).style.zoom = '1'; setOp(elemId, 0); for(i=1; i<=frames; i++){ debugOutLn("(fadeIn for) elemId = " + elemId); setTimeout("setOp(" + elemId + "," + incrOp*i + ")", delay*i); } } function setOp(elemId, val){ debugOutLn("(setOp) elemId = " + elemId + "; val = " + val); // document.getElementById(elemId).style.opacity = val; // document.getElementById(elemId).style.filter = 'alpha(opacity = ' + val * 100 + ')'; } Code: function debugOutLn(str){ document.getElementById("debug").innerHTML += str + "<br />"; } And this is the text it outputs (on Opera 11.01): Code: (setOp) elemId = d1296668690535; val = 0 (fadeIn for) elemId = d1296668690535 (fadeIn for) elemId = d1296668690535 (fadeIn for) elemId = d1296668690535 (fadeIn for) elemId = d1296668690535 (fadeIn for) elemId = d1296668690535 (fadeIn for) elemId = d1296668690535 (fadeIn for) elemId = d1296668690535 (fadeIn for) elemId = d1296668690535 (fadeIn for) elemId = d1296668690535 (fadeIn for) elemId = d1296668690535 (setOp) elemId = [object HTMLDivElement] ; val = 0.1 (setOp) elemId = [object HTMLDivElement] ; val = 0.2 (setOp) elemId = [object HTMLDivElement] ; val = 0.30000000000000004 (setOp) elemId = [object HTMLDivElement] ; val = 0.4 (setOp) elemId = [object HTMLDivElement] ; val = 0.5 (setOp) elemId = [object HTMLDivElement] ; val = 0.6000000000000001 (setOp) elemId = [object HTMLDivElement] ; val = 0.7 (setOp) elemId = [object HTMLDivElement] ; val = 0.8 (setOp) elemId = [object HTMLDivElement] ; val = 0.9 (setOp) elemId = [object HTMLDivElement] ; val = 1 Why is an object reference assigned to what was previously a string? Thanks for the help! Quote: http://codecanyon.net/item/html-befo...preview/153778 http://codecanyon.net/item/beforeaft...preview/529151 http://www.catchmyfame.com/2009/06/2...eafter-plugin/ I need this effect, I will explain below The first, we have if we slide on the left. when we slide on the right if we slide to END the result will be: OR It's use jquery plugin, I want to find the same things with only javascript, not use jquery. Because, I'm use it on ipod, iphone, android. It's not allow jquery. I'm really need it. please, help me. Thanks for your time Hi I want to build a site that has these two javascript effects. I know HTML, but dont know javscript too well, I know some to be able to change some aspects. I have found some code online that allws me to change the background image with each click of the links. the effect I now want to create is the effect that as you clikc on teh link and the new text appears, the old one drops down andthe new one pops up from the bottom into place. and you have a choice of either a big block ont eh right or a small strip on the bottom depending ont he page. what is this effect called. and does any one know where i might be able to get soem code for it from so i can insert it into my page I hope all this makes sense the site is http://www.peponi-lamu.com many thanks Firebug is giving me no error messages, but alert() message is never triggered. I want the alert() message defined below to alert what the value of the variable result is (e.g. {filter: Germany}). And it doesn't. I think the javascript breaks down right when a new Form instance is instantiated because I tried putting an alert in the Form variable and it was never triggered. Note that everything that pertains to this issue occurs when form.calculation() is called: markup: Code: <fieldset> <select name="filter" alter-data="dropFilter"> <option>Germany</option> <option>Ukraine</option> <option>Estonia</option> </select> <input type="text" alter-data="searchFilter" /> </fieldset> javascript (below the body tag) Code: <script> (function($){ var listview = $('#listview'); var lists = (function(){ var criteria = { dropFilter: { insert: function(value){ if(value) return handleFilter("filter", value); }, msg: "Filtering..." }, searchFilter: { insert: function(value){ if(value) return handleFilter("search", value); }, msg: "Searching..." } } var handleFilter = function(key,value){ return {key: value}; } return { create: function(component){ var component = component.href.substring(component.href.lastIndexOf('#') + 1); return component; }, setDefaults: function(component){ var parameter = {}; switch(component){ case "sites": parameter = { 'order': 'site_num', 'per_page': '20', 'url': 'sites' } } return parameter; }, getCriteria: function(criterion){ return criteria[criterion]; }, addCriteria: function(criterion, method){ criteria[criterion] = method; } } })(); var Form = function(form){ var fields = []; $(form[0].elements).each(function(){ var field = $(this); if(typeof field.attr('alter-data') !== 'undefined') fields.push(new Field(field)); }) } Form.prototype = { initiate: function(){ for(field in this.fields){ this.fields[field].calculate(); } }, isCalculable: function(){ for(field in this.fields){ if(!this.fields[field].alterData){ return false; } } return true; } } var Field = function(field){ this.field = field; this.alterData = false; this.attach("change"); this.attach("keyup"); } Field.prototype = { attach: function(event){ var obj = this; if(event == "change"){ obj.field.bind("change", function(){ return obj.calculate(); }) } if(event == "keyup"){ obj.field.bind("keyup", function(e){ return obj.calculate(); }) } }, calculate: function(){ var obj = this, field = obj.field, msgClass = "msgClass", msgList = $(document.createElement("ul")).addClass("msgClass"), types = field.attr("alter-data").split(" "), container = field.parent(), messages = []; field.next(".msgClass").remove(); for(var type in types){ var criterion = lists.getCriteria(types[type]); if(field.val()){ var result = criterion.insert(field.val()); container.addClass("waitingMsg"); messages.push(criterion.msg); obj.alterData = true; alert(result); initializeTable(result); } else { return false; obj.alterData = false; } } if(messages.length){ for(msg in messages){ msgList.append("<li>" + messages[msg] + "</li"); } } else{ msgList.remove(); } } } $('#dashboard a').click(function(){ var currentComponent = lists.create(this); var custom = lists.setDefaults(currentComponent); initializeTable(custom); }); var initializeTable = function(custom){ var defaults = {}; var custom = custom || {}; var query_string = $.extend(defaults, custom); var params = []; $.each(query_string, function(key,value){ params += key + ': ' + value; }) var url = custom['url']; $.ajax({ type: 'GET', url: '/' + url, data: params, dataType: 'html', error: function(){}, beforeSend: function(){}, complete: function() {}, success: function(response) { listview.html(response); } }) } $.extend($.fn, { calculation: function(){ var formReady = new Form($(this)); if(formReady.isCalculable) { formReady.initiate(); } } }) var form = $('fieldset'); form.calculation(); })(jQuery) Thanks for response. I have something that's called with AJAX when the user enters some text (http://askvoke.com). What I want is to execute some javascript within this "frame". If the frame calls something, with say
Code: <script type=\"text/javascript\"> document.write('h'); </script> in it, then "h" doesn't appear, and neither does anything besides what would normally be shown if I didn't add that. Anyone have a solution? Here is the structure I am working with as this html/script was created by the chmProcessor to produce WebHelp files... index.htm contains: Code: <iframe id="mainFrame" name="mainFrame" class="full" src= "frameset.html"> frameset.html contains: Code: <frameset cols="20%,80%"> <frame id="treeFrame" src="tree.html" name="treeFrame" /> <frame id="frameCont" src="2_Welcome.htm" name="Welcome" /> </frameset> tree.html is the navigational panel and contains: Code: <script type="text/javascript" src="tree.js"> </script> I have placed alert() calls in tree.js. When I load index.htm in Chrome, apparently tree.js is not being loaded because I do not see any alert box and the functionality within tree.js does not work. Note: The functionality does work in IE and Firefox If I open tree.html directly in Chrome, the tree.js functionality does get called. I do not know how to solve this problem or why Chrome is not loading the pages and script correctly. Thanks for your help! Hi, I am facing a problem in passing replace() function as an argument in user defined java function, can any one help me how to resolve it? intention is to pass a file path to my user defined function, but before passing the path i want to replace the character '\' to '\\' I am posting my javascript function he <a href="#" onclick="OpenDocPreview('<%# Eval("PATH")%>'.replace(/\\/g,"\\\\"), '<%# Eval("Filename")%>')"><%# Eval("DocTitle") %></a> function OpenDocPreview(url, docname) { alert('message from search base : ' + url + ' ' + docname); } thank you, I made a mouseover event of a caption on a picture, when I hover the opacity of the background color of the hover and the text goes down. What I want is that when I hover over the image which the caption is floating on, the onmouseover event gets activite. For an imaginary example: Code: function unhighlight(x) { x.style.backgroundColor="transparent" } Function ActivationFuction() { activate.function="unhighlight" } thanks How can I call a PHP Function inside a Javascript Function? This is what I have so far, but I don't think I'm doing it the right way. Any suggestions? PHP Code: <?php function phpQuery(){ $query = mysql_query("INSERT INTO mytable VALUES('','name','email')"); } ?> <script type="text/javascript"> function delayQueries() { timeoutID = window.setTimeout(doQueries, 2000); } function doQueries() { var runQuery = "<?php phpQuery(); ?>"; } </script> Hi everyone, I am pretty new at javascript OOP. I have a javascript file that has plenty of javascript functions, variables, arrays, etc. I need to convert this into an object. Here is an example: Code: var myvar1 = ''; var myvar2 = new array(); var myvar3 = new array(); var myvar4; var myvar5 = 60; var myvar6 = ''; function myfunc1(){ myvar1 = 'hello'; return myvar1; } function myfunc2(somenum=0){ myvar5 = somenum; //calling myfunc1() from within this function. //do something in here } function myfunc3(){ //calling myfunc1() from within this function. for(i=0;i<somelength;i++){ myvar2 = myvar3[i]; (something to put into the array) } } 1. I need to create an object and put ALL the varibles (myvar1 - myvar5) in that object. 2. Then the first two functions "myfunc1 and myfunc2" inside the same object. 2. And the function myfunc3 needs to sit OUTSIDE my object as a regular javascript function. It calls on myfunc1 (which is inside the object) and also inserts data into myvar2 (which is classified inside the object) and myvar3 (which is classified inside the object as well). This is what i came up with, but it's not going well: Code: var myobj1 = function(){ this.myvar1 = ''; this.myvar2 = new array(); this.myvar3 = new array(); this.myvar4; this.myvar5 = 60; this.myvar6 = ''; var myfunc1 = function(){ this.myvar1 = 'hello'; return this.myvar1; } var myfunc2 = function(somenum=0;){ this.myvar5 = somenum; //calling this.myfunc1() from within this function. //do something in here } } function myfunc3(){ //calling mynewobj.myfunc1() from within this function. for(i=0;i<somelength;i++){ mynewobj.myvar2 = mynewobj.myvar3[i]; (something to put into the array) } } var mynewobj = myobj1; HELP.....!!!! i really want to get into object oriented world, so thanks in advance. Im looking at how or what this effect is called i am not even sure if it is javascript i assume it is from looking at the code. But i cant seem to convert it to what i want. So if someone could point me to a more simple version of this code or what the technique is called that would be great. Here is the page. http://www.pizzacapers.com.au/the-me...nature-pizzas/ What i am talking about: You click the pizza and it comes up inside of the border picture on the left side of the page. Thanks Is there a particular term for writing functions in this manner? I'm interested in doing some reading up on it but don't quite know what to search for. Code: (function(msg){ document.write(msg); })("What's that smell?"); I apologize if I am posting this in the wrong section. I am looking for a code or script for a certain type of game but I can't even figure out what this type of game would be called. The game I am talking about is called "cryptopix" at tanga.com. I would really like to implement something like that on my website that members could create and participate in. If anyone can help point me in the right direction I would be forever grateful. I would assume it's a java script.
Anyone know of a better CLI base than the one I'm using? It's based off of http://sacrifizezone.blogspot.com/ ------------------------------ So, the way the CLI works is whenever it sees the input which has the matching ID of a DIV, it displays it. Example @ http://ijappy.webs.com/green You can download an early version of the soarce w/ the command "dl src"... It works great, for now, but as I add more & more commands I'm sure the INDEX file will surely begin to... be populated.. So I was wondering if anyone knew a way (using Javascript/Ajax/PHP I really don't care) to "PRINT" a files contents instead of showing a div. So when I typed in 'help' it looked up help.html and printed it's content... Is there such thing? Is this a bad concept? Please, help haha ;D ok ive searched everywhere online for a webform that is in 2 or more parts... example: (not asking for contact info yet) page 1: name age gender "start request button" (continued application) page 2: email address phone number best time to contact, etc... "submit button" saves info for next page to submit all info from both pages of application to a server etc. I know its possible, i just need to be put on the path... any help is much appreciated! If I use function or Function to create a javascript function, does it make any difference ? Whats the difference between two and in which situation shall I use either ? Likewise whats the difference between event and Event objects of JavaScript ? Thanks Ok, so basically what I've got is a button which when clicked, "opens" a section of the page. I also need the button to "jump" to this section of the page, because it's below the current content and won't be visible. What I've got so far is ... Javascript <script language="javascript"> function toggle() { var ele = document.getElementById("toggleText"); var text = document.getElementById("displayText"); if(ele.style.display == "block") { ele.style.display = "none"; text.innerHTML = "show"; } else { ele.style.display = "block"; text.innerHTML = "hide"; location="#ordernow" } } function moveWindow(){window.location.hash="ordernow"} </script> HTML ... (The rest of the form is up here) <input name="Button" type="button" class="button" value="Order Now" onclick="toggle();moveWindow()" id="displayText"/> ... (This is the start of the section that becomes visible, along with the anchor point which is highlighted in red.) <div id="toggleText" style="display: none"> <a name="ordernow"></a> <fieldset> <legend>Order Confirmation</legend> <div class="standardinput"> <label>Company:</label> <input name="Company" type="text" class="textinput" id="Company" /> </div> If I put two separate buttons, both functions will work. Basically I need them to be on the same function, not sure how to do that? Thanks so much in advance =) |