473,395 Members | 1,471 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

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.options[form1.object.selectedIndex].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.
Jul 20 '05 #1
3 2401
try
parseInt(integer)

"Shiran" <sh********@eurocenter.lk> wrote in message
news:d6**************************@posting.google.c om...
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.options[form1.object.selectedIndex].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.

Jul 20 '05 #2
sh********@eurocenter.lk (Shiran) writes:
Please tell me how can I get the string id for the selected value.


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 - lr*@hotpop.com
Art D'HTML: <URL:http://www.infimum.dk/HTML/randomArtSplit.html>
'Faith without judgement merely degrades the spirit divine.'
Jul 20 '05 #3
To avoid convertion problems with strings that start with '0' (treated
as octals) you should specify the radix:

parseInt(integer, 10)

http://devedge.netscape.com/library/...v.html#1064173

I hope this helps.

Wagner

"steve stevo" <st***@stevosteve.fsnet.co.uk> wrote in message news:<bl**********@newsg1.svr.pol.co.uk>...
try
parseInt(integer)

Jul 20 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Andy R. | last post by:
Hello everyone, I've spent quite some time now, looking for some information on how to get this done, sadly none has helped me much, though. I have a bit of java scrpt on a webpage (.php) to...
3
by: StealthMonkey | last post by:
Let me prefix this by saying that I know next to nothing about Java (so please try to keep explainations simple). I use PHP for my server-side web programming. Here is my dilemma: I need a...
4
by: Don Grover | last post by:
I hope some one can help, I have a html table that is created with asp that has a row of repeated buttons down the side. these call a page passing a query string with invoice number. I need to...
18
by: Mickey Segal | last post by:
On comp.lang.java.programmer we are discussing problems created for Java programs by pop-up blockers (in the thread "showDocument blocked by new microsoft pop-up blocker"). Our problem is that...
34
by: kpg | last post by:
Hello all, I have an asp.net web application with tons of Java script files. I would like to protect the Java Script somehow so it can't be seen by a remote user. I found several 3rd party...
9
by: Stephen H. | last post by:
Hi, I have an existing web application with java beans that I wanne migrate to ASP.NET using C#. The existing web application has some jsp files that use java beans as follows: .... <%@...
7
by: dbabin | last post by:
I have a java script function enableServerList() {document.getElementById("ddlServers").disabled=false } function disableServerList() {document.getElementById("ddlServers").disabled=true } ...
4
by: Quill_Patricia | last post by:
I have a Python script which is used to load data into a database. Up to now this script has been run by customers from the Windows command prompt using "python edg_loader.pyc". Any error messages...
0
by: tosreejithp | last post by:
Hi, My first problem was i am not able to compiled a file from java script to java class.Now its clear and working fine..now i can convert a java script file to java class by Rhino Java Script...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.