How To Add Variable In Function
Jun 3, 2009
I am using Jquery but the question belongs to simple JS
$("#anyID > tbody")
Now this works fine where # comes before any ID
The problem is if i have anyID in JS variable like
var1= "#anyID"; How can i insert that in above function
$(var1 + "> tbody"); is not working
View 4 Replies
ADVERTISEMENT
Aug 17, 2010
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.
View 13 Replies
View Related
Nov 17, 2011
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.
View 1 Replies
View Related
Feb 10, 2010
Here is the code:
for (var i = 0; i < BS_crm['activityTypes'].length; i++) {
var clickFunc = function(){ activityList.showForm( -1, {blockType:[""+BS_crm['activityTypes'][i]['id'], "0"]} ); };
var type = {
[Code]....
Now, basically what I am doing here is running through one array to create an array of objects, that will be used to create links that will use whatever onClick function I pass it. The problem is that on the second line I need the BS_crm['activityTypes'][i]['id'] to be a value, not a reference. If that line was simply changed to:
var clickFunc = function(){ activityList.showForm( -1, {blockType:["3", "0"]} ); };
View 4 Replies
View Related
Sep 18, 2010
I'm making some changes to a google chrome extension I made and am having some trouble. Heres my code on a content script page (removeAttr.js) :
chrome.extension.sendRequest({greeting: "whitelist"}, function(response) {
var whitelist = response.whitelist;
console.log(response.whitelist);//working
});
alert(whitelist);//alerts "undefined"
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.
View 7 Replies
View Related
Mar 21, 2010
how to pass variable say(n) value to another function...here below my script:
<html>
<head>
<script type="text/javascript">
function docalc(){
[Code].....
View 5 Replies
View Related
Feb 18, 2009
I am currently working on a code that has a function within it called findHighestValueIndex which will find the highest value in an array. The problem I am having is writing this function so i can call it in the program to work on 2 different arrays. I already have it working on the array assesmentScoresArray, but I also need it to work on the weightedScoresArray. Is it actually possible to do this or do i need to write another function that is almost the same but with the arguments etc for the other array? I will paste the code below so you can see where I am up to. I am a novice in programming so im probably going about this all the wrong way
<HTML>
<HEAD>
<TITLE>
[code]....
View 4 Replies
View Related
Aug 15, 2010
Im trying to set the value of a variable with a function, the variable i want changed is defined in another variable.
Then later i have this:
The "Selected" var is the var i want to change, and the value of it will change every time one is changed (it's for a calculator) When i try it though, it changes the value of the "selected" var it'self and not the var that i want changed. how i can i got it to change the value of the value of selected and not the selected var it'self?
View 2 Replies
View Related
Jun 1, 2007
Heres what i got, ignore all the unknowns they come from textboxes etc.
My problem is in this function I change the value of a variable. I want to store that variable change so i can use it in another function. Heres what i got.
function setupGame(){
var guessesLeft = guessNo.value = 10;
var wordSplice = new Array();
wordVal = word.value
wordVal = wordVal.toLowerCase();
alert(wordVal);
for(var i=0; i<wordVal.length; i++){
wordSplice[i] = wordVal.substring(i, i+1);
wordSoFar.value += "*"
}}
Thats the first function, the variable or 'Array' values of wordSplice I saved I want to use in this function :
function runCoreEngine(){
for(i in wordSplice){
}
}
View 2 Replies
View Related
Jul 11, 2011
How I would modify the following function to get it to check if a url variable is present and if so to add it into the string variable for the url.
Code:
If my url is index.php?make=Apolo then I need to get this added into the var queryString part of the function so that the ajax returns the correct values.
View 1 Replies
View Related
Apr 22, 2011
I'm trying to add a php variable to a url in the following function but can't get it to work...
Code:
<?php
$leEcho = "theEcho";
?>
[Code].....
View 11 Replies
View Related
Jul 27, 2011
I am using Jquery but the question belongs to simple JS
$("#anyID > tbody")
Now this works fine where # comes before any ID The problem is if i have anyID in JS variable like
var1= "#anyID";
How can i insert that in above function
$(var1 + "> tbody"); is not working
View 6 Replies
View Related
Jul 20, 2005
I have a .js file that receives a value from an html page. I'd like this
value to be a global variable that all functions in the .js file can use. I
have tried just declaring a var at the top of my .js file, but when the
value comes into the function and gets assigned to that variable, it is not
global.
View 4 Replies
View Related
Jul 20, 2005
I know only little of javascript and have trouble with the syntax of a
function this is the function
function ClipBoard( VARIABLE)
{
holdVARIABLE.innerText = VARIABLE.innerText;
Copied = holdVARIABLE.createTextRange();
Copied.execCommand("Copy");
}
probably needless to say, but it doesn't work.
How can i get this function to work?
View 3 Replies
View Related
Oct 15, 2010
I'd like to trick the .get function and use a variable, instead of an url.I already know what the link will be - linker - but I can't pass it to jQuery, it doesn't work...
what I should do to use the get function like this:
$.get(Variable, function(data) {
$(function () {
$("a").each(function () {
[Code]....
View 1 Replies
View Related
Jul 4, 2009
New to JQuery and hope this question has an easy solution. At present I am trying to assign a global variable from a function which is called on a mouseover event, fired by going over a hyperlink with a specific class.
[Code]...
View 3 Replies
View Related
Jul 4, 2009
At present I am trying to assign a global variable from a function which is called on a mouseover event, fired by going over a hyperlink with a specific class.
The code:
[b]active = "false"
$('.menulink').mouseover( function(active) {
active = "true"
[Code].....
View 7 Replies
View Related
Jul 12, 2009
ive got this function here which i nid to get a specific variable out from it so dat i could pass it to another function. ive tried many ways bt still cant do it, including using global var and function call.
var textFile = 'preferedChannel.txt' ;
var testChannel = 'This is a test channel' ;
(function(f) {
$.get(f, function(resp)
{
resp = $.trim(resp);
// Variables to get current day and time in 24hrs format
[Code]....
View 1 Replies
View Related
Mar 4, 2009
If it is possible to pass a php variable through to a javascript function.
Example.
I have a bit more to the code but that is the bare essentials as an example. If i remove the $id and $name from the passTest() for onClick the function works properly. However if I leave them in the function doesn't seem to work at all.
View 2 Replies
View Related
Jun 9, 2009
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?
View 2 Replies
View Related
Jul 19, 2009
Is is possible to set a variable name from a function parameter?
Kind of like this but it doesn't work!
View 8 Replies
View Related
Aug 14, 2009
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:
<tr>
<td class="datashaded" valign="top"><font size="2"><b>Country:</b></font></td>
<td class="datashaded" valign="top">
[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.
View 3 Replies
View Related
Apr 22, 2011
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!
newSearchBox.onkeyup = function() {updateSearch_TC_JD(table_JD.length-1)}
View 3 Replies
View Related
Nov 10, 2011
What I did wrong to make this code not work. Can you put a variable in a function callback?
<script type="text/javascript">
var aaa = prompt('number?')
var obja = new Const(aaa);
functin Const(numb){
this.x=numb;
alert(obja.x);
}
</script>
View 3 Replies
View Related
May 26, 2009
I have a JSON array data.cells that I need to iterate through to get the values out of and put the values into an onclick event listener.
Right now the variable name data.cells[i].letter is being based through the buildString function for each cell in my board, instead of the value of the variable. Same goes for the x and y variables.
View 3 Replies
View Related
Jul 12, 2010
I am trying to call a function from a link or button like the example below, however I would like to call the function whilst passing a variable along (not a string).
This isn't my code, it is a simple way of explaining what I am trying to do.
<html>
<head>
<script type="text/javascript">
function myfunction(txt){
[Code]....
So instead of 'java too!' I would have a variable named "category" which could contain different data each time the button is pressed.
View 2 Replies
View Related