Is it possible to print out the variable from within a function? In this particular case, I am trying to show the 'soundfile' variable I set in the playRandomSoundNoWindow function.
I have the following function: function containsurl(index){ var theurl = "[URL]"; .. } I need to use the theurl variable in another function, how can I do that?
How do I acess the whitelist variable from outside the sendrequest() function?
Iv tried saving it to a window.var variable with no luck. Iv tried creating a div and assigning it's innerHTML as the whitelist variable and getting it later with no luck. The fact that it's a chrome extension complicates things because i dont actually know if i can create elements from where the script is located.
I have this problem in xsl wherein i want to access a variable in javascript and use it my xsl. How would i access or use a javscript variable in my xsl file?
I am new to Javascript but fluent in C++ and other languages, I have a query, I made a global variable to hold string information, can the value of this string be assigned to a form input field value? I mean in the 'default value sense' I am just wondering if there is any syntax to accomplish this. EG in my javascript I have the string nameVal; It is a global variable, I would like to know if it is poosible access its value for use in the line below shown with italics, or is it basically always a case of 'type the value in manually yourself' and then rely on events functions to update the field thereafter? Name: <br><input type = "text" name = "nameField" size = "50" value = my string val here onChange ="this.value=storeVal(this.value, '0')"></input></br>
In hover, the structure is Code: $("div.x2").hover( function(){ var a = 1;}, function(){ alert(a);} );
If I want to access a that was set in the mouseover part of this structure, or I want to change the value of a from the second function, do I have to create a global variable that can be accessed by both or is there a way to pass this variable back and forth between the two functions since they are both within the hover event?
i have script variables which are generated through a loop and i have a function which should return me the value of particular variable given a key as input to that function Here is how my code looks like:
I have two Select Boxes on my web page, 2nd being populated based on selection of first select box. Now I am suppose to get the selected value of 2nd Select and put it in a link i.e. Code: <a href='abc.html?id=<2nd select box value>
I can get the selected value using Javascript with the following code: Code: 2ndid = form.2ndodf.options[form.2ndodf.options.selectedIndex].value; Where 2ndid is a global javascript variable. How I can use this variable into <a href> tag.
I am trying to access the width variable from my main page. Within the imageinfo.js script functions I can alert() the width value which returns 1024. But I can't seem to pass this variable to my main page or access it directly so that I can use document.write() to write the variable on the page. Whenever I try to call the 'width' variable directly from the main page I get undefined. How can I access this variable? However, with the test code below, I was able to get ducument.write() to write the 'width' variable on the page but now the page doesn't stop loading - there's an endless loop in the code...
I have an object whose name is mural. I have assigned the name mural to the title of an anchor element. When user clicks and element I want to store the title of the anchor in a variable called sprite. I then want to access that object whose name corresponds to the sprite variable string.
Here is my code: HTML Code: var mural= new Object(); mural.top='0px'; mural.left=-'510px';
var stamps= new Object(); stamps.top='0px'; stamps.left=-'1886px'; var sprite=$(this).attr('title'); $(".image-holder").css("background-position",'sprite.top, sprite.left');
It's not working because the the variable sprite is just a reference to $(this).attr('title'), how do I make it reference the object? Oh and I know that .cc jquery statement probably wont work, I'm not sure yet of the correct way to have two values that don't need quotations in as the second argument.
I'm trying to pupulate a web page with javascript. I have 2 functions. One that runs on-load so I can populate a dropdown list. The second one to process the selection when the user selects an item from the list. I have a global variable in the top of my javascript that I use in the functions and as long as I set it in it's global scope, everything works fine. But what I really want to do is to pass this into the javascript running on this page via [URL]
I cannot get this to work. First here is what I have that works: <script type="text/javascript"> weekNumber = "00" function processSelection(sel) {..... ... [includes references to weekNumber] .....}
I've got the code to gets the variable passed in properly: var sGet = document.location.search; sGet = sGet.substring(1); // Eliminate the leading "?" var sGetPairs = sGet.split("&") //Get 1st pair var sGetValue = sGetPairs[0].split("="); //Split it var weekNumber= sGetValue[1]; //Save it
Where do I put this code so that I can use it to set the global variable "weekNumber"? I've tried putting this code in the populateList function. I've tried referencing it via window.weekNumber and this.weekNumber. I've spent far too many hours trying to understand this without success. Where to put this code so I can set the global variable weekNumber?
We have a web site provided by the software company that created our vacation rental management software, so, as such, I don't have entire control over the pages -- just bits and pieces. They recently started including jQuery 1.4.4 along with jqueryUI and cookie plugin on the pages and utilizing it a bit (as well as a custom jquery bit of code they wrote up). here's the relevant code (that I have control over):
HTML Code: <script type="text/javascript"> var phoneflat = $.util.getCampaignPhone('MCPH').replace(/[^0-9]/g, ''); if(phoneflat=="null"){var DNISPh='88812345678'} else{var DNISPh=phoneflat}
[Code]....
Basically, we have a phone-number tracking system on our Web site, and the toll-free number on our site gets replaced depending on how the MCPH cookie is set. The above code pulls formatted number from that campaign cookie, removes the formatting from the number, and sets the pop-up URL to include the number, passing the number after the "?DNIS=" (which is required for this specific campaign tracking to work properly).
This all works fine and dandy if the jquery and cookie code is all before the above code snippet on the page, but the developers of the software are trying to follow best practices and are loading all the javascript files at the end of the page, and this is far earlier in the page. So there's really no way for me to pull that ".util.getCampaignPhone('MCPH')" as the cookie may not have been set yet, nor is the campaign data ready.
So I'm currently working on a ASP.NET Webforms site and I've run in to a small problem. On my .cs file I have the following Webmethod
[WebMethod] public static string IsJobEditable(int jobid){ try{ string isEditable = "false"; JobsBLL jbl = new JobsBLL(); int jobStatusId = jbl.GetJobStatusId(jobid); //If the jobs is either waiting or being edited it is okay to edit it if(jobStatusId == Convert.ToInt32(ConstantsUtil.JobStatus.Waiting) || jobStatusId == Convert.ToInt32(ConstantsUtil.JobStatus.Edit)){ isEditable = "true"; }return isEditable; }catch (Exception ex){ throw ex; }}
This function in this case will ALWAYS return TRUE as a string. On Aspx page I have the following $(function () { $.ajax({ type: "POST", url: "Coordination.aspx/IsJobEditable", data: "{jobid:" + jobid + "}", contentType: "application/json; charset=utf-8", dataType: "text", success: function (result) { alert(result);
//This is written out in the alert {"d":"true"} I want this in a variable as a string so I can do a check on it before I do some other actions. The format is not a String so I cannot split on it to retrieve the "true" part. }, error: function (err, result) { alert(err); } });});
As you can see in the comments the value I get back in the Callback method is in to me a weird format. The type is unknown and I need this value to be able to proceed with my entire method surrounding the small portion of the Javascript. Where to access the result variable / data as a var or anything else that will let me put it into a var (as a string).
all on the same page that are accessed by the classic show/hide DIV functionality.
So user clicks button 2, which shows story 2, hide stories 1 and 3. (all on the same page).
The issue is that I've been asked to provide a method to directly link to story 2 or 3, which currently isn't possible since you need to load the page, then click the button to show story 2 or 3 (naturally 1 loads by default).
So I'm looking for any method to go right to story 2/3 from a link.
Perhaps I can pass a variable through the URL which executes the function as soon as the new page loads (which would mean a quick double page load but I could handle that)
Here's the function: var showMe = function(me) { document.getElementById(me)["style"]["display"] = "block"; }, hideMe = function(me) { document.getElementById(me)["style"]["display"] = "none";
I'm not an ace JSer by any means--the problem I'm about to pose could easily be solved with pointers in C++ (the language with which I am most familiar), unfortunately that is not an option.I am making a webapp using the google visualization API:URL...My problem may be related to the API, but I think it's more Javascript oriented--the Google group for the API is helpful,I have a function, drawDash(), which declares some elements of the visualization, some filters for the visualization, then binds them together and draws them. Now what I need to do is access the elements of one of those vars, specifically a filter, and add/change properties of it with an HTML form.
I've set up an onclick function for a set of checkboxes in my form that calls another function. The problem I face is that I can't really access the filter correctly.[code]So basically, I want to have a function be able to edit the var serviceSearch from another function.
function popsizes(colorcode) { var BLK=new Array(); BLK = ["2XL","3XL","4XL","5XL","LG","MD","SM","XL","XS"];
elem = document.getElementById("selcolor"); for (i=0; i<elem.options.length; i++){ sizelist = colorcode[i]; document.getElementById("selsize").options[i] = new Option(sizelist); }}
</script>
In an event, i'm passing in "BLK" as the colorcode param. This is creating my selsize select box with B, L, K, and undefined options until the for loop finishes. ie, its taking the passed in colorcode as a literal string, instead of referencing the array. Anyone have a pointer as to how i can access the arry, instead of the literal string?
I've attached a cut-down version of a script I am working on. It's a pretty simple button with a function attached, which creates a random number and compares it with a preset value.I can't seem to get the function to read the variables
I am trying to declare a variable inside a function and use it later on in my code... but it just already returns white space... i.e. not variable value. I am setting it within this function:
function show_video1(){ document.getElementById('video1').style.display="block"; var video1Name = "Education World News (Part 1)"; document.getElementById('video2').style.display="none"; document.getElementById('video3').style.display="none"; document.getElementById('video4').style.display="none"; [Code]...
and trying to call it later on with this: <script type="text/javascript">document.write(video1Name)</script> It might be worth noting that each one of my 11 videos will hace a different name.
I've got a function displayResults(imageArray); that first calls removeElements(); to get rid of the currently displayed list items. Both functions are part of class function eventBox(array, string, date). both displayResults(imagearray); and removeElements(); have been bound to eventBox(); by e.g. this.removeElements = removeElements;
However, from within displayResults(imageArray); this.removeElements(this.identifier + "eventsul"); evaluates to "undefined". Also, this.identifier called from within the function also evaluates to undefined (it doesn't in other functions). For some reason I can't access global functions and variables from displayResults(imageArray);. Any ideas?
Here is the code for displayResults(imageArray); :
So I've got this checkbox thing going on, where an array converted with the value of each checkbox in it.It looks like this:
[Code]...
What I want out of this function is the variable newworkdays to use in another function.
How do I access the "newworkdays" outside the function? I've already try to declare the variable outside of the function, though that resulted in that I didn't get the value of the variable inside the function.