JavaScript - Need Help Passing Variable To Return Array Value
I need to get this script to work, I only included what im having the problem with.
I am Using jQuery Library. Here is how this should work: .btnRoof div is clicked the parent id is retrieved as var pid a function called roof is called which simply changes a css background to "color" the function perform is called to get the "color1[0]" from the array. My Problem: perform() returns the word color1, color10, color1[0], or c. instead of images/cp-roof-blue.png as listed in the array. Code: $(document).ready(function() { var color1=new Array(); color1[0]="images/cp-roof-blue.png"; color1[1]="images/cp-panel-blue.png"; color1[2]="images/cp-trim-blue.png"; function perform(name, x) { alert(name[x]); //alert([name][x]); //alert(name+'['+x+']'); //alert(color1[0]); // correct return name[x]; } function Roof(color) { $("#colorPicker .roof").css("background", "url("+color+")"); } $('.btnRoof').click(function() { var pid = $(this).parent().parent().attr("id"); Roof(perform(pid, 0)); }); }); I tried to clarify as much as possible, please let me know if I need explain further. Thanks. Similar TutorialsI have inherited some code, and cannot get it to work. Note the bold section in the OBJECT tag below. I believe this is where the issue is. Code: <script language="JavaScript"> var camArray = new Array(); camArray['Dolliver'] = "http://video.dot.ca.gov/asx/D5-Bello-at-101.asx"; camArray['Mattie'] = "http://video.dot.ca.gov/asx/D5-Mattie-Rd-at-101.asx"; camera="Dolliver"; var camHTMLd = "<object id='MediaPlayer' width=320 height=240 classid='CLSID:22D6f312-B0F6-11D0-94AB-0080C74C7E95' standby='Loading Windows Media Player components...' type='application/x-oleobject' codebase='http://activex.microsoft.com/activex/controls/mplayer/en/nsmp2inf.cab#Version=6,4,7,1112'><param name='filename' value='"+camArray[camera]+"'><param name='Showcontrols' value='False'><param name='autoStart' value='True'><embed type='application/x-mplayer2' src='"+camArray[camera]+"' width=320 height=240></embed></object>" function changeCam(camera){ document.getElementById("caltransCamera").innerHTML = camHTMLd; //alert(camHTMLd+camArray[camera]); } </script> Then in the page, I have the following code: <a href="javascript:changeCam('Mattie');">101 at Mattie Road</a> It SHOULD open and start displaying the MATTIE cam, but it reloads the default Dolliver. What am I missing? Thank you in advance. Please help, I have been looking at this all day and I know there must be a simple fix! How do I pass results back to textService so that I can make a call such as textResult = textService(text to pass in); I don't want to use a global variable if I can avoid it. This is the code Code: function textService(text){ req.open("GET", "http://....?text="+text, true); req.onload = showResults; req.send(null); } function showResults() { results = req.responseXML.getElementsByTagName("Result"); } Thank you in advance I have a project that uses and Ajax call but it appears that the call back function cannot take arguments, nor return values. However, I have wrapped another function inside the call back function that takes xmlhttp.responseText as the argument and returns values that are supposed to be placed in a global array. If I do, for instance: callback function code.... globalArray = someFunction(xmlhttp.responseText) alert(globalArray), I get the expected values. but a function is called later to query the contents of the global array the global array is empty (No other code or functions exist in this project to alter the global array) Primary dev client is FireFox 3x on Mac OSX Is this a bug, or is there some other aspect of javascript that I need to know about? I am using ajax here because javascript does not have an array shuffling function and php does. So I send an array to the server, have it shuffled by the server and returned to the requesting page. Hi, I am looking for some help with function below, the $date variable will for months 01-09 return a value of 1-9 leaving out the 0 numerator Code: function reformatDate($Date) { var $date = $Date; months = ["01", "02", "03", "04", "05", "06", "07", "08", "09", "10", "11", "12"]; var parts = $date.split("/"); var m = parts[0]; for ( var i = 0; i < months.length; i++ ) { if (months[i] == m ) { var month = i; } } $date = parts[2] + "-" + (month+1) + "-" + parts[1]; // +1 needs to be appended to month as JavaScript month starts at 0 _log("Date " + $date); //test date is in correct format return $date; } so in above example if i pass a date 01/02/2015 it will return 2015-1-02 whereas i want it to return 2015-01-02 for the purposes of the function i need the $date to return 01,02,03 etc also can anyone explain why the zero is dropped before each number? Reply With Quote 01-22-2015, 03:39 PM #2 sunfighter View Profile View Forum Posts Senior Coder Join Date Jan 2011 Location Missouri Posts 4,830 Thanks 25 Thanked 672 Times in 671 Posts Problem is he Code: for ( var i = 0; i < months.length; i++ ) { if (months[i] == m ) { var month = i; // YOU SET THIS TO A SINGLE DIGIT. USE var month = months[i]; } I'm trying to pass the following variables.
Code: var hours; var mins; in the below code, however I can't get the value but keep getting values don;t exist. here is all the code 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>Classic Example</title> <script type = "text/javascript"> var totalhrs = (2* 3600); var totalmin = (180* 60); var totaltime = (totalhrs + totalmin); var timeInSecs; var ticker; var p = true; function pauseTimer() { if (p) {p=false} else { p = true; tick(); } } function startTimer(secs){ timeInSecs = parseInt(secs); ticker = setInterval("tick()",1000); } function tick() { var secs = timeInSecs; if (p) { if (secs>0) { timeInSecs--; } else { document.getElementById("but1").disabled = false; clearInterval(ticker); // stop counting at zero } } var hours= Math.floor(secs/3600); secs %= 3600; var mins = Math.floor(secs/60); secs %= 60; var result = ((hours < 10 ) ? "0" : "" ) + hours + ":" + ( (mins < 10) ? "0" : "" ) + mins + ":" + ( (secs < 10) ? "0" : "" ) + secs; document.getElementById("countdown").innerHTML = result; } </script> </head> <body onload="startTimer(totaltime);"> <script type="text/javascript"> document.write('<a href="another_page.php?mins='+mins+'&hrs='+hours+'">test link</a>'); </script> <p><span id="countdown" style="font-weight: bold;"></span></p> </body> </html> I'm trying to capture the 2 noted variables above in the simple link, Code: <script type="text/javascript"> document.write('<a href="another_page.php?mins='+mins+'&hrs='+hours+'">test link</a>'); </script> I think this is what I am trying to do, I am pretty new to javascript so I'm not sure... but here is my question... I got this function below. Code: function getProductInfo(id) { var sku = window.document.InvoiceForm.Item0Sku.value; alert(sku); } when I use the 0 I get the right value back, however whenever I try to pass it the id variable with a value of '0' I can't seem to compose the concatenation correct in order to recieve the correct value. I either recieve errors or the whole window.document.InvoiceForm.Item0Sku.value string back in the alert, what am I doing wrong? What's the most efficient way of me getting all the IDs from the following array (ideally returned in its own array) when the colour = 1? I know I could use a for loop with an if statement in it, but wondered if there was anything better in terms of speed and/or neat code? Thanks in advance. var directions = [ { id: 1, towards: "Manchester", colour: 1 }, { id: 2, towards: "Sheffield", colour: 1 }, { id: 3, towards: "London", colour: 2 }, { id: 4, towards: "Glasgow", colour: 2 }, { id: 5, towards: "Leeds", colour: 3 }, { id: 6, towards: "Derby", colour: 3 } ]; Reply With Quote 12-19-2014, 11:34 PM #2 Old Pedant View Profile View Forum Posts Supreme Master coder! Join Date Feb 2009 Posts 28,311 Thanks 82 Thanked 4,754 Times in 4,716 Posts Why not use a filter? Code: var chosen = directions.filter( function(val) { return val.colour == 1; } ); Of course, that does a loop behind the scenes, but it should be faster than a JS for loop. Its a ads rotation code: Don know why it doesnt work... Code: <body> <div align="center"> <script> var brw=navigator.appName; var id; if(brw == "Netscape") id=1; if(brw =="Microsoft Internet Explorer") id=2; if(brw == "Opera") id=3; var delay=10000; var k=0; var fcontent=new Array(); var b=new Array(); function go(k) { b[0]='' b[1]='<iframe src="http://........." width="460" height="60" scrolling="no" name="cpm" frameborder="0"></iframe>' b[2]='<iframe width="468" height="60" allowtransparency="false" frameborder="0" hspace="0" vspace="0" marginheight="0" marginwidth="0" scrolling="no" src="http://............"></iframe>' b[3]='<iframe width="468" height="120" allowtransparency="false" frameborder="0" hspace="0" vspace="0" marginheight="0" marginwidth="0" scrolling="no" src="http://............"></iframe>' if(id != 3) b[4]='<iframe width="1" height="1" allowtransparency="false" frameborder="0" hspace="0" vspace="0" marginheight="0" marginwidth="0" scrolling="no" src="http://......."></iframe>' else b[4]='' b[5]='..' ..... ..... b[36]='.... ' return; } begintag='<div style="font: normal 14px Arial; padding: 5px;">'; //set opening tag, such as font declarations fcontent[0]=b[0]+b[1]+b[2]+b[3]+b[4]+b[5]; fcontent[1]=b[6]+b[7]+b[8]+b[9]+b[10]; fcontent[2]=b[11]+b[12]+b[13]+b[14]+b[15]; fcontent[3]=b[16]+b[17]+b[18]+b[19]+b[20]; fcontent[4]=b[21]+b[22]+b[23]+b[24]+b[25]; fcontent[5]=b[26]+b[27]+b[28]+b[29]+b[30]; fcontent[6]=b[31]+b[32]+b[33]+b[34]+b[35]; fcontent[7]=b[0]+b[36]; closetag='</div>'; var ie4=document.all&&!document.getElementById; var DOM2=document.getElementById; var index=0; //function to change content function changecontent(){ if (index>=fcontent.length ) { index=0; ++k;delay=delay+5000; } go(k); if(delay>15000){return;} if (DOM2){ document.getElementById("fscroller").innerHTML=begintag+fcontent[index]+closetag } else if (ie4) { document.all.fscroller.innerHTML=begintag+fcontent[index]+closetag; } ++index; setTimeout("changecontent()", delay); } if (ie4||DOM2) document.write('<div id="fscroller" style="width:700px;"></div>'); if (window.addEventListener) window.addEventListener("load", changecontent, false) else if (window.attachEvent) window.attachEvent("onload", changecontent) else if (document.getElementById) window.onload=changecontent </script> </div> </body> here go(k); function might do this mass (output-->NaN). plz b a help... I have a function which is currently called twice on the same page. Part of the function is to apply an onkeyup event to a created element. The problem is that when the function is called twice the first created element calls the onkeyup function of the second element! table_JD.length-1 = 0 for first element table_JD.length-1 = 1 for second element updateSearch_TC_JD(1) is somehow called from first element! Code: newSearchBox.onkeyup = function() {updateSearch_TC_JD(table_JD.length-1)} Thanks for any help you can provide! Hi, I'm having one javascript function which will return the variable and I need to pass that variable to command button action.Please find the below code and let me know how I can achieve this. <script> function addEntry(entries) { var uploadedEntry = entries[0].entryId; alert("Uploaded Entry Details::::" + uploadedEntry ); } </script> <h:commandButton tabindex="1" image="../img/submit.gif" action="#{portfolioListing.uploadMediaEntry(uploadedEntry)}" Thanks, Anil Hello Can i pass php Variable into javascript function like this example. PHP Code: <script type="text/javascript"> <!-- function confirmation() { var answer = confirm("are u sure?") if (answer){ window.location = "user.php?action=statusd&uid=".$row['id'].""; } else{ alert("Canceled") } } //--> </script> This ".$row['id']." will be an user id ... link PHP Code: <a href='#' onclick='confirmation(); return false;'>Go</font></a> Hi, I am having trouble passing the correct id to change the innerHTML. I have a jsp that display people and their address information. There could be several people in the list, so it is in a loop. That part all works good. There is a drop down list with countries in them. Based on the country they select, I want to change some of the text. Here is what I have: Code: <tr> <td class="datashaded" valign="top"><font size="2"><b>Country:</b></font></td> <td class="datashaded" valign="top"> <select tabindex="<%=countryTab%>" name="<%=country%>" size=1" onChange="changeText(this.form.<%=country%>, this.form.<%=addressLabel%>, this.form.<%=zipLabel%>);"> <% for (int i =0; i < countryList.size(); i++ ) { String countryOption = (String)countryList.get(i); String countryVal = bene.getAddress().getCountry(); String selected = ""; if ( countryOption.equalsIgnoreCase( countryVal ) ) selected = "selected"; %> <option value="<%=countryOption %>" <%=selected%> ><%=countryOption%></option> <% } %> </select> </td> </tr> <tr> <td class="datashaded"><div id="addr1"><font size=2><b id="<%=addressLabel%>">Address:</b></font></div></td> <td class="datashaded"> <input size=20 maxlength="50" tabindex="<%=add1Tab%>" name="<%=address1%>" value="<%=address1Value%>" </td> </tr> Everytime through the loop, addressLabel has an index added to it so it is unique - so I can refer to each person separately. Here is the js function: Code: function changeText(sel, txtField1, txtField2) { var selectedValue = sel[sel.selectedIndex].value; if ( selectedValue == "<%=IParticipantConstants.BENEFICIARY_COUNTRY %>") { document.getElementById(txtField1).innerHTML = 'Address:'; document.getElementById(txtField2).innerHTML = 'Zip:'; } else { document.getElementById(txtField1).innerHTML = 'Street or P.O. Box'; document.getElementById((txtField2).innerHTML = 'Postal Code:'; } } When I hardcoded the id= value, not matter which group I changed the country on, only the first one was changing, so I knew I needed unique ids for each group. There is more to the table, but this is the good part. When the onChange fires now, Nothing at all happens. Can anyone see the problem?? Thanks for looking! I've been staring at this same problem for over a week now. I've worked around it as best as i can but i think it's time to ask someone else for input. I'm trying to pass a value thru an ajax parameter.. that's all. it SHOULD be easy in theory. what i want to do is create a jscript variable then pass that variable as the value for a parameter. php then converts that value to something it can use to finish the rest of my code. As i said it's hindering my webpage progress and i would like to get it fixxed soon so any help would be appreciated. Code: function getSelection() { var selection=document.getElementsById("SelectedItem"); var xmlhttp;//create a var for the obj if (window.XMLHttpRequest)//if requesting an obj... { // code for IE7+, Firefox, Chrome, Opera, Safari xmlhttp=new XMLHttpRequest(); } else if (window.ActiveXObject) { // code for IE6, IE5 xmlhttp=new ActiveXObject("Microsoft.XMLHTTP"); } else { alert("Your browser does not support XMLHTTP!"); } xmlhttp.onreadystatechange=function() { if(xmlhttp.readyState==4) { var text = xmlhttp.responseText; addNode(text); } } xmlhttp.open("GET","battle_nin.php?selection",true); xmlhttp.send(null); } //the php snippet $currentjutsu=$_GET[selection]; google is not my friend on this one if I wanted to set a variable with radio buttons to decide whether a function adds or subtracts, I know I can't do this: Code: <body> <input type="radio" name ="op" onclick="op='-'">count up: <input type="radio" name ="op" onclick="op='+'"> <script type="text/javascript"> var op; function calc() { start=start op 1000; } </script> </body> but is there something I can do, without getting all if/elsey? Hey there, I'll explain what I'm trying to do. I have a back-to-top button on my website that will only appear after the user is 500px down the page. I'd like to be able to change that 500px value to whatever the users window height is. I have a code that retrieves the users window height and will echo it wherever I place the script on my page: Code: <script> var winW = 800, winH = 600; if (document.body && document.body.offsetWidth) { winW = document.body.offsetWidth; winH = document.body.offsetHeight; } if (document.compatMode=='CSS1Compat' && document.documentElement && document.documentElement.offsetWidth ) { winW = document.documentElement.offsetWidth; winH = document.documentElement.offsetHeight; } if (window.innerWidth && window.innerHeight) { winW = window.innerWidth; winH = window.innerHeight; } document.writeln(+winH); </script> I'll also post the script for the back-to-top button: Code: <script type="text/javascript" src='<?php bloginfo('template_url'); ?>/js/jquery.min.js'></script><script> $(document).ready(function(){ // hide #back-top first $("#back-top").hide(); // fade in #back-top $(function () { $(window).scroll(function () { if ($(this).scrollTop() > 500) { $('#back-top').fadeIn(); } else { $('#back-top').fadeOut(); } }); // scroll body to 0px on click $('#back-top a').click(function () { $('body,html').animate({ scrollTop: 0 }, 800); return false; }); }); }); </script> In that first code, it seems like the value +winH is what I need to use. The line document.writeln(+winH); merely prints the value as text on my page. Now in this second piece of code there's two numeric values. The second, 800, is the speed that the page scrolls back to the top. The first value, 500, is the value I want to replace. Can anyone guide me through how I might combine these two scripts to work together? I'm more of an actionscript person but got roped into an html/javascript job. What I need to do, and it shouldn't be that difficult is this: page1.html - there is a yellow button and a red button - if the user clicks on the yellow button I want to set a cookie with the value "yel" then load the next page - if they click the red button set that cookie with the value "red" page2.html - 'onload' i want to read that cookie and load up the main image to match, something like this maybe?... document.mainimage.src='img/main_' + variable + '.png' so that the path would be for example 'img/main_red.png' Any help please? Preferably javascript only and as simple as possible. If you think this would be easier sending that variable in the URL instead of as a cookie please explain. I'm having a very hard time searching for tutorials that are any good and that do exactly this kind of thing. Hi, I have a DOM click event that creates a <span>. When the user clicks a button, it turns that <span> into a textarea that the user can type a new name in, press enter, and then the span contains the text the user input. Sort of like when you rename a file in Windows Explorer. Anyway, the code is something like this, and I'm wondering if I can use 'area_el' in this way... right now it's giving me the error that area_el is undefined, even though I define it in the function that contains the Event declaration. The first part is the Dom stuff to make it all work. It's not stuff I need to mess with, but I'm putting it here in case it's useful. Code: var Dom = { get: function(el) { if (typeof el === 'string') return document.getElementById(el); else return el; }, add: function(el, dest) { var el = this.get(el); var dest = this.get(dest); dest.appendChild(el); }, remove: function(el) { var el = this.get(el); if(el.parentNode != null) el.parentNode.removeChild(el); } }; var Event = { add: function() { if (window.addEventListener) { return function(el, type, fn) { Dom.get(el).addEventListener(type, fn, false); }; } else if (window.attachEvent) { return function(el, type, fn) { var f = function() { fn.call(Dom.get(el), window.event); }; Dom.get(el).attachEvent('on' + type, f); }; } }() }; The following code defines what happens when the user clicks submit to create a polygon. I also have some variables: Code: var created_area_array = Array(); var createdarea_index = 0; var number_of_areas_saved=0; var currently_renaming=false; Event.add(window, 'load', function() { Event.add('SubmitArea', 'click', function() { if(polyPoints.length>0) add_created_area(); }); }); Finally, where the issue is. I define area_el in the function below, and further down I want to pass it to a function within the "rename" click event, but I get an error that area_el is undefined. Code: function add_created_area() { number_of_areas_saved++; var area_el = document.createElement('span'); var area_el_remove = document.createElement('span'); var area_el_rename = document.createElement('span'); var new_entry = polyPoints; var new_entry_array_index = "Area" + (createdarea_index); var new_entry_array_name = "Area #" + (createdarea_index+1); area_el.innerHTML = '<span class=\"address-text\">' + new_entry_array_name + '</span><br>'; area_el_remove.innerHTML = "<a onMouseOver=\"rollover('address_remove')\" onMouseOut=\"rollout('address_remove')\" style='cursor:pointer;'>" + "<img src=\"images/tabs-icons/normal-address_remove.png\" name='address_remove' title='remove' alt='remove'></a> "; area_el_rename.innerHTML = "<a onMouseOver=\"rollover('area_rename')\" onMouseOut=\"rollout('area_rename')\" style='cursor:pointer;'>" + "<img src=\"images/tabs-icons/normal-area_rename.png\" name='area_rename' title='rename' alt='rename'></a> "; created_area_array[new_entry_array_index] = new_entry; createdarea_index++; Dom.add(area_el_remove, 'CreatedAreas'); Dom.add(area_el_rename, 'CreatedAreas'); Dom.add(area_el, 'CreatedAreas'); Event.add(area_el, 'click', function(e) { if(!currently_renaming) { polyPoints = []; var thePolyPoints = (created_area_array[new_entry_array_index]).toString(); alert(thePolyPoints); //formatting created_area_array[new_entry_array_index] to store as polygon points in the polyPoints array thePolyPoints = thePolyPoints.replace(/[\[\]{}]/g, ""); thePolyPoints = thePolyPoints.replace(/Location/g, ""); //adding the co-ordinates to the polyPoints array thePolyPoints = thePolyPoints.split(","); for(var ctr=0; ctr+1<thePolyPoints.length; ctr+=2) { var location1 = new Microsoft.Maps.Location(thePolyPoints[ctr],thePolyPoints[ctr+1]); polyPoints.push(location1); } var out=""; for(var i=0; i<polyPoints.length; i++) { out += polyPoints[i] + " "; } alert(out); //creating the polygon and searching... if(create_area==true) { drawPolygon(); polygonSearch(); } else if(create_area==false) { document.getElementById('createarea').innerHTML = "<a id='createarea'><span class='create_area' style='color:blue'><strong>Create Area</strong></span></a>"; document.getElementById("mapDiv").oncontextmenu = function(){return false} MouseUpHandlerId = Microsoft.Maps.Events.addHandler(map, "mouseup",MouseUpHandler); MouseDownHandlerId = Microsoft.Maps.Events.addHandler(map, "mousedown",MouseDownHandler); MouseMoveHandlerId = Microsoft.Maps.Events.addHandler(map, "mousemove",MouseMoveHandler); MouseOverHandlerId = Microsoft.Maps.Events.addHandler(map, "mouseover",MouseOverHandler); drawPolygon(); polygonSearch(); create_area=true; } } }); Event.add(area_el_remove, 'click', function(e) { Dom.remove(this); Dom.remove(area_el_rename); Dom.remove(area_el); if(number_of_areas_saved>1) number_of_areas_saved--; }); Event.add(area_el_rename, 'click', function(e) { if(!currently_renaming) { area_el.innerHTML = '<textarea name=\"renaming_area\" id=\"renaming_area\" style=\"width:200px;height:10px;background-color:#DCDCDC; resize:none;font-size:8px;\" onKeyPress=\"return enter_rename(area_el, event)\" maxlength=\"30\"></textarea><br>'; currently_renaming=true; } }); Event.add("createdarea_clear", 'click', function(e) { Dom.remove(area_el_remove); Dom.remove(area_el_rename); Dom.remove(area_el); created_area_array = []; number_of_areas_saved=0; createdarea_index=0; }); } The enter_rename(area_el, event) function that isn't passing in my variable. Code: function enter_rename(area_el, event) { var keyPressed = (event.which) ? event.which : event.keyCode; var current_str = document.getElementById("renaming_area").value; if(keyPressed == 13) { if(current_str.length>0) { if(allSpaces(current_str)==true) { alert("Please enter a meaningful area name."); return false; } else { area_el.innerHTML = '<span class=\"address-text\">' + current_str + '</span><br>'; currently_renaming=false; return true; } } else return false; } else return true; } Making area_el global does not clear the span elements when I click my "createdarea_clear" button, however when it's local, the function works as expected. I have the following code, where I am inputting a word and on clicking the button , i am setting the value of the text box in div class="twit" which is hidden. now I have to access the value of this hidden text box (name=q) using php.Say I want to print using php .How do I do this ? Code: <html <head> <title></title> <link rel="stylesheet" href="search.css" type="text/css" media="screen" /> <script type = "text/javascript"> function gettweet() { document.getElementById("src").value= document.getElementById("searchbox").value; } </script> </head> <BODY> <form align="center"> <div id="top"> <h3>Search </h3> <input type ="text" name="q1" id = "searchbox"\> <input type ="button" value="ClickMe!" id = "b1" onclick="gettweet();"\> </div> <div id= "twit"> <input type ="text" name="q" id = "src"\> <?php ?> </div> </form> </BODY> </HTML> I am just starting to learn javascript and was hoping someone might be able to answer my question: var months = "April Showers"; document.write('<p><img src="ad11.jpg"); document.write(" alt="); document.write(months); document.write(">"); document.write(months); How come when I display my output to a browser without the presence of the ad11.jpg file, only the first word (April) in the text string "April Showers" is dispayed where the .jpg file is suppose to be...but the last line displays the entire text string. Sorry, this is a newbie question, and probably really dumb, but... If I create a function that looks like this... Code: function recall(tim) { setTimeout("window.location.replace('somepage.html')",tim); } ...it works fine when called. However; I want to be able to pass the page url in a variable, something like this... Code: function recall(tim, myurl) { setTimeout("window.location.replace(myurl)",tim); } ...but this creates an error, saying "myurl is not defined." Even if I simplify the code and place the url in a variable within the function... Code: function recall(tim) { var myurl="somepage.html"; setTimeout("window.location.replace(myurl)",tim); } ...I still get the "myurl is not defined" error, even tho I am defining it. Plz can someone explain what I'm doing wrong. Tkx... --paul |