473,402 Members | 2,055 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,402 software developers and data experts.

Javascript question

If i have a number num = 123.456
How could i separate them into num1 = 123 / num2 = 456
Nov 13 '06 #1
1 796
vee10
141 100+
hi,

i think this is the solution for ur problem

Expand|Select|Wrap|Line Numbers
  1.  
  2.  
  3. <html>
  4. <head>
  5.     <title>Untitled Page</title>
  6.     <script type="text/javascript">
  7.     function splitnum()
  8.     {
  9.     var str=document.form1.text1.value;
  10.     index=str.indexOf(".");
  11.     if(index!=-1)
  12.     {
  13.     num1=str.substring(0,index);
  14.     num2=str.substring(index+1,str.length);
  15.     }
  16.     else{ num1=str;num2=0;}
  17.  
  18.     alert(num1);
  19.     alert(num2);
  20.     }
  21.     </script>
  22. </head>
  23. <body>
  24. <form name="form1">
  25. <input type="text" onblur="splitnum()" name="text1" />
  26. </form>
  27. </body>
  28. </html>
  29.  
  30.  
  31.  










If i have a number num = 123.456
How could i separate them into num1 = 123 / num2 = 456
Nov 13 '06 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: Colin Colin | last post by:
I downloaded a calendar.asp file that someone named Jacob "WickedPisser" Gilley made. It's a few years old but It works fine and it's what I was looking for without getting into ActiveX objects. ...
9
by: LNM | last post by:
I am trying to create a survey type form where multiple choice answers are selected (radios) and I am using an onclick event to update a text box with 'correct', etc. I am using the...
9
by: beguigne | last post by:
Below is a snippet of a crude date picking routine for a form. I am a novice at this so, I am hitting my head at why when I select the day, the onChange event gives me a blank. What am I missing?...
7
by: e | last post by:
I've been having an extremely difficult time finding an answer to this in IE / js groups, so I thought I'd try here. I've got an aspx page that delivers loads of report data into custom-named...
12
by: Joe | last post by:
Hello All: I'm sure that one of you can quickly spot the error in my script. I am using a small javascript function to retrieve the text of a hyperlink in a datagrid column. Here is my...
1
by: number1.email | last post by:
Hello, I have a simple Web Page Questionairre in which questions are read from a database, and the user can indicate the correct answer via either a radio input control or a dropdown list. The...
4
by: Joey | last post by:
I am going to use a collection of either div HTML server controls or panel web server controls (renders as div on newer browsers) on a web form. I need to be able to hide them with a client-side...
17
by: Man-wai Chang | last post by:
I have a form formABC that has a textbox plus a button. On clicking the button, window.open() a popup window for user to select a value. The value will then be passed back to formABC's textbox. ...
1
by: Daniel Kaplan | last post by:
So just started playing with Javascript, and my first run at making three step buttons came out just fine. But I do have a general question. In my book's example in the HTML script the IMG tags...
3
by: bnsmith001 | last post by:
I have a text file with 29766 words in it. Currently, the file is formatted with one word per line, followed by a DOS CR/LF. I'd like to write a Word-of-the-Day tool solely in javascript, where I...
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: 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
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

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.