JavaScript - Calling A Custom Tag?
Hey guys, I'm trying to call the following custom tag: <mvt:item name="category_tree" /> from a JS function:
<script language="javascript" type="text/javascript"> <!-- function left_nav_bar () { document.write('Categories:'); document.write('<mvt:item name="category_tree" />'); } //--> </script> But the custom tag is not executing in the browser. Am I calling it wrong from my JS code? Similar TutorialsSo I'm new around here, and to web dev in general, but I've got a (hopefully) short question. I am trying to call a function (nextMonth()) every second from the time that the cycle method gets called, until it is called again. As of now I am trying to use setInterval, (and I previously tried with setTimeout and using a callback argument but maybe I wasn't doing that properly). The problem is that after running the cycle() method for 5 or 6 seconds, the entire browser freezes up and you have to kill it and restart it. Here is my code as of now: Code: function cycle() { if(CYCLEINT != null) //STOP THE CYCLE LOOP { window.clearInterval(CYCLEINT); CYCLEINT = null; document.getElementById("cycle").innerHTML = "Cycle Months"; } else //LOOP IS NOT RUNNING, INITIATE AND CONTINUE INTERVAL. { CYCLEINT = self.setInterval("nextMonth()", 1000); document.getElementById("cycle").innerHTML = "Pause"; } } function prevMonth() { var dVal = $( ".slider" ).slider( "option", "value"); if(dVal > 1) { dVal--; $( ".slider" ).slider( "option", "value", dVal ); refresh(); } } function nextMonth() { var dVal = $( ".slider" ).slider( "option", "value"); if(dVal < dateMax) { dVal++; $( ".slider" ).slider( "option", "value", dVal ); refresh(); } if(CYCLEINT != null && dVal >= dateMax) { cycle(); } } I've done a lot of work only to be stuck here at this problem. someone please help: Using the today variable as the parameter value, call the showDateTime() function and store the value returned by the function in the thisDay field of the eventform Web form. what exactly is this asking me to do? would you provide examples please? thanks in advance!@ Hi, I'm very new to Javascript and I need some help on calling some existing functions. What i want to do is create a new function to call the first test1 and then call test2 to turn on the checkbox. i hope this isn't confusing. Code: function test1(inStore,onSale,newItem) { var daURL; if (inStore==true) { BSSetStoreOnly(true); daURL="s-2-Online-Store.aspx?ms=bsm1"; if (onSale==true){ daURL+='&SaleOnly=1'; } } else { BSSetStoreOnly(false); daURL="s-1-Our-Products.aspx?ms=bsm1"; if(newItem==true) { daURL+='&NewOnly=1'; } } location=daURL; } function test2() { var pInc; chk=document.getElementById("chkAll"); pInc=readCookie("overrideURL"); if (pInc==null) { pInc=0; } if (pInc==0) { chk.checked=false; } else { chk.checked=true; } } function callingTest1Test2 { } in HTML you can call CSS Code: <head> <link rel="stylesheet" type="text/css" href="style.css" /> </head> <tr><td class="cssHere">Display</td></tr> can you even call CSS in javascript? Code: document.writeln("<tr><td class="cssHere">" + Display + "</td></tr>"); if so how do you even call the "style.css" thanks I'm using an XMLHttpRequest to call an XML document. Code: xmlhttp.open("GET","gallery.xml",false); xmlhttp.send(); var xmlDoc = xmlhttp.responseXML; var x = xmlDoc.getElementsByTagName("photo"); How do I retrieve a subset of the photo elements - for example, retrieve only those with "insect" in the category node? New here. The issue is this: I am trying to display two clocks. I used the javascript clock generator (http://rainbow.arch.scriptmania.com/...generator.html) to create both clocks. However, the same code to place in the html was given to call each clock; <script language="JavaScript">displayTime();</script>. Below is the code for both clocks. What can be changed so that each clock displays on my website? Clock 1: function timeSource(){ x=new Date(timeNow().getUTCFullYear(),timeNow().getUTCMonth(),timeNow().getUTCDate(),timeNow().getUTCHours (),timeNow().getUTCMinutes(),timeNow().getUTCSeconds()); x.setTime(x.getTime()+10800000); return x; } function timeNow(){ return new Date(); } function leadingZero(x){ return (x>9)?x:'0'+x; } function twelveHour(x){ if(x==0){ x=12; } return (x>12)?x-=12:x; } function displayOnTime(){ if(fr==0){ fr=1; document.write('<font size=1 face=verdana><b><span id="tP">'+eval(outputTime)+'</span></b></font>'); } document.getElementById('tP').innerHTML=eval(outputTime); setTimeout('displayOnTime()',1000); } function amPMsymbol(x){ return (x>11)?'pm':'am'; } function fixYear4(x){ return (x<500)?x+1900:x; } var dayNames=new Array('Sunday','Monday','Tuesday','Wednesday','Thursday','Friday','Saturday'); var monthNames=new Array('January','February','March','April','May','June','July','August','September','October','Novem ber','December'); var fr=0; var outputTime1="dayNames[timeSource().getDay()]+' '+timeSource().getDate()+' '+monthNames[timeSource().getMonth()]+' '+fixYear4(timeSource().getYear())+' '+':'+':'+' '+twelveHour(timeSource().getHours())+':'+leadingZero(timeSource().getMinutes())+':'+leadingZero(tim eSource().getSeconds())+' '+amPMsymbol(timeSource().getHours())"; Clock 2: function timeSource(){ x=new Date(timeNow().getUTCFullYear(),timeNow().getUTCMonth(),timeNow().getUTCDate(),timeNow().getUTCHours (),timeNow().getUTCMinutes(),timeNow().getUTCSeconds()); x.setTime(x.getTime()+daylightSaving()-18000000); return x; } function timeNow(){ return new Date(); } function daylightSaving(){ return ((timeNow().getTime()>findDay(0,2,3,2).getTime())&&(timeNow().getTime()<findDay(0,10,3,1).getTime()) )?3600000:0; } function findDay(d,m,h,p){ var week=(p<0)?7*(p+1):7*(p-1),nm=(p<0)?m+1:m,x=new Date(timeNow().getUTCFullYear(),nm,1,h,0,0),dOff=0; if(p<0){ x.setTime(x.getTime()-86400000); } if(x.getDay()!=d){ dOff=(x.getDay()<d)?(d-x.getDay()):0-(x.getDay()-d); if(p<0&&dOff>0){ week-=7; } if(p>0&&dOff<0){ week+=7; } x.setTime(x.getTime()+((dOff+week)*86400000)); } return x; } function leadingZero(x){ return (x>9)?x:'0'+x; } function twelveHour(x){ if(x==0){ x=12; } return (x>12)?x-=12:x; } function displayTime(){ if(fr==0){ fr=1; document.write('<font size=2 face=Arial><b><span id="tP">'+eval(outputTime)+'</span></b></font>'); } document.getElementById('tP').innerHTML=eval(outputTime); setTimeout('displayTime()',1000); } function amPMsymbol(x){ return (x>11)?'pm':'am'; } function fixYear4(x){ return (x<500)?x+1900:x; } var dayNames=new Array('Sunday','Monday','Tuesday','Wednesday','Thursday','Friday','Saturday'); var monthNames=new Array('January','February','March','April','May','June','July','August','September','October','Novem ber','December'); var fr=0; var outputTime="dayNames[timeSource().getDay()]+' '+timeSource().getDate()+' '+monthNames[timeSource().getMonth()]+' '+fixYear4(timeSource().getYear())+' '+':'+':'+' '+twelveHour(timeSource().getHours())+':'+leadingZero(timeSource().getMinutes())+':'+leadingZero(tim eSource().getSeconds())+' '+amPMsymbol(timeSource().getHours())"; Hello, I am new to using Javascript and have some experience with HTML and CSS. I am trying to use Javascript to display an image based on a value. I have the image positions in my .css. Just to make it easy if my var x=0 i want to call the "position 1" div, or else i want to call the "position 2" div. How can i make this possible. I have positions because i have a background image and i want the different pictures to be in a different location on the background based on the value. Below is my code that I have right now. Thanks for the help. layout.css #layout { position: relative; top:0%; z-inderx:-1; } #date { position: absolute; top:5%; left: 50%; margin-left: -190px; z-index: 1; font-family: calibri; font-size: 44px; font-weight: bold; color:#000000; } #location1 { position: absolute; top:22%; left: 50%; margin-left: -590px; z-index: 1; } #location2 { position: absolute; top:28%; left: 50%; margin-left: -590px; z-index: 1; } Layout.HTML <html> <head> <Title>Layout</title> <link rel"stylesheet" type="text/css" href="layout.css" /> </head> <body> <div id="layout"> <center> <img border="0" src="background.png" width="1200" height="880" /> </center> </div> <div id="date"> 24 OCTOBER </div> <script type="text/javascript"> var x=0; if (x==0) { <div id="location1"> <img border="0" src="picture1.png" width="70" height="60" /> </div> } else { <div id="location2"> <img border="0" src="picture2.png" width="70" height="60" /> </div> } </script> </body> </html> I would like to call a function within a function. Is this even possible?? When I do this I get "undefined" Here's my code: Code: <html> <head> <script type="text/javascript"> function product(a,b){ total = a*b; display(total); } function display(num){ return num; } </script> </head> <body> <h1>This text I do NOT want to be erased.</h1> <a href="http://google.com" target="_blank">Total: </a> <script type="text/javascript"> product(3,4); document.write(display()); </script> </body> </html> I know you can just return in the first function, "product()" but I would like to do something else in my second function "display()" then return a value. thanks Hi, How can i call a javascript alert function from an if condition in PHP? For instance: if (A == B) { CALL alert(); } thanks I need to create a form button named Create Resume. When clicked this button should call a function that generates a new Web page displaying a resume based on the user input. I am supposed to use the document.write() method to populate a newly generated Web page with all of the XHTML elements, formatting and variable values needed to produce the desired output in Web (.htm) format. I was hoping to get some guidance on how to accomplish this final step on my project. Any help would be greatly appreciated! KM <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <title>Web 115 Final Project</title> <meta http-equiv="content-type" content="text/html; charset=iso-8859-1" /> </head> <body> <script type="text/javascript" src="projectjs.js"> </script> <hr align="center" width="60%" /> </br> <script type="text/javascript"> document.write("<span style=\"font-family:garamond; text-align:center;font-size: 30px;\"> <p><b>Build Your Resume</b></p><\/span>"); </script> <form name="resume" method="get"> <p><input type="text" value="Enter your full name" size="50"/> </p><p> <input type="text" value="Enter your address" size="150"/> </p><p> <input type="text" value="Enter your phone number" size="50"/> </p><p> <input type="text" value="Enter your e-mail address" size="50"/> </p> <script language = "Javascript"> function echeck(str) { var at="@" var dot="." var lat=str.indexOf(at) var lstr=str.length var ldot=str.indexOf(dot) if (str.indexOf(at)==-1){ alert("Invalid E-mail ID") return false } if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at) ==lstr){ alert("Invalid E-mail ID") return false } if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot) ==lstr){ alert("Invalid E-mail ID") return false } if (str.indexOf(at,(lat+1))!=-1){ alert("Invalid E-mail ID") return false } if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot){ alert("Invalid E-mail ID") return false } if (str.indexOf(dot,(lat+2))==-1){ alert("Invalid E-mail ID") return false } if (str.indexOf(" ")!=-1){ alert("Invalid E-mail ID") return false } return true } function ValidateForm(){ var emailID=document.resume if ((emailID.value==null)||(emailID.value=="")){ alert("Please Enter your Email ID") emailID.focus() return false } if (echeck(emailID.value)==false){ emailID.value="" emailID.focus() return false } return true } </script> <p> <textarea id="tarea" cols="75" rows="4">Enter your personal information </textarea></p><p> <textarea id="tarea" cols="75" rows="4">Enter your career objectives </textarea></p><p> <textarea id="tarea" cols="75" rows="4">Enter your educational background </textarea></p><p> <input type="text" value="Most recent employment beginning and ending dates" size="50"/></p><p> <textarea id="tarea" cols="75" rows="4">Most recent employment experience</textarea> </p><p> <input type="text" value="Employment beginning and ending dates" size="50"/></p><p> <textarea id="tarea" cols="75" rows="4">Additional Employment Experience</textarea></p><p> <input type="text" value="Employment beginning and ending dates" size="50"/></p><p> <textarea id="tarea" cols="75" rows="4">Additional Employment Experience</textarea></p><p> <input type="text" value="Employment beginning and ending dates" size="50"/></p><p> <textarea id="tarea" cols="75" rows="4">Additional Employment Experience</textarea></p><p> <textarea id="tarea" cols="75" rows="4">Character References</textarea></p><p> <textarea id="tarea" cols="75" rows="4">Business References</textarea></p></br> <input type="button" name="push_button" value="Create Resume"/> </form> </body> </html> Can I clean up the header section on some of my pages by putting all the javascript stuff in another page, and then using a server side script to assemble the header? If so how do I do this? For example all my pages have the following in the header: <script type="text/javascript" src="css/csshorizontalmenu.js"></script> I want to have this in a seperate file and call with SSI but it doesnt work when I use something like the following: <?php require_once('navigation.php'); ?> Thanks for any help. I am able to do the following; Code: alert(myObject.Income.EESA.Name); However I'm looking at Code: alert(myObject.Income[0].Name); Or even better, not the full name, just "EESA". I need to loop through as you can see at the end of this script what I'm working on. Code: <script type="text/javascript"> var EESARate = 289.3; var DLARate = 111.20; var CARate = 61.35; var SkyCost = 54.75; var PerfectHomeCost = 28.17; var CreditExpertCost = 14.99; var UnitedUtilitiesCost = 8.13; var BTCost = 57.18; var AdobeCCCost = 46.88; var TVLicenceCost = 6.06; var GasCost = 10.00; var ElectricCost = 20.0; var ServerPackageCost = 9.99; var USDValue = 123; //Fetch the value var myObject = { "Income": { "EESA": { "Name": "Enhanced Employment and Support Allowance", "Amount": { "GBP": EESARate, "USD": EESARate * USDValue }, "Frequency": { "When": "14", "Next": "30/10/2014" }, "Description": "", }, "DLA": { "Name": "Disibility Living Allowance", "Amount": { "GBP": DLARate, "USD": DLARate * USDValue }, "Frequency": { "When": "7", "Next": "Wednesday" }, "Description": "", }, "CA": { "Name": "Carers Allowance", "Amount": { "GBP": CARate, "USD": CARate * USDValue }, "Frequency": { "When": "7", "Next": "Saturday" }, "Description": "", }, }, "Bills": { "Sky": { "Name": "Sky", "Amount": { "GBP": SkyCost, "USD": SkyCost * USDValue }, "Frequency": { "When": "30", "Next": "XX/XX/XX" }, "Description": "", }, "PerfectHome": { "Name": "Sky", "Amount": { "GBP": PerfectHomeCost, "USD": PerfectHomeCost * USDValue }, "Frequency": { "When": "7", "Next": "Wednesday" }, "Description": "", }, "CreditExpert": { "Name": "Experian Credit Expert", "Amount": { "GBP": CreditExpertCost, "USD": CreditExpertCost * USDValue }, "Frequency": { "When": "30", "Next": "XX/XX/XX" }, "Description": "", }, "UnitedUtilities": { "Name": "United utilities", "Amount": { "GBP": UnitedUtilitiesCost, "USD": UnitedUtilitiesCost * USDValue }, "Frequency": { "When": "7", "Next": "Wednesday" }, "Description": "", }, "BT": { "Name": "British Telecomunications", "Amount": { "GBP": BTCost, "USD": BTCost * USDValue }, "Frequency": { "When": "30", "Next": "XX/XX/XX" }, "Description": "", }, "AdobeCC": { "Name": "Adobe Creative Cloud Suite", "Amount": { "GBP": AdobeCCCost, "USD": AdobeCCCost * USDValue }, "Frequency": { "When": "30", "Next": "XX/XX/XX" }, "Description": "", }, "TVLicence": { "Name": "Television Licence", "Amount": { "GBP": TVLicenceCost, "USD": TVLicenceCost * USDValue }, "Frequency": { "When": "30", "Next": "XX/XX/XX" }, "Description": "", }, "Gas": { "Name": "Eon Gas", "Amount": { "GBP": GasCost, "USD": GasCost * USDValue }, "Frequency": { "When": "7", "Next": "Wednesday" }, "Description": "", }, "Electric": { "Name": "Eon Electric", "Amount": { "GBP": ElectricCost, "USD": ElectricCost * USDValue }, "Frequency": { "When": "7", "Next": "Wednesday" }, "Description": "", }, "ServerPackage": { "Name": "1&1 Unlimited Plus (12 mo. term)", "Amount": { "GBP": ServerPackageCost, "USD": ServerPackageCost * USDValue }, "Frequency": { "When": "30", "Next": "XX/XX/XX" }, "Description": "", }, }, }; var IncomeTotal = 0; for (var k in myObject.Income) { if (myObject.Income.hasOwnProperty(k)) { ++IncomeTotal; } } alert(myObject.Income.EESA.Name); document.write('<table>') for(i = 0; i < IncomeTotal; i++){ document.write('<tr>') document.write('<td>row ' + (i+1) + ', column 0</td>') document.write('</tr>') } document.write('</table>') var TotalBills = 0; for (var k in myObject.Bills) { if (myObject.Bills.hasOwnProperty(k)) { ++TotalBills; } } //alert(TotalBills); </script> I am in a class that is right now creating an online quiz that is also displays time. The part I am running into a wall right now is "Call the runClock() function every second, storing the ID of this timed-interval command in the clockId variable." I am unsure how to call it every second. Also, how would I call a function within a function? Here is my code so far: <link href="quiz.css" rel="stylesheet" type="text/css" /> <script src="functions.js" type="text/javascript"></script> <script type="text/javascript"> var seconds = 0 var clockID = function runClock() { clockID = seconds++; document.getElementById("quizclock").value = seconds; } function startClock() { return showQuiz; } </script> </head> I am looking for a custom pop up box, but there is only 3 kinds (Alert, Confirm, Prompt). Neither of those will work. This is what I want to do. http://www.youtube.com/watch?v=zr0F6elv-vg Hi Everyone, I am not able to figure out why the function "changeDiv(the_div,the_change)" is not called from the for loop in the function displayUsers(keeper)that I generated. The displayUsers is written to get rid of excess code in the function display(keeper). Can someone, please point out what the mistake is? Code: function changeDiv(the_div,the_change) { var the_style = getStyleObject(the_div); if (the_style != false) { the_style.display = the_change; } } function getStyleObject(objectId) { if (document.getElementById && document.getElementById(objectId)) { return document.getElementById(objectId).style; } else if (document.all && document.all(objectId)) { return document.all(objectId).style; } else { return false; } } //Shows input information for # of users selected function displayUsers(keeper) { var display=keeper; var i,user; for(i=1;i<= display;i++) { user="user"+i; changeDiv('user','block'); } } /*function display(keeper) { if (keeper == 1) { changeDiv('user1', 'block'); changeDiv('user2', 'none'); changeDiv('user3', 'none'); changeDiv('user4', 'none'); changeDiv('user5', 'none'); changeDiv('user6', 'none'); changeDiv('user7', 'none'); changeDiv('user8', 'none'); changeDiv('user9', 'none'); changeDiv('user10','none'); } else if (keeper == 2) ... ... ... else { changeDiv('user1', 'none'); changeDiv('user2', 'none'); changeDiv('user3', 'none'); changeDiv('user4', 'none'); changeDiv('user5', 'none'); changeDiv('user6', 'none'); changeDiv('user7', 'none'); changeDiv('user8', 'none'); changeDiv('user9', 'none'); changeDiv('user10','none'); } }// end function display(keeper)*/ I almost have the website finished, at least functionally (the complicated backend). It will arguably be one of the coolest history sites on the web. But I am running into some technical problems, and want to ask you about them, as I am at a point where that is my only alternative. First is in the website: http://184.73.182.71/timelines/search2.fwx There is the line: Timeline.loadXML("http://184.73.182.71/14OZH01XY.xml", function(xml, url) { eventSource.loadXML(xml, url); }); This is loading an XML data file into the time-line, and it works fine. The question is, why cant I dynamically load this data from a process, like: Timeline.loadXML("http://184.73.182.71/getdata.php?page=10", function(xml, url) { eventSource.loadXML(xml, url); }); It is returning the exact same thing, yet it dosent work. Somebody suggested the following: eventSource.loadXML(eventSource.loadXMLText(xmlstring,),"http://184.73.182.71/getdata.php?page=10"); But that dosent seem to work either. And can I do the same thing with a script tag, such as: <script src="http://184.73.182.71/getdata.php?page=10" type="text/javascript"></script> Is this illegal? Thanks in advance for looking at this. Code: <form> <input type="button" value="Click!" id="001" /> </form> function one() { window.alert('Hello'); window.alert('World!'); } var varname=document.getElementById("001"); varname.onclick=one; I am not sure if the last line is this example is correct. Should it not be: varname.onclick=one(); Or is it ok to write it either way? Thanks. Hi, I would like to do something like this: Code: function searchLocations(count) { var found = false; var input = document.getElementById('autocomplete').value; var inp = input.toLowerCase(); var count = 0; for (var j = 0; j < gmarkers.length; j++) { gmarkers[j].hide(); var str=gmarkers[j].myname.toLowerCase(); var patt1=inp; if (str.match(patt1)) { found = true; gmarkers[j].show(); count++; } } if (count==1) myclick(j); if (count>1) centerZoom(); if ( ! found ) alert("No matches found. Please check your spelling or refine your search."); } on this page here, but the functions - myclick(j); and centerZoom(); aren't getting called. I tried it with switches here, but that only made things worse. I know the functions work because if I put them two } up, they get called, but that takes them out of the if statements. Those if (count...) statements have to be where they are so that "count" will get the right value. Any ideas? Hi. Firstly, i apologise for this being a google maps related question but the problem is a regular javascript question i believe, and it's really frustrating me. As i'm sure you're aware that with the maps you can click on a red 'marker' and make an info box pop up. I'm trying to do this with a text link outside of the map. My problem is calling that script via the text link. i really can't see what i'm doing wrong; my html link Code: <a href="javascript;" onmouseover="marker.openInfoWindowHtml();">test</a> and the javascript from the map Code: GEvent.addListener(marker, "click", function() { marker.openInfoWindowHtml(); }); I'm sure it's something simple but i've been trying variations for hours and I can't get my head around it. Anyone with any ideas would be an absolute star. Cheers, Pat. i now have <a href=""javascript:NewCssCal('repaymentdate','ddMMyyyy')""> how can I have this after it calls teh newcsscal and fills in the textbox call another function. (i don't want to add it to newcsscal as that's used in multiple locations and I only need to call this function in 1 location. |