Java Script Problem

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Shiran

    Java Script Problem

    I have a javascript problem. I wish someone can solve it.
    I have a combobox where it displays string values.
    I have an unique id for each of the string values which is an integer.

    I am using form1.object.op tions[form1.object.se lectedIndex].id*1; so I
    can get the correct id for the selected string. This works fine for
    me.

    But in another combo I need to have the id as a 'String' not as an
    integer,
    for this the above javascript doesnt work. It returns an 'NaN'

    Please tell me how can I get the string id for the selected value.

    Any help is greatly appreciated

    Thanks
    Shiran.
  • steve stevo

    #2
    Re: Java Script Problem

    try
    parseInt(intege r)

    "Shiran" <shiranthad@eur ocenter.lk> wrote in message
    news:d66508ad.0 310011947.284d3 f1f@posting.goo gle.com...[color=blue]
    > I have a javascript problem. I wish someone can solve it.
    > I have a combobox where it displays string values.
    > I have an unique id for each of the string values which is an integer.
    >
    > I am using form1.object.op tions[form1.object.se lectedIndex].id*1; so I
    > can get the correct id for the selected string. This works fine for
    > me.
    >
    > But in another combo I need to have the id as a 'String' not as an
    > integer,
    > for this the above javascript doesnt work. It returns an 'NaN'
    >
    > Please tell me how can I get the string id for the selected value.
    >
    > Any help is greatly appreciated
    >
    > Thanks
    > Shiran.[/color]


    Comment

    • Lasse Reichstein Nielsen

      #3
      Re: Java Script Problem

      shiranthad@euro center.lk (Shiran) writes:
      [color=blue]
      > Please tell me how can I get the string id for the selected value.[/color]

      Drop off the "*1". It is only there to convert the string value to a
      number. If the string does not contain a number, trying to convert it
      gives NaN (Not a Number).

      /L
      --
      Lasse Reichstein Nielsen - lrn@hotpop.com
      Art D'HTML: <URL:http://www.infimum.dk/HTML/randomArtSplit. html>
      'Faith without judgement merely degrades the spirit divine.'

      Comment

      • W d'Anjos

        #4
        Re: Java Script Problem

        To avoid convertion problems with strings that start with '0' (treated
        as octals) you should specify the radix:

        parseInt(intege r, 10)



        I hope this helps.

        Wagner

        "steve stevo" <steve@stevoste ve.fsnet.co.uk> wrote in message news:<blgnvp$cb f$1@newsg1.svr. pol.co.uk>...[color=blue]
        > try
        > parseInt(intege r)[/color]

        Comment

        Working...