When is a number not a number?

I've got some server script that determines the "SELECTED" entry in a SELECT
control.  (The code below is a snippet.)  If no information is returned then
I want the number defaulted a hard-coded value, otherwise, I want number
that matches the returned value selected.  The defaulted, hard-coded value
works but the comparison (i == val) doesn't work if a a value was returned
in the information.  I've verified that it is indeed a number within the
range I want.

Why would this comparison fail like this?

TIA
Alan Rosine

<snip>
if (docInfo.advPayMonths == null) || (docInfo.advPayMonths == undefined) ||
isNaN(docInfo.advPayMonths) {
    val = 6;
} else {
    val = docInfo.advPayMonths;
}

for (i = 1; i <= 12; i++) {
    document.write('<OPTION VALUE=' + i);
    if (i == val) {
        document.write(' SELECTED');
    }
    document.write('>' + i + '-' + val);
}
<snip>



0
Alan
8/10/2001 12:44:40 AM
sybase.powersite 2112 articles. 0 followers. Follow

3 Replies
1696 Views

Similar Articles

[PageSpeed] 26

Try using the eval() JS method 
A.

Alan Rosine wrote:
> 
> I've got some server script that determines the "SELECTED" entry in a SELECT
> control.  (The code below is a snippet.)  If no information is returned then
> I want the number defaulted a hard-coded value, otherwise, I want number
> that matches the returned value selected.  The defaulted, hard-coded value
> works but the comparison (i == val) doesn't work if a a value was returned
> in the information.  I've verified that it is indeed a number within the
> range I want.
> 
> Why would this comparison fail like this?
> 
> TIA
> Alan Rosine
> 
> <snip>
> if (docInfo.advPayMonths == null) || (docInfo.advPayMonths == undefined) ||
> isNaN(docInfo.advPayMonths) {
>     val = 6;
> } else {
>     val = docInfo.advPayMonths;
> }
> 
> for (i = 1; i <= 12; i++) {
>     document.write('<OPTION VALUE=' + i);
>     if (i == val) {
>         document.write(' SELECTED');
>     }
>     document.write('>' + i + '-' + val);
> }
> <snip>

-- 
__________________________

Adam Simmonds [TeamSybase]
System Architect
ITS FLEXSIS PROJECT
The University of Sydney
Phone:  +61 2 9351 5174
Mobile: +61 403 341 474
Fax:    +61 2 9351 7711
0
Adam
8/10/2001 3:55:09 AM
Am I not understanding?  It seems that the eval() method executes a piece of
code.  I'm trying to perform a comparison.  The example does show it well
but the if statement is a comparison ( if (i = = val) ) and not an
assignment.  I did try using the eval() method but no joy.

Any other suggestions?

TIA
Alan Rosine

"Adam Simmonds [TeamSybase]" <asimmond@mail.usyd.edu.au> wrote in message
news:3B735B1D.3B823FEF@mail.usyd.edu.au...
> Try using the eval() JS method
> A.
>
> Alan Rosine wrote:
> >
> > I've got some server script that determines the "SELECTED" entry in a
SELECT
> > control.  (The code below is a snippet.)  If no information is returned
then
> > I want the number defaulted a hard-coded value, otherwise, I want number
> > that matches the returned value selected.  The defaulted, hard-coded
value
> > works but the comparison (i == val) doesn't work if a a value was
returned
> > in the information.  I've verified that it is indeed a number within the
> > range I want.
> >
> > Why would this comparison fail like this?
> >
> > TIA
> > Alan Rosine
> >
> > <snip>
> > if (docInfo.advPayMonths == null) || (docInfo.advPayMonths == undefined)
||
> > isNaN(docInfo.advPayMonths) {
> >     val = 6;
> > } else {
> >     val = docInfo.advPayMonths;
> > }
> >
> > for (i = 1; i <= 12; i++) {
> >     document.write('<OPTION VALUE=' + i);
> >     if (i == val) {
> >         document.write(' SELECTED');
> >     }
> >     document.write('>' + i + '-' + val);
> > }
> > <snip>
>
> --
> __________________________
>
> Adam Simmonds [TeamSybase]
> System Architect
> ITS FLEXSIS PROJECT
> The University of Sydney
> Phone:  +61 2 9351 5174
> Mobile: +61 403 341 474
> Fax:    +61 2 9351 7711


0
Alan
8/10/2001 3:43:56 PM
Hi there.=20

I think you should try using parseInt() function.

It looks like the i =3D=3D val comparation is not working because val =3D=20
docInfo.advPayMonths is not read as a number, but as a string. parseInt=20
converts the string to an integer.

Try this:=20

val =3D parseInt(docInfo.advPayMonths);

Also, you can find some info here:=20
http://developer.netscape.com/docs/manuals/communicator/jsref/index.htm

(click the index on the left, then use the "find" function of your browser =

to find "parseInt"). Please tell me if this works.

---
Giannino Alvarez
giannino=5Falvarez@mx.sony.com
M=E9xico City

0
Giannino_Alvarez
11/29/2001 10:37:50 PM
Reply:

Similar Artilces:

problem with number/number=number ?
hi i need for below 1/36 = 0,0277777777777778 but result should be 1 3/36 should be 1 35/36 should be 1..... (between 1 and 36)/36 should be 1 36/36  and 37/36 and 45/36 and 71/36 should be 2  (between 72 and 37)/36 should be 2  (between 107 and 73)/36 should be 3  and go on how can i do it ? ThanksMark as me if my question or my answer can be helpful for you :) Hi, I think that (int)(n / 36) + 1 will do the trick  hi it work true without below  result 1 for 1/36 and 4 /36 and 35 /36 .. it is true.. but result 2 for 36/36 . res...

Re-number week numbers?
Is it possible to have week numbers off-set i.e.. for educational use week 1 is beginning of September ....... ...

Number of connections (spid numbers)
Since upgrading from 11.9.2 to 12.5.1, I have noticed a significant increase in the spid number assigned to connections. Actually, it broke an application that captures @@spid to a 3-char field. I usually have no more than between 300 and 400 concurrent connections with anywhere from 30 - 50 new connections each hour (per sysmon). The spid numbers are now reaching over the 1000 mark. Has anything changed in how spid numbers are assigned? I assumed that a spid number is assigned either by one thats been previously assigned and available or the next highest number sequentially. If I ch...

Replace number with Number+R
Using vb.net 2005 I want to do the following: I have a formula, ex, something like 1 + 2 + ((3 + 4 + 5)/4) and I want to replace each number with number+R ex: 1R + 2R +....   and so on. whats a good code snippet to do this?  I am thinking some regexp will do the trick. think i just got it: someString = System.Text.RegularExpressions.Regex.Replace(someString , "\d+", "$&R")...

Number of User, Number of Connections
Hi, Does open client provide a mechanism to write an application that will alow me to monitor the number of users and connections to a database? Regards, San > Does open client provide a mechanism to write an application that will alow > me to monitor the number of users and connections to a database? I do not think Open Client has a way to do it, but I think the easiest is to select the info from master.dbo.sysprocesses Stephan On Sun, 12 Aug 2001 16:18:03 -0400, Stephan Marais <smarais@mindspring.com> wrote: You could write an openclient application tha...

Check for number of Numbers in a string
Hi all, Need some help here. I know in C++ and Java, I can check for the number of Numbers in sa string. One example is "RN12" will have 2 numbers while "RN1234" will have 4. How do I do it in VB.net? Thanks for all the help!SGDOTNET.ORG I know there has to be a better way but couldn't you just write an for next statement to analyze the string? Imports Microsoft.VisualBasic.Information For i = 0 to myString.Length() Step 1 If IsNumeric(Mid(myString,1,1)) Then '//Do something really neat End If Next You may have to tweak that ...

Random number excluding a number.
i have been playing around with random numbers and to get a random number between say 1 and 100 i use a code like this : System.Random RandNum2 = new System.Random(); int MyRandomNumber2 = RandNum2.Next(1, 100); but if i want to get a number between 1 and 100 excluding the number 50. is this possible? thanks Si  Kind of a funny concept for random, but you could put the calls to random in a loop and exit when the result is not 50. blink18jew:i have been playing around with random numbers and to get a random number between say 1 and 100 i use a code like this : ...

Number
Hello,What should be the data type for holding numbers with 2 decimal places (2.32, 4.23, 1.23, ...)?Thanks,Miguel You could use the double datatype double decimalNumber = 12.21; for more about datatypes check this link HCHaissam Abdul MalakMCAD.NET| Blog | u can use double.parse or System.Math.Round functions  have a look at the code below  double number = 123456.646;number = double.Parse(number.ToString("####0.00")); Decimal d = 17.3501m;d = Math.Round(d, 2);Arshad Rasheed - MCPFree ASP.Net & Ajax books Please mark the most helpful reply/replies as "Answer"...

Number
Hello,Inside a GridView I am accessing a value of the datasource:DataBinder.Eval(gvrContainer.DataItem, "Average")I know this is of type Double. I want to round it and change it to integer.How can i do this?Thanks,Miguel  Either of the following.(replace "num" with your column name "Average") <asp:TemplateField HeaderText="num" SortExpression="num"> <ItemTemplate> <asp:Label ID="Label2" runat="server" Text='<%# Eval("num", "{0:F0}") %>'></asp:Label> </ItemTemplate> </asp:TemplateField>   <asp:BoundField DataField="num" HeaderTex...

number
How to get host name and port number from my computer please send me the details HttpContext.Current.Request.Url.Host HttpContext.Current.Request.Url.Port  --------------------------------------------------------Don't forget to click "Mark as Answer" on the post(s) that helped you.NHibernate with ASP.net Problem-Design-Solution sample applicationScott ASP.net blog   HttpContext.Current.Request.Url.Host HttpContext.Current.Request.Url.PortRegardsNicsam[!!!!!!!Hopes this helps you!!!!!!!]...

number
Name: panda-fighter@yandex.ru Email: panda-fighteratyandexdotru Product: Minefield Summary: number Comments: 75215 Browser Details: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:2.0a1pre) Gecko/2008051003 MRA 5.3 (build 02560) Minefield/4.0a1pre From URL: http://hendrix.mozilla.org/ Note to readers: Hendrix gives no expectation of a response to this feedback but if you wish to provide one you must BCC (not CC) the sender for them to see it. ...

number
Hi there I'm a new bird to Perl - and I have a little problem. I have a file input where I split the file into an array and that works fine, but there is some "spam" in the beginning of the file I want to get rid of - the problem is that I never know how many lines there is with this "spam"! Therefore I want to make a check that excludes all lines there doesn't start with a number in other languages I would make a check like If (! isNaN(string)) { ..... } How do I make this check In Perl? I haven't been able to find something similar in ...

AutoCompleteExtender number minus number bug?
hey fellow developpersi have created an extremely simple solution to recreate my problem..so i have a  <asp:TextBox /> and a <cc1:AutoCompleteExtender /> which is linked to the webservice that just does this:1 <WebMethod()> _ 2 <System.Web.Script.Services.ScriptMethod()> _ 3 Public Function GetList() As String() 4 Dim strReturn As New List(Of String) 5 6 strReturn.Add("10056") 7 strReturn.Add("10056-01") 8 9 Return strReturn.ToArray 10 End Function so whatever i type in the textbox, the ...

How to convert a hexadecimal number to normal number?
In VB.NET, how can I convert a hexadecimal number (like FF) to normal number (like 255) ?? Come on, gurus, this must be a piece of cake for you!:-) Any help appreciated, thanks, Hooker try to use System.Convert.ToInt16(your parameter) hope this work...if this doesn't work there should be some method in the 'convert' class.Toronto Trade show displays | Toronto Printing Solutions | Toronto Printing...

Web resources about - When is a number not a number? - sybase.powersite

Number - Wikipedia, the free encyclopedia
A number is a mathematical object used to count , label, and measure . In mathematics , the definition of number has been extended over the years ...

Number - Wikipedia, the free encyclopedia
A number is a mathematical object used to count , label, and measure . In mathematics , the definition of number has been extended over the years ...

Police boost numbers at schoolies after Paris attacks
For police patrolling Australia's biggest annual gathering of school leavers on the Gold Coast, the combination of celebratory teenagers, alcohol,&nbsp;extreme ...

Old Lady Lawyer: Meet Fred Rodell — He Has Our Number
A book on the legal profession from the 1930s s just as prescient and on point about us and our profession as it was when first published almost ...

Macy's Thanksgiving Day Parade by the Numbers: You Won't Believe How Many Clowns!
"It's probably the only place you'll see Dolly Parton in a van talking to Kermit the Frog." So says John Piper, VP of Macy's Studio, whose team ...

"But when the researchers crunched the numbers to find out if there's an upper limit to improving well-being ...
"... they found that the happiness maxed out at sex about once a week." "This showed a linear association between sex and happiness up to a ...

Meteors traveling at over 160,000 mph are falling in large numbers tonight — here's how to watch
The moon will be setting in the early evening hours on Tuesday, which is good news for viewers because it means dark skies for the Leonid meteor ...

Roxas' camp on latest survey: Our numbers are improving
... bet trailing behind two other candidates, the administration party says the latest Pulse Asia survey shows that Manuel "Mar" Roxas III's numbers ...

How tech led to the death of France's public enemy number 1
When one of the terrorists involved in the Paris shootings dropped his smartphone in a trashcan outside the Bataclan concert venue on Friday ...

People tweeted their phone number and got spammed with cat facts
There are people who share their real phone numbers via a tweet. Yes, really. One programmer decided to teach those folks a lesson by spamming ...

Resources last updated: 11/22/2015 3:14:14 PM