HighDots Forums  

newby question joining variables and strings together

JavaScript discussion (multi-lingual) JavaScript discussion (alt.comp.lang.javascript)


Discuss newby question joining variables and strings together in the JavaScript discussion (multi-lingual) forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
chris
 
Posts: n/a

Default newby question joining variables and strings together - 09-21-2005 , 04:27 PM






im pretty ne to java script - so please be gentle

basically what i want to do is construct an action in a function using a
variable sent to that function


ok - what i want to do is

function ($number)
{
form1.button[add in the $number here].disabled=true;
}

say $number was 34, so in effect i would end up with

function ($number)
{
form1.button34.disabled=true;
}

i have tried all sorts but cnt seem to get the result i want - any advice
would be great






Reply With Quote
  #2  
Old   
web.dev
 
Posts: n/a

Default Re: newby question joining variables and strings together - 09-21-2005 , 04:37 PM







chris wrote:
Quote:
im pretty ne to java script - so please be gentle

basically what i want to do is construct an action in a function using a
variable sent to that function


ok - what i want to do is

function ($number)
{
form1.button[add in the $number here].disabled=true;
}

say $number was 34, so in effect i would end up with

function ($number)
{
form1.button34.disabled=true;
}

i have tried all sorts but cnt seem to get the result i want - any advice
would be great
I believe the effect you want to achieve is the following:

function myFunc(btnNum)
{
document.forms["formName"].elements["button" + btnNum].disabled =
true;
}

Hope this helps.



Reply With Quote
  #3  
Old   
Jasen Betts
 
Posts: n/a

Default Re: newby question joining variables and strings together - 10-15-2005 , 07:48 PM



["Followup-To:" header set to alt.comp.lang.javascript.]
On 2005-09-21, chris <someone (AT) here (DOT) com> wrote:
Quote:
im pretty ne to java script - so please be gentle

basically what i want to do is construct an action in a function using a
variable sent to that function


ok - what i want to do is

function ($number)
{
form1.button[add in the $number here].disabled=true;
}

say $number was 34, so in effect i would end up with

function ($number)
{
form1.button34.disabled=true;
}

this appears to be what you are trying to di,
it may work (I have not tested it).
but it is non-standard and will cause warnings in mozilla, and may not at all in
other browsers.

function ($number)
{
eval("form1.button"+$number+".disabled=true;");
}

you should be using document.GetElementById

this means giving any element you want to refer to an id tag.
that means you can have non-submitted form inputs by not giving
them a name tag.

Bye.
Jasen


Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.