Skip to content

Tag: javascript

Remove uneven prices from list of price

I have prices array like this Above is the list of price , where there are few uneven numbers like 0, 300, 301 I am trying to remove those odd numbers by following code I am basically comparing current number with previous number and if difference is more than 50 i am excluding it to my fresharray , but my

How to make background of a textbox with a if condition

I have below input text field. I need to change the background color of this textbox according to the text. From below code, I could get this done after clicking on the box. Here is my CSS class. But I need to show the red color border without clicking. Further I need to change the background also to red colo…

Splitting string into array based on first and last

I have this array :- var a = [‘ DL1,C1,C5,C6′,’M4,DL3-7,B1-5’] And I want to split them like [DL1,C1,C5,C6,M4,DL3,DL4,DL5,DL6,DL7,B1,B2,B3,B4,B5] So that DL3-7 or DL3-DL7 this Split like this DL3,DL4,DL5,DL6,DL7 Reason why I am doing this, is because I want to block duplicate entry lik…

JavaScript, get the value of input field on entry

I have a HTML page with an input field that the user enters a value into. The HTML code looks like this: I’m trying to use JavaScript to get the value entered by the user so that I can then compare it against another value and write out the result, but I’m not sure how I collect the initial value