Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Web Programming > JavaScript > Javascript How-To
|
Javascript How-To Ask your "How do I do this with Javascript?" questions here.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Javascript How-To section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old October 4th, 2005, 05:03 AM
Friend of Wrox
 
Join Date: Jan 2005
Posts: 1,525
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via ICQ to crmpicco Send a message via AIM to crmpicco Send a message via MSN to crmpicco Send a message via Yahoo to crmpicco
Default create a variable dynamically in JavaScript

Code:
var arrival"+s+" = document.forms["form"].elements["arrival"+s].value;
Is there a way to create a variable dynamically in JavaScript?

The above code doesnt work, also tried:

Code:
var arrival[s] = document.forms["form"].elements["arrival"+s].value;



www.crmpicco.co.uk
__________________
_______________________
Ayrshire Minis - a Mini E-Community
http://www.ayrshireminis.com
http://www.crmpicco.co.uk
 
Old October 4th, 2005, 05:46 AM
Friend of Wrox
 
Join Date: Oct 2004
Posts: 553
Thanks: 0
Thanked 1 Time in 1 Post
Send a message via MSN to vinod_yadav1919 Send a message via Yahoo to vinod_yadav1919
Default

Hi Crmpicco!!
 Use eval function.
 Hope this will help you


Cheers :)

vinod
 
Old October 4th, 2005, 06:14 AM
joefawcett's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 3,074
Thanks: 1
Thanked 38 Times in 37 Posts
Default

You would normally use an array for this sort of thing.
Why do you need to create a variable dynamically?

--

Joe





Similar Threads
Thread Thread Starter Forum Replies Last Post
php take get variable and dynamically set values crmpicco PHP How-To 1 October 22nd, 2007 07:19 PM
storing Javascript variable to ASP variable rupen Classic ASP Basics 5 April 10th, 2007 07:06 AM
assign javascript variable to asp variable manjunath_c_k Classic ASP Basics 1 September 14th, 2006 07:35 AM
create a new variable in javascript crmpicco Classic ASP Basics 2 February 2nd, 2005 12:53 PM
Dynamically create tables vickriz Javascript How-To 8 August 5th, 2003 03:00 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.