converting a variable within a append document.forms string

Discussion in 'ASP .Net' started by barry, Dec 22, 2005.

  1. barry

    barry Guest

    I have the following:
    function(NAMED)
    {
    sString.Append("document.forms[0].NAMED.style.visibility = 'hidden'")
    }

    and would like to convert the NAMED into the object it represents - for
    example in this case it represents the name of an image called card17

    thanks
     
    barry, Dec 22, 2005
    #1
    1. Advertising

  2. Hi Barry,

    Where are you getting the Append() method from? Is this server or client
    side code? Neither the .Net String class (v1.1) or the JavaScript string
    class (v2.0) have an append method as far as I can tell.

    If this is client-side javascript as I suspect, I would suggest the
    following. The replace() method uses regular expressions (yuck!):

    function namedSubstitude( ElementName )
    {
    // assumes sString is in scope for somewhere...
    sString.replace(/NAMED/i, ElementName) ;
    }

    Hope this helps,
    Mark

    barry wrote:

    >I have the following:
    >function(NAMED)
    >{
    >sString.Append("document.forms[0].NAMED.style.visibility = 'hidden'")
    >}
    >
    >and would like to convert the NAMED into the object it represents - for
    >example in this case it represents the name of an image called card17
    >
    >thanks
    >
    >
    >
    >
     
    Mark Micallef, Dec 23, 2005
    #2
    1. Advertising

  3. barry

    barry Guest

    Sorry, should have been more explicit
    This is in a codebehind file and is using IsStartupScriptRegistered to run
    the javascript
    all of what follows is in the script code

    I am passing to a function a name attribute from an img tag. I have checked
    the name attribute and it is what I want but
    when I try to use it in the following script code I can not get the passed
    attribute to convert to its actual value.
    I have tried using

    The attribute passed is called card

    sString.Append("document.forms[0]." + card + ".style.visibility =
    'hidden'")

    You would think the above would work but the attribute card needs to be put
    in "card" for the syntax to work and of course this does not convert
    properly

    Any help is appreciated.

    "Mark Micallef" <> wrote in message
    news:...
    > Hi Barry,
    >
    > Where are you getting the Append() method from? Is this server or client
    > side code? Neither the .Net String class (v1.1) or the JavaScript string
    > class (v2.0) have an append method as far as I can tell.
    >
    > If this is client-side javascript as I suspect, I would suggest the
    > following. The replace() method uses regular expressions (yuck!):
    >
    > function namedSubstitude( ElementName )
    > {
    > // assumes sString is in scope for somewhere...
    > sString.replace(/NAMED/i, ElementName) ;
    > }
    >
    > Hope this helps,
    > Mark
    >
    > barry wrote:
    >
    > >I have the following:
    > >function(NAMED)
    > >{
    > >sString.Append("document.forms[0].NAMED.style.visibility = 'hidden'")
    > >}
    > >
    > >and would like to convert the NAMED into the object it represents - for
    > >example in this case it represents the name of an image called card17
    > >
    > >thanks
    > >
    > >
    > >
    > >
     
    barry, Dec 23, 2005
    #3
  4. barry

    barry Guest

    Sorry, I was not more explicit
    This is client side javascript in a codebehind
    All of what I am about to say is in the javascript code
    I have a img tag with a name attribute that I am passing to a function
    The attribute when I run my browser over it shows up as the correct value
    but will not convert in the code below

    sString.Append("document.forms[0]." + card + ".style.visibility = 'hidden'")

    First this gets a syntax error and I have to but the card(attribute passed)
    in double quotes which will of course then not convert properly.

    Any help would be appreciated.


    "Mark Micallef" <> wrote in message
    news:...
    > Hi Barry,
    >
    > Where are you getting the Append() method from? Is this server or client
    > side code? Neither the .Net String class (v1.1) or the JavaScript string
    > class (v2.0) have an append method as far as I can tell.
    >
    > If this is client-side javascript as I suspect, I would suggest the
    > following. The replace() method uses regular expressions (yuck!):
    >
    > function namedSubstitude( ElementName )
    > {
    > // assumes sString is in scope for somewhere...
    > sString.replace(/NAMED/i, ElementName) ;
    > }
    >
    > Hope this helps,
    > Mark
    >
    > barry wrote:
    >
    > >I have the following:
    > >function(NAMED)
    > >{
    > >sString.Append("document.forms[0].NAMED.style.visibility = 'hidden'")
    > >}
    > >
    > >and would like to convert the NAMED into the object it represents - for
    > >example in this case it represents the name of an image called card17
    > >
    > >thanks
    > >
    > >
    > >
    > >
     
    barry, Dec 23, 2005
    #4
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Tony Prichard
    Replies:
    0
    Views:
    791
    Tony Prichard
    Dec 12, 2003
  2. Manish Hatwalne
    Replies:
    1
    Views:
    423
    Martin Honnen
    Jul 13, 2004
  3. Replies:
    4
    Views:
    716
  4. HYRY
    Replies:
    10
    Views:
    647
    Bruno Desthuilliers
    Sep 26, 2007
  5. Chris Hohmann
    Replies:
    5
    Views:
    248
    Ray at
    Sep 4, 2003
Loading...

Share This Page