Variables Setting W/array
Jul 23, 2005
How can I go about setting a number of variables using a table which will
have the variable names to be declared in one table. The data to be assigned
will reside in another. As an example, I know this assignment works:
var nam0 = tab[0]
var nam1 = tab[1]
var nam2 = tab[2]
..
..
..
What I would like is to use two tables
var namtab = ["nam0","nam1","nam2"]
var tab = ["va0","val1","val2"]
Then using a loop, assign the variables so that I may address them by name
"nam0" rather than namtab[0].
var nametab = ["nam0","nam1","nam2"] ** also tried w/o the quotes
for(var i=0;i<3;i++) {
var nametab[i] = crumbs[0];
View 7 Replies
ADVERTISEMENT
Feb 3, 2011
I have some JavaScript which is splitting out the different variable elements from the URL.Now, how do I set the internal variables?Then I want to set the variable ScriptHeading to be Change and the variable ScriptType to be NewThread.I keep finding all sorts of lovely code showing how to split out the various sections in many different ways, but I can't find anything on how to actually set these variables.
View 1 Replies
View Related
Jul 20, 2005
I'm trying to create specific pop'up window (for product category
selection), but in JS I'm a newbie
and some problem occured, so I have a question:
Is it possible in main window (that opens a popup) to set in popup window:
1. global variables
2. form fields
For example, I'm opening popup window like below:
categories=window.open(address,"categories","scrollbars=no,height=400,width=
600");
Then I try to set global variable in popup window:
categories.global_variable = 1; //no effect
Or try to set form field:
categories.document.some_form.some_filed.value = "some value"; //no effect
If none of above won't work, how could I pass some data to another window
using JS?
View 3 Replies
View Related
Jan 5, 2010
I am passing a URL via the GET method url variables. The original URL looks like this:Code: The actual site is done in coldfusion and I do not have access to that or any other server side languages. PG=FORUMS is the page that contains the iframe and I need the iframe src to be the same as the "page" variable.I attempted to throw together some scripts I found online and this is what I came up with:
Code:
<script language="javascript">
<!--
[code]....
View 7 Replies
View Related
Feb 15, 2011
I am trying to understand somecode. I don't think I am understanding everything correctly. Can someone confirm or add to my understanding?
Here is the code, below is my explanation:
- CODE 1 - is saying if the the class subnav_dd is called on an anchor tag on a li, then make the function in the if statement "live". (Live in a sense binds the function to the condition, but unlike bind it allows the condition to be used more then once. ) So if the class subnav_dd is the parent, and has a class of .dis then prevent anything below it from firing. CSS - If code 1 is true, then I will only get the first li to fire, the remaining ones will not.
- CODE 2 - This one is a little tricky. Function ToggleOptions takes 3 variables (target, array, state). The condition is if the div subnav + target have siblings, then check to see how many siblings are there. Put the amount of siblings into an array, then check the state of each sibling. I don't completely the rest of it.
I think if the div subnav is called and something is found in the array then the class dis is either added or removed. Then what? I don't understand why I still need the else that adds a class to #subnav_ +.target
View 1 Replies
View Related
Feb 13, 2009
I'm having problems setting variables from selector bars. I've currently been trying different forms of document.getElementById() but to no avail.
View 4 Replies
View Related
Mar 8, 2010
how to accomplish this. In my website, I would like the user to input text into a single or multiple textbox(es) and then have the contents of the textbox(es) stored to either a variable or an array. Then I would like to have that variable/array compared to other arrays. Basically, the user is searching for items in a database. The user can search for as many or as little items as they want. Then the item(s) will be compared to multiple arrays to find out if what the user wants is in the database.
So for example, let's say the user is searching for recipes that have all or part of these ingredients: chicken, broccoli, lemon, honey. So, there would have been a total of 4 textboxes...one for each ingredient. These ingredients are stored to an array..lets call it ingredient(). In the database of recipes, each recipe has its own array which includes the ingredients needed to make the recipe, we'll call them tag1(), tag2(), and tag3(). Now, I want the array, ingredient(), to be compared to each of the "tag" arrays to see if any of the "tag" arrays include exactly match the ingredient() tag in part or in whole. Is this possible?
View 2 Replies
View Related
Oct 22, 2010
//<input type="text" id="s_field" value=""/>
var valid = true;
var div = $("#s_field");
$.post("index.php",{id: 6}, function (data){
[Code]..
When posting data, and getting response need to set valid to false - email is not valid.
1. in function it alerts valid is false
2. outside function it says valid is still true!
even i didn't wrote var valid = false;, but valid = false;I need to set Global "valid" variable to false.
View 1 Replies
View Related
Feb 15, 2010
I am a newbie and am writing a function. I want the function to refer to an arrays elements to get the biggest, but I dont know how to do this.
Here is the code:
what I am trying to do, is get the array elements to be called and give me an answer. Will I need to add the array to the function? It is further down the code after the function at the moment. Or will I need to add the array elements to the function?
View 4 Replies
View Related
Jan 17, 2011
I have an array form input with an id: field[0], field[1] etc.How can I set the value of each array element directly?
$("#field[0]").val("value") doesn't appear to work.
View 3 Replies
View Related
Jun 27, 2011
I have part of a script like so:
var audioPlaylist = new Playlist("2", [
{
mp3:"audio/eight-day-week.m4a"
[code]....
View 4 Replies
View Related
Oct 30, 2006
What happens if you do this?
function Person() {}
Person.prototype = 7;
var ted = new Person();
Also what happens if you set Person.prototype to an array or function?
View 1 Replies
View Related
Apr 7, 2009
I keep getting <undefined> when I alert out the value of my array 'fadeimages1'. Using php/mysql I retrieve filenames from a directory and create <INPUT> fields to store the filenames. In the javascript portion of the code, I use getElementsByName() to retrieve all of the <INPUT> fields. I then declare an array, 'fadeimages1'. Next, using a for loop I try to copy the values from the <INPUT> fields into the array 'fadeimages1'. When I alert out the length and value variable for each <INPUT> field, I get the correct filename, but after trying to store the value into 'fadeimages1' array, I get value is <undefined> when I alert it out. BTW, the following code uses 'fadeimages1.push()', but I also tried 'fadeimages1[i]=...'. Both result in <undefined> values.
[Code]....
View 2 Replies
View Related
Apr 2, 2009
Anyone know how to get Javascript variables into PHP variables or a MySQL database? Full question in the PHP section.
View 2 Replies
View Related
May 6, 2006
I have a program written in Javascript and fully functioning which takes a user-selected directory name and then displays all the photos in that directory in a certain format.
I am now wanting to expand the program to allow users to optionally enter their own strings and the program will use all the photos from www.flickr.com which use that string as a tag.
I have a PHP interface to flickr (called PHPflickr) which collects all the relevant photo urls. I now need to get these images back into my Javascript so I can process them using the existing functions (rather than rewrite all my functions in PHP code and have two sets of functions in the program). I found on another thread a means to do this for a date variable:
var jsArray = new Array(
<?php
$length = count($monthDataArray);
for ($i = 0; $i < $length; $i++)
{
echo '"' . addslashes($monthDataArray[$i]) . '"' . (($i < $length - 1) ? ',' : '') . "
";
}
?>
but being completely new to PHP I'm not sure what "addslashes" might be or what formatting will be necessary if I am starting with an array of urls. Code:
View 1 Replies
View Related
Mar 2, 2009
I want to create an associative array dynamically pulling the index values from an array (propertyArray); Associative array is created inside create function and then returned. But after it is returned, I cant use index names to retrieve values. It returns undefined as below code shows.
Code JavaScript:
var propertyArray=["a","b","c"];
function create(){
var array=[];
[code]....
View 2 Replies
View Related
Jan 21, 2011
Modifying my code:
I have this C# code that is connecting to database and creating a array(list)
Code:
I'm trying to pass it to a javascript function so I can then pass it to a silverlight page so I was able to create this easy javascript that show a aleart box on startup of the list(array)
Code:
But I want to do something like this and can't get it:
Code:
View 2 Replies
View Related
Sep 17, 2010
What is the correct syntax for an nested array where each array element has 3 elements, a number and two text strings?
Code:
array = ['1, Old Man, Old Man','2 Black Sheep, Black Sheep',....]
should the text strings be in double quotes("")?
Code:
array = ['1, "Old Man", "Old Man"','2 "Black Sheep", "Black Sheep"',....]
View 3 Replies
View Related
Apr 25, 2011
I am really hoping someone is willing to take the time to read this post and take a minute to take a look at my code. What is happening is there are some matches for a script I made and then an area for segments during an event. If you notice on the segment part of the form is that there is a dropdown that asks for where in the event that segment needs to go. With the Introduction or the different numbered matches. What I need to happen for a subArray I need it to take the introduction, all the matches, and all the segments and order them accordingly. With the introduction first, the matches in order based off there match number and then the segments in between the introduction or matches based off the user's input.[URL]..
View 7 Replies
View Related
Nov 3, 2010
I am working on a page where the user will select a location from a dynamically generated dropdown list. I was able to create the php multidimensional array (tested and working) from a MySql database using the users information at login, but I'm having problems converting it to a javascript multidimensional array. I need to be able to access variables that I can pass to a number of text fields within an html form.For instance, if a user belongs to a company with multiple addresses, I need to be able to let them select the address they need to prepopulate specific text fields.
View 9 Replies
View Related
Jul 21, 2011
is this correct
var mid = math.floor((0 + array.length)/2)
from here you could use array.slice to divide the array into two equal sized arrays?
View 6 Replies
View Related
Apr 10, 2010
This one is throwing me off! Either I am making a stupid mistake or I'm doing it totally wrong I have an array, and I am trying to select unique values from it and assign it to another array. Here is the code:
Code:
var flag;
for (i=0;i<=pdfs.length-1;i++)
{
flag = 1;
for (j=0;j<=pdfs2.length-1;j++)
[Code]...
The problem is that the if (pdfs2[j] == pdfs[i]) statement ends up never being true. There are URL's to pdf files in the array. On the other side, if there is a much easier way to select unique values from an array, please feel free to point it out.
View 2 Replies
View Related
Sep 1, 2010
I am building a customised javascript prototype to sort an associative array on the array key (in ascending order). Basically, I am separating the array keys into a separate array and then using .sort() to sort the keys and then reassembling the original associative array elements according to the sorted keys array.
The sorting works ok except that when I run the test code below, the outputed sorted associative array has an extra element at the end of the array whose key is the name of the prototype function and the value for that element is the function code itself. Obviously I am misunderstanding something about associative arrays or how javascript prototypes work.
[Code]...
View 8 Replies
View Related
Nov 19, 2011
I want to have a simple code such that some data is stored in array. When we create a search box it has to give suggestions from the data stored in array.
View 4 Replies
View Related
May 6, 2007
I'd like to reorganize the third, fourth, fifth and sixth, as well as any
elements thereafter in an array in random order:
var a = new Array('first','second','third','fourth','fifth','s ixth','etc')
In other words, the first, second and third element should remain in
position 0, 1 and 2, while the fourth, fifth and sixth, etc. should appear
in random order.
View 9 Replies
View Related
Mar 26, 2010
I'm trying to grab values from a set of arrays based on the value returned by my select box.
**Caveat - this is not an area I have any real experience with**
My arrays look like:
Code JavaScript:
I then need to test for each, then associate with one of my fees arrays, then grab each of the values in the array and write those values to elements within my page.
I'm then doing this to evaluate for each degree
Code JavaScript:
I need to first figure out how best to import all of these 60+ arrays and then in each of my conditions pull out each value and write to my page.
There is a unique 1 to 1 relationship between each degree and array so I can't consolidate as the values for each degree differ slightly.
View 3 Replies
View Related