Referencing A Function Through An Array?

Jun 1, 2010

I am loading a set of icons using an array. The reason for this is that the icon set will be different depending on what some PHP code has given to the JavaScript.

My code currently looks like this.

Code:

var things_to_load = new Array();
things_to_load['header_cursors'] = new Array( 'default' , 'pointer' );
things_to_load['header_icons'] = new Array( '../img/triggers/to-roll/undo.png' , '../img/triggers/add.png' );
things_to_load['header_labels'] = new Array( 'undo' , 'add' );

[Code].....

The problem I have is that the click function gives the error "things_to_load.header_clicks[c] is not a function".

This makes sense as presumably the click function is saving the value and not what that value references.

how I can get this code to save the function not the string referencing it?

View 5 Replies


ADVERTISEMENT

Referencing Object Array Dynamically

Dec 3, 2009

What I'm trying to do here is even possible.

I've tried numerous variations of the alert line with evals, brackets and jQuery syntax but always seem to get the error:

XML filter is applied to non-XML value ({one:["1", "2", "3"], two:["a", "b", "c"]})

Which makes me think I'm either attempting something stupid or only missing my target slightly.

The code will be running within a jQuery project up if that helps in any way.

View 4 Replies View Related

Referencing Array-syntax-like Form Variable

Mar 26, 2007

I am experience some problems reading a form variable from a
Javascript function. The point with this particular variable is that
its name has the following syntax:

<input name="tx_impexp[tt_content:159]"/>

I want to set this var to 1 from my javascript function, so I tried
to execute the following line of code:

document.frm_1.tx_impexp[exclude][tt_content:159].value=1;

Unfortunately the following error come up:

Error: missing ] in index expression
document.frm_1.tx_impexp[exclude][tt_content:159].value=1
--------------------------------------------------------------|

It seems Javascript expects to close down the bracket at the position
marked...An easy solution would be to change my var syntax but the
point is that I cannot since I am using an already made script and I
should not modify it.

Just wandering if this is due to a syntax error defined according to
Javascript specification language or there is something wrong with
this.

View 5 Replies View Related

Adding JS To Old HTML Referencing Array Elements?

Mar 23, 2010

Years ago I created HTML that employs checkboxes and textboxes. I am now writing JS with the intention of adding flexibility and limiting redundancy. I am not sure I truly understand how to correctly interact the two though. For example, one of my scripts have arrays that contain the names of the checkboxes and textboxes, with a 'for' loop to document.write() them to references within the HTML code.This does not seem to be working for me though. Here is what I have thus far (in short):

<script language="javascript">
var teamNames = new Array(3);
teamNames[0]="South Africa";
teamNames[1]="Mexico";
teamNames[2]="Uruguay";

[Code]...

I've left out a lot of the code (to include the teamAbbr array, but you get the points. I've tried moving the JS within the HTML body and playing with the reference syntax, but nothing so far.

View 6 Replies View Related

Referencing Two Elements From A Single Function?

May 31, 2010

I have this function:

Code:

$(function () {
$('#Tags').tagSuggest({
separator: ", ",

[code]....

This references the #Tags element which is an input text box. I would like this function to run on another element also (#Tags2). So if either the #Tags or #Tags2 text boxes are used, the function runs.How can I extend this function rather than duplicating it?

View 14 Replies View Related

JQuery :: Submenu From Array - Function ToggleOptions Takes 3 Variables - Target - Array - State

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

Referencing Value

Oct 6, 2004

I'm trying to get a value from a link that a user click on in a pop up window and send it back to the parent window. It's working fine in mozilla and some IE but i'm having problem in IE 5 and some IE 6.

<a href="javascript:opener.document.getElementById('<?php echo $_REQUEST[partid];?>_partremoved').value = '<?php echo $partnum;?>'
opener.document.getElementById('<?php echo $_REQUEST[partid];?>_partinstalled').value = '<?php echo $partnum;?>'window.close();">
<?php echo $partnum;?></a>

View 4 Replies View Related

Referencing A <tr> Object

Jul 23, 2005

if i have this code: <form><input type=text name="id1"></form> then with
javascript i can reference this with this.form.id1, how can i reference
something like this:

<table>
<tr name="id2">
..
..
</table>

?

this.id2 doesn't work

View 5 Replies View Related

Referencing A DIV Within A Form?

Oct 29, 2009

whenever I run the below code I am unable to hide my <DIV>. I have posted a previous post regarding hiding DIVs however as this is slightly different I thought I would create a new topic here to allow for easier searching for other users.

The below code works if the DIV is outside of the form however if I enter it within the form nothing happens.

<form name="formcreate" method="post" action="">
<table width="80%" border="0" cellspacing="2" cellpadding="2">
<div id="div1">
<tr>

[Code].....

View 4 Replies View Related

Referencing Other Page's Dom

Aug 28, 2007

Is there a way in the Javascript to reference the dom of another page that is online. An example would be if www.cnet.com has an element with an id = money can I reference that page with an object that and get a value from the money element and display it on my page. I know this sounds confusing but really i just want to be able to save a xhtml page that is not on my website. Create a input filestream from that page and use data from the filestream to make data on my own page.

View 1 Replies View Related

Update Array In One Function By Another Function

Jul 26, 2010

I have small problem and I am stuck with it for days without any solution. So I have a function that has an array,

function arrjoin( )
{
var a = new Array (1,1,1,1,1,1,0,0,0,0);
var c = a.join("~");
return (c);
}

I have another function that call the arrjoin(). But before doing so, I get a value from an input field based on which i need to update the array in arrjoin() and save that as the new array(I mean same array but with the update value).

[Code]....

This is my current function. In this before I call joinarr( ) I need to update the array a in joinarr( ) with the value=index, that I am fetching here and save the array. (Haven't implemented yet) This process keeps on occurring every time a index value is generated. Thus in the next iteration the array a in arrjoin( ) show not be array show here but the array with the updates values. I am eventually transferring the array to server side to do some processing based on current value of the array.

View 1 Replies View Related

Referencing An Object's Fieldnames

Apr 12, 2006

A have an array of objects defined like this:

var collegas =
[{smtp:'alberic.verhelst@king.dom',voornaam:'Alberi c',famnaam:'Verhelst'},
{smtp:'anita.dierens@king.dom',voornaam:'Anita',fa mnaam:'Dierens'}, etc


I iterate over this array with this code :

for (var i = 0, stop=collegas.length ; i < stop ; i++) {
for (var veld in collegas[i]) {
etc

I would like to check whether a particular veld instance's name is smtp. In
code what I want is this :
if (veld.fieldName=="smtp") { do something ...

But this syntax doesn't work.....

View 2 Replies View Related

Referencing Parameters In JS, POST Vs. GET

Jul 20, 2005

I would like to reference the "name=value" parameters sent to my page
(submit'ted from a previous page with a <form>.) in my javascript.

I can do it if my second form is called with a "get" using the
window.location.search property, etc.

I don't know where these parameters are if my second page is called with a
"post"...

View 1 Replies View Related

Referencing Form In Variable?

Feb 10, 2009

i have a simple thing that causes me all sorts of headaches. I have many forms on the same page, and identical items in each form. The same object in each form call the same procedure. So, I'm passing in the form value, such as:

onchange="DoMyFunction('formName');"
and then in the procedure i do:
function DoMyFunction(formname){
document.[formname].object.value='1';
}

Now i have functions like this all over, problem is getting them to work. Once they work, they work fine. But when i add a new one, it can match an old function (except the object being referenced) and it won't work!

Does anyone know the proper way to reference a form in a function?

View 4 Replies View Related

OnMouseMove And Referencing A <div Id> Underneath Another <div Id>?

Sep 2, 2010

My functions for mouse_move / up / down all control the movement of a box. So you can click a box and move it anyway. It then snaps to an invisible grid. However there are multiple boxes on the screen so if you move it to a spot where another box already resides, then that box needs to swap places.This is what the mouse_over function tries to do. When I click the first box it stores the position of that box that was clicked. If I release the mouse button whilst hoovering over another box I want the other box to take the stored positions of the first box.However what I think is happening is the mouseover function is applying the new position to the box I'm moving, as I guess this is the first layer the mouse is over.Is there anyway I can reference the layer underneath using onmouseover.

<script language="javascript">
var x;
var y;

[code]....

View 5 Replies View Related

Referencing The Correct Object?

Dec 9, 2010

I have a table which I would like to be highlighted with the click of a button, but I can't seem to reference it correctly. I can make the <td> clickable and function, but when I try to apply it to the button I can't make it reference the td cell, rather than change the background color of the button.The function is:

function roll(obj){
obj.style.backgroundColor == "pink" ? obj.style.backgroundColor = "#e5e5e5" :
obj.style.backgroundColor = "pink";

[code]....

View 7 Replies View Related

Referencing A Checkbox Via A Variable

Apr 17, 2007

for(x = 1; x < totalCheckBoxes; x++) {
checkBoxName = "document.addProductEditor.journalEdit_" + x;

if(checkBoxName.checked == "true") {
//updatedJournalList = checkBoxName.value + ",";
}}

The problem is that while checkBoxName produces the correct variable, the final if statement claims that checkBoxName.checked has no properties. What am I doing wrong?

View 3 Replies View Related

Referencing Arrays Of Objects?

Sep 16, 2010

I am trying to return a JSON string from a server with a list of locations. I want to populate a div with checkboxes and the names of the locations.This is the JSON string I am currently working with:

Code:

[{"loccode":2,"locdesc":"Atlanta"},
{"loccode":1,"locdesc":"Charlotte"},
{"loccode":0,"locdesc":"NA"},
{"loccode":3,"locdesc":"Test1A"}]

I have a similarly formed data definition that is hard coded in the javascript for permissions that looks like this:

Code:

var prm = [
{"id":110,"idtext":"110","prmdesc":"Users"},
{"id":130,"idtext":"130","prmdesc":"Forms"},

[code]....

When i run that bit of code it displays Test1A and that is all.I am certain I am missing something basic, but I have not been able to figure out what it is.

View 3 Replies View Related

Referencing A Field On A Form?

Dec 9, 2010

I have validation code on my web form used by passing in the name of a field on the form. I have fields on my form named Hospital1, Hospital2, Hospital3, etc. I am trying to write a For loop to validate each one:

with (thisform)
{
{for (i=1; i<=9; i++)
{

[Code]....

What is the proper format of var vHosp= "Hospital"+i; so that it will recognize that field?

View 7 Replies View Related

Using Prototye Referencing Parent ?

Mar 18, 2011

My code is below it is pretty straight forward, but it is not working

What I want to do is build a generic class "car" then call it using a prototype

Code:

View 3 Replies View Related

Error "this.assignments() Is Not A Function" With Passing Array As Argument To Function

Oct 5, 2010

I'm trying to pass titleArray and pointsArray to the task(); I'm getting an error mgs this.assignments() is not a function. I've highlighted this.assignments()

[Code]...

View 6 Replies View Related

Referencing Elements Within An Iframe In Firefox.

Jul 23, 2005

I've written several utility pages that use a dynamically created
iframe. The iframe typically has a form that is populated by the main
page. Then the form is submitted to be processed, and the returning
page does something -- call a function on the main page, change a
variable on the main page, etc.

All this stuff I created works on IE. Sorry, didn't have other browsers
available to test. Now I have access to a machine with FF, and none of
these scripts work.

So, short and sweet: What is the proper way to reference a form on an
iframe from the parent doc in firefox? Also, call a function from the
parent to the iframe, and vice-versa, call a function on the parent doc
from the iframe when it loads?

View 6 Replies View Related

JQuery :: Referencing An Object In An Onclick?

Jan 8, 2011

I have created an object called list. the object has a method called load and a method called setSelected (it has more, but they arn't impotant here).

The load method prints out table rows like this:

str+="<tr>"+data+"</tr>";

and in the end, inserting str as the body of a table.

what I want to do now, is have an onclick event for each of these table rows, that calls the setSelected method of the current object. so for example, if I'd write this on my page:

mylist = new list(args...);
mylist.load();
<div id='associated-div'></div>

that if someone clicks a row in the table that is created in the div, the setSelected method of my list oject will be called.

View 1 Replies View Related

JQuery :: Referencing An Unnamed Form?

Apr 7, 2010

I am using the following system to create my forms : <% using (Html.BeginForm()) { %> Now I want to refer to the form in JQuery, but all the examples I can find refer to the form by it's name. How do I refer to my form if it doesn't have a name?

View 2 Replies View Related

Referencing Main Page From IFramed One

Jun 25, 2009

I have a script which works from my main page, but I need to embed it also into an iframed page, and have it affect the main page from there as well. In my main page, I have the following iframes:
<iframe id="main">
<iframe id="player">
<control buttons embedded on main page, along with the iframes>
The default source of "main" is page A, which is a frameset of pages B and C. In page B, I want to embed the same controls I have on the main page, and have them affect the main page from there.

Here's the controls script from the main page - it works from that page - a resizing onClick of the "player" iframe:
<head>
<script language="JavaScript">
function resizeIframe(iframeId, iframeHeight, iframeWidth)
{
if (iframeWidth>0)
{
document.getElementById(iframeId).style.width=iframeWidth;
}
if (iframeHeight>0)
{
document.getElementById(iframeId).style.height=iframeHeight;
}
}
</script>
</head>
<body>
<a id="widenButton" onclick="resizeIframe(player', 420, 720)return false;">Enlarge Player</a>
</body>
How would I put the widenButton in that back page and still have it affect the front page?

View 1 Replies View Related

Referencing Values On A Drop-down Menu

May 8, 2006

I have managed to write a working script to add together two values and display the total. I need to advance from that stage and now I have a 'quantity' box and a drop-down menu with a few options on it, each relating to a price. I am trying to take the quantity entered by the user and multiply it by the price they select from the drop-down and display it in a third box. So far I have:

two = document.autoSumForm.value from menu.value;
document.autoSumForm.total.value = (one * 1) + (two * 1);

How can I rewrite the above to account for the different choices a user can make on a drop-down menu?

View 3 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved