Dynamic Variables

Jul 23, 2005

I need to create a variable out of nothing. From a database I extract an
item with a certain id. With this id I want to create a new variable.
For example:

id = 36;

"item"+id = new Array();

Now I get the message "Illegal left hand assignment".

I tried:

eval("item"+id) = new Array();

Is it possible to create a variable out of nothing?

View 4 Replies


ADVERTISEMENT

Dynamic Variables In AttachEvent

Jan 24, 2007

I am trying to write a loop that will add 10 divs to the screen. Each
div will have an onclick event. The function that will be called
onclick requires a parameter. That parameter is dynamic based on the
index of the loop. In Firefox this is no problem. However in IE I get
some results that I wouldn't expect.

Here is my code:

for(var i = 0; i < 10; i++)
{
var linename = jsonObj.lines[i].line;
var childcountid = jsonObj.lines[i].childcount;
var lineid = jsonObj.lines[i].lineid;

var newdiv = document.createElement('div');
newdiv.setAttribute("id","main" + i);
if (navigator.appName == "Microsoft Internet Explorer")
{
//************ this is the problem area
*****************
newspan.attachEvent("onclick", function() {getCategories('main' +
i)});
}
else
{
newspan.setAttribute("onclick", "getCategories('main" + i + "')");
}
document.getElementById('container').appendChild(n ewdiv);
}

What happens is when the element is clicked the parameter being passed
to getCategories is always 'main9' IE always grabs the current value
of i, not the value of i at the stage of the loop that attachEvent was
called.....

View 1 Replies View Related

Passing Dynamic PHP Variables?

Jul 16, 2011

I'm creating dynamic buttons and forms for a website and would like the form hidden when it's corresponding button is clicked. However, when I pass button and form name variables to my JavaScript that hides the form, the variables are not being recognised unless I explicitly set them. (e.g 1 and 2 as seen below).

In a nutshell the onlick event doesn't seem to like PHP variables !

[Code]...

View 1 Replies View Related

Dynamic Named Variables

Feb 18, 2004

I have a little problem that doesn't seem to be working. I'm trying to access a variable using its string name which is passed when the function is called Code: ie:

function a(varName, other crap...) {

document.getElementById("sometag").innerHTML = ['varName'].somevalue;
}

// I would call this function like so...
a("temp1", othercrap...);

The variable temp1 is set in another script file. I don't specifically know which variable I will be passing to the function a(), all I have is its string representation. I can access the values of temp1 if I specifically call it but I can't seem to figure out how to call it dynamically.

View 2 Replies View Related

Dynamic Query String Variables?

Sep 20, 2007

I'm working on a rather complex booking system for building European
trips, in a combination of SQL/VBScript/Javascript. There are tons of
query string variables that get passed back and forth between the
pages, and in almost every case, I can set 'em up fine, provided the
variables are in the link.

The page the *holds* the booking information, though, is problematic.

An example trip might include two European cities or towns with a week
in each in an apartment or cottage that the user selects from a dozen
or properties for each region.

All the information is on one page (all the dozen or so properties for
each weeks, available dates for the trip and for each , max occupancy
per property, pricing per property and per number of passengers,
etc...everything necessary to actually book the trip). If the user
changes party size or chooses a date, properties are hidden or shown
depending on max occupancy and/or availability.

So, a user sets their date and party size (or maybe just the party
size, or maybe has just cleared everything out to start over...) then
wants to view available properties so they can find one they like. The
current pax/date/etc. information is not in the query variables,
because the link was built at runtime.

If I build the link in an onclick event, it breaks if someone right
clicks to open a new page or tab.

I hate sites that disable right click menu. I hate sites where, when
you open a new page with a right click, it generates a javascript
error if the URL is created with an onclick event. I hate that using
an onclick to bring up the page means whatever is showing in the
status bar bears no resemblance to the page that is brought up when
you click on the link.

My client isn't worried about the non-javascript people for this use;
those people are referred to a free spiffy catalog, which frankly, is
how most of this client's customers book their trip anyway. I just
want to be able to carry the variables in such a way as to not break
the site if someone right clicks.

Anybody have any suggestions? Is it hopeless?

View 11 Replies View Related

JQuery :: RSS Manager - Dynamic Variables (Contain URL)

Jun 14, 2009

I'm building up a RSS reader. In this app, the user will have the option to add and remove urls in a list. What I need is to create a new variable, everytime the user submit the form with the url. The variable must contain the url.

View 1 Replies View Related

Dynamic Buttons And Passing Variables?

Jun 29, 2010

I am developing a site that adds multiple dynamic buttons. I would be ideal if the event these buttons trigger could pass a 'variable' (the passed variable is constant with respect to each button).

My attempt...

myButton.setAttribute("onClick", "myFunction(" + myVar +")");

...doesn't seem to work.

View 2 Replies View Related

Send Dynamic Created Variables As Parameter In Ext Js?

Mar 2, 2009

I am using ext js library to built ajax base site.I need to build dynamci variable and then send that variable with same name in paramter to phpi have following function where first i check the array length and then loop untill the array lenght come to end and within that i get the value from html.now i want to send dynamic variables as parameter but i can do this

Code:
addvalue = function(){
var id_str=document.getElementById('array_chk').value;

[code]....

View 2 Replies View Related

Variables Scope In Dynamic Functions - Display The Number 1 At First And Then 2

Mar 19, 2011

I have got this piece of code:

Code:

I would like to display the number 1 at first and then 2. but this code produces number 2 for both alerts. I was able to achieve what i wanted with "new" constructor when creating functions but this is not a good practice and after all i am passing these functions as an event handlers and it can't be done with "new" keyword because it is throwing error. I think there are some solutions with arrays e.g the x would be an array of numbers, but i don't like it. Am i missing something important?

View 3 Replies View Related

Get Variables Into PHP Variables Or MySQL Database?

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

Setting Html Variables To URL Variables

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

JQuery :: Populate A Dynamic Dropdown List Based On Another Dynamic Drop Down Selection?

Jun 29, 2010

how to populate a dropdown based on Another dropdown selection. This all should be a dynamic. Eg: I have two text boxes one is TechID and other is JOB ID. When I start typing Tech ID it suggests me the list of IDs which start with the input string i have put in Tech textbox. When i select the Tech ID the jobs associated to that Tech ID should be displayed in JOB ID text box as a dropdown list.

View 1 Replies View Related

A Nested Dynamic Checkbox Inside My Dynamic Form.

Jul 23, 2005

I am having a problem with the last results. I can't seem to be able to
get the input2A and input3A to appear. I don't seem to have a problem
with the show and hide after a number is entered and submitted. If
anyone can answer my problem I will be greatly appreciated with a
prize. I actually have submitted it more than once and I haven't had
anyone been able to answer it yet. Code:

View 5 Replies View Related

Dynamic Function With Dynamic Parameter On The Right Operand?

Jul 1, 2011

i was trying for some days now to find a solution for this. had a look at different posts and forums online, but no luck so far...is it possible to auto-create this with a loop???:

Code:
T$('infowindow1').onclick = function(){ setInfobox('1'); }
T$('infowindow2').onclick = function(){ setInfobox('2'); }

[code]....

View 5 Replies View Related

PHP Variables To Javascript Variables

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

Dynamic Drop-down List - Create A Dynamic Menu Where A User Selects One Item And Another Select List Is Shown

Jun 30, 2009

I've been beating my head against a wall for a few days trying to get this working. I'm trying to create a dynamic menu where a user selects one item and another select list is shown, then another and another (and so on). Here is my JS, it *should* be taking the ID of the div, comparing it to the selected value and then showing another div by settings it's class property to visible:

[Code]...

View 1 Replies View Related

Dynamic Calculation For Dynamic Form

Oct 25, 2010

I have made a script where you can add extra fields, and next to the row is a span that automatically displays the outcome from a calculation of three fields in that row. i.e. Q x (B - A) = total. Here is the bit that does the calculation:

function advCalc(selected) {
var result = Number(document.formmain.elements["quantity"+selected].value) * (Number(document.formmain.elements["provideamount"+selected].value) - Number(document.formmain.elements["supplyamount"+selected].value)) ;
[Code]....

View 23 Replies View Related

JQuery :: Validation Dynamic Rules - Add In Rules Dynamically Through The Rules(add) Function After Adding Some Dynamic Fields Through The User Inputs

Sep 6, 2011

I will like to know if there is anyway to view all the rules that I have currently in the Jquery validation plugin. Currently, I am trying to add in rules dynamically through the rules(add) function after adding some dynamic fields through the user inputs. the rules are added in this manner.

[Code]...

View 2 Replies View Related

Dynamic Form With A Dynamic Form Inside It...

Jul 23, 2005

INTRO: I tried to clean it up for easy reading. I hope I didn't make
any mistakes.

PROBLEM: WOW, this is some crazy sh!t. I can't get my checkbox (see
"TAGSELECTED") to print my textboxes (see "TAG#") when more than 1
number (see "VLANS") is inputed into my form.

QUESTION: How do I make my dynamic form have a dynamic input box(which
is created by checking the checkbox and calling the functionC1) inside
it and still be able to pass the values to my php page? Code:

View 4 Replies View Related

2 Variables In An URL

Apr 4, 2006

I thought it was possible to send two variables in an URL like this:

print" <script type='text/javascript'>
document.location.replace('http://127.0.0.1/add_task.php?tk_request_name={$req_name}?tk_req_id ={$maxValue}');
</script>";

but I can't get them separately in add_task.php

is there something wrong with script?

I use this code in some other PHP code.

View 1 Replies View Related

Using Variables As Variables

Apr 9, 2007

Lets say I have a variable declared as such:

var newVariable="opener";

How can I then use this variable to access the opener of 'window' ?

Meaning, I dont want to access it as such:

window.opener

but as: window.+newVariable

So it uses the contents of newVariable to access the opener.

I need this because I have a couple of variables which I need to concat to eachother as a string,
and this string in turn is the variable I need to access from window.opener.varSomething
where varSomething is the variable that stores the variable I need to access.

View 5 Replies View Related

Using ASP Variables

Jul 20, 2005

I use ASP to obtain data from a database and I have a piece of javascript
code I use on my website. I want to use the database variables in my
javascript. I'm not very familiar with javascript, but here is some info
similar to what I'm trying to do.

<%
strFirstName=session("FirstName")
strLastName=session("LastName")
%>

The javascript code I want to use the variables in.
Items[1]=["First Name", strFirstName,""]
Items[2]=["Last Name", strLastName,""]

Please help or point me to a website with this solution. Thanks much for
your help.

View 16 Replies View Related

Getting URL Variables

Jul 20, 2005

if the url was thispage.htm?day=4

how does one grab the day value?

View 2 Replies View Related

Getting Variables From PHP?

Feb 22, 2011

Not sure if php is the best solution or maybe javascript. ( or both.)

I am writing a litle script that will go to my mysql table and take out 20 rows ( from about 10,000 rows ) based on the WHERE statement.

Then I want to step through these 20 rows displaying just two filds in this fashion:

First, I want to display one field in a "box" ( using divs and css ) then wait for a form input. Then while keeping the first displayed box and field display the second field in a similar box a fee lines below. Wait for a form input update some data.

Then onto the next row.

If I use javascript then I could keep all the processing on one page and not have
to have server refreshes.

But how do I get these those array elements from $row['field1'] and $row['field2'] into javascript vars ?

Is this the best way to do this ?

Or would php and having a couple of extra trips to the server for form processing be better ?

View 5 Replies View Related

Getting The Sum Of Two Variables?

May 24, 2009

I would like to multiply combo_1 and combo_2 to give an outcome and display it in the textbox of txt_price using javascript.

f['txt_price'].value = (f['combo_1'].value).toFixed(2);

This is something I was working on but no results so far.

<form>
<select name="combo0" id="combo_0" onChange="change(this);" style="width:200px;">
<option value="0">-select-</option>
<option value="1">Canada</option>

[Code]....

View 2 Replies View Related

How To Get Sum Of Two Variables

May 24, 2009

I would like to multiply combo_1 and combo_2 to give an outcome and display it in the textbox of txt_price using javascript.
f['txt_price'].value = (f['combo_1'].value).toFixed(2);

This is something I was working on but no results so far.
<form>
<select name="combo0" id="combo_0" onChange="change(this);" style="width:200px;">
<option value="0">-select-</option>
<option value="1">Canada</option>
<option value="2">States</option>
</select><BR><BR>

<!-- I would like to Multiply this field -->
<select name="combo1" id="combo_1" onChange="change(this)" style="width:200px;">
<option value="1"></option>
</select><label></label>
<BR><BR>
<!-- and this field -->
<select name="combo2" id="combo_2" onChange="change(this);" style="width:200px;">
<option value="1"></option>
</select>
<BR><br>
<!-- To present an outcome to this field -->
<input type="text" name="txtPrice" id="txt_price" onChange="change(this);" style="width:200px;">
<BR></form>

View 4 Replies View Related







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