Sponsored Content
Top Forums Web Development Javascript to force decimals in 0.25 steps Post 302918558 by Akshay Hegde on Wednesday 24th of September 2014 07:42:40 AM
Old 09-24-2014
You mean like this ,

Code:
<script type="text/javascript">
   var fixed = 0.25
   function TextChange(e)
   { 
        if (isNaN(e.value)){ alert('must be numeric'); return  }
       
	var v = Math.floor( (parseFloat( e.value.toString().split(".")[1].substring(0,2) ) * 0.01)/fixed ); 
     e.value  =  (e.value | 0 ) +  fixed * (isNaN(v) ? 0 : v);   
   }
</script>

<input type="number" onchange="TextChange(this)" />


Last edited by Akshay Hegde; 09-24-2014 at 08:54 AM..
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

handle decimals

Hi All, How we can handle decimals in (Float) in UNIX. a=73 b=5 c=`expr a / b` i am getting 14 but i need full 14.6 . Can any one help me pls? (1 Reply)
Discussion started by: subin_bala
1 Replies

2. Shell Programming and Scripting

Bourne and decimals??

I need to get 15% of the variable exer1 to be added to other exercises so far, i've got exer1=$1 aver=`expr $exer \* .15` but i keep getting an error that an integer value was expected. Is there anyway around this? (1 Reply)
Discussion started by: kdyzsa
1 Replies

3. Shell Programming and Scripting

convert Regular decimals to Packed decimals

Hi, I am trying to find if there is a way to convert regular decimal values to Paced decimal values. I tried to find a c program but I could get a Packed converted to regular decimal not the other way round. If not unix please let me know if any other progrimming language I can use to do... (2 Replies)
Discussion started by: mgirinath
2 Replies

4. Shell Programming and Scripting

Decimals in TCSH

Hello, I want to run a loop with non-integer values (which I know I can't) so I've created a loop of integers and divided it by 10. However, these values are always rounded down to 1 significant figure. How do I get the script to keep and use the decimal value? My script is as follows #... (1 Reply)
Discussion started by: DFr0st
1 Replies

5. UNIX for Dummies Questions & Answers

Regarding Decimals in Cshell

Hello... I am new to unix and I am wondering if in a C-shell script , Are we supposed to use only whole numbers........ for example..if a program needs to calculate the average of some numbers........ @ avg = (($1 +$2 + $3)/3)) is returning a whole number.........How can a decimal be achieved... (1 Reply)
Discussion started by: ravindra22
1 Replies

6. Shell Programming and Scripting

Grep wholenumbers / decimals

Hi I have a large file in which I need to search for certain whole numbers and print the whole line. I'm currently trying this via command line using grep but grep is also matching the decimal values and i just want to return the matching whole numbers (the entire line) Example File ddggg ... (7 Replies)
Discussion started by: duckeggs01
7 Replies

7. Shell Programming and Scripting

Round up the decimals

Hi All, I would like to do the following in the shell script 561.76 to 562 I tried using this echo 'scale=0; 749 * 75 /100 ' | bc but just returned only 561 Please help me . I appreciate your help Thanks rajeevm (13 Replies)
Discussion started by: rajeevm
13 Replies

8. Shell Programming and Scripting

Getting date in seconds with decimals

I am trying to get date to display decimal Desired output 1350386096256.12 I know this can be done with printf, but are not able to make it work. I have tested this and many otherprintf "%.2f" $(($(date +%s%N)/1000000)) (8 Replies)
Discussion started by: Jotne
8 Replies

9. Programming

Decimals reading Python

Hello, i'm new in python. Consider that i have this function that read me some data from a serial : def GetData(): line = open(serialx).read() hash = line.find("#") when = line count = line # print when, count, line return (float(when), int(count)) it gives me the result... (2 Replies)
Discussion started by: Board27
2 Replies

10. Shell Programming and Scripting

how to find the field has more than 2 decimals

Hi Gurus, I have below sample file, I need find the line which 2rd field has more than 2 decimals. in sample file, I need to find xyz, 123456.789 abc, 1234.45, def xyz, 123456.789, xxx bce, 1234.34, xxx thanks in advance (13 Replies)
Discussion started by: ken6503
13 Replies
LMORPH(1)						      General Commands Manual							 LMORPH(1)

NAME
lmorph - morphing lines SYNOPSIS
lmorph [-display host:display.screen] [-foreground color] [-background color] [-window] [-root] [-mono] [-install] [-visual visual] [-points int] [-steps int] [-delay usecs] [-figtype type] DESCRIPTION
The lmorph program shows smooth and non-linear morphing between 1D curves. OPTIONS
lmorph accepts the following options: -window Draw on a newly-created window. This is the default. -root Draw on the root window. -mono If on a color display, pretend we're on a monochrome display. -install Install a private colormap for the window. -visual visual Specify which visual to use. Legal values are the name of a visual class, or the id number (decimal or hex) of a specific visual. -points integer Number of points in each line drawing. Default is 200 points. -steps integer Interpolation steps from one drawing to the next. Default is 150. You may specify 0, to get a random number between 100 and 500. -delay microseconds How much of a delay should be introduced between steps of the animation. Default 70000. -figtype type Limit the figures to only open or closed figures. Possible types are "all" (default), "open" and "closed". -linewidth integer Width of lines. Default is 5 pixels. ENVIRONMENT
DISPLAY to get the default host and display number. XENVIRONMENT to get the name of a resource file that overrides the global resources stored in the RESOURCE_MANAGER property. SEE ALSO
X(1), xscreensaver(1) AUTHOR
Sverre H. Huseby <sverrehu@online.no> and Glenn T. Lines <glennli@ifi.uio.no>, built on top of the screen saver routines by Jamie Zawinski <jwz@jwz.org>. xscreensaver hack LMORPH(1)
All times are GMT -4. The time now is 03:40 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy