JavaScript - Create Specific Number Output Based Upon Internal Calcs
Need help - sorry for the novice-ness of this.
Have a computed field ("Subtotal"). With that number, need to set up rule such that if Subtotal is a certain number, a certain number will print in the new field (lets call it "First"). Here's what I have so far... var a=getField("Subtotal").value; var b=5000; var c=9000; var d=33000; var e=53000; var f=68000; var g=78000; var h=83000; var i=0; Code: if (a.value<=100000){ event.value=b } else if (a.value<=200000 && a>100000){ event.value=c.value } else if (a.value<=1000000 && a>200000){ event.value=d.value } else if (a.value<=2000000 && a>1000000){ event.value=e.value } else if (a.value<=3000000 && a>2000000){ event.value=f.value } else if (a.value<=4000000 && a>3000000){ event.value=g.value } else if (a.value<=5000000 && a>4000000){ event.value=h.value } else if (a.value==0){ event.value=i.value } Any thoughts??? Help is GREATLY appreciated. D Similar TutorialsNoob here! I'm doing a little project where i need to take a number (lets say 6), and then I need to find out witch numbers 6 can divided with that equals to a whole number. Any ideas how i can do that? This is what i got in my mind so far: myNum/num === wholeNumber I then need a variable "num" that count all whole numbers from 0 to myNum and a variable "wholeNumber" that works as all whole numbers from 0 to myNum. I really hope you can help me out, thanks Hi does anyone know how to output a reformated number to a form?? This is what I have so far: Code: if (!document.userSurvey.phone.value) { alert("Phone number missing. Please enter a valid phone number to continue."); document.userSurvey.phone.focus(); return false; } else { var numbersOnly = ""; var chars = ""; var phoneNo = document.userSurvey.phone.value; for (i = 0; i < phoneNo.length; i++) { chars = phoneNo.substring(i,i+1); if (chars >= "0" && chars <= "9") { numbersOnly = numbersOnly + chars; } } if (numbersOnly.length != 13) { alert("Incorrect phone number format.You must enter 13 numbers."); document.userSurvey.focus(); return false; } else { var areacode = numbers.substring(0,2); var leading0 = numbersOnly.substring(2,3); var exchange = numbersOnly.substring(3,5); var ext1 = numbersOnly.substring(5,9); var ext2 = numbersOnly.substring(9); var newNumber =( "+" + areacode + " " +"(" + leading0 + ")" + exchange + " " + ext1 + "-" + ext2); Hi guys, I am new to java, I am having trouble on outputting the num2 on the screen. I could not see any errors indicated the problem on the program(Eclipse). However, the program just miss scan the num2. I was trying to sort the number and output them from smallest to largest. Any suggestion would be helpful and appreciated! ----------------------------------Code import java.util.Scanner; public class Demo{ public static void main(String[] args){ System.out.println("Please input three songs' BPMs"); int S,M,L; Scanner keyboard =new Scanner(System.in); int num1 = keyboard.nextInt(); int num2 = keyboard.nextInt(); int num3 = keyboard.nextInt(); boolean isAllSame = (num1 == num2) && (num2 == num3) && (num1 == num3); boolean isDI = (num1 != num2) && (num2 != num3) && (num1 != num3); boolean isTS = (num1 != (num2 = num3)) || ((num1=num2) !=num3) || ((num1 = num3) != num2); boolean isCMatch = Math.abs(num2 - num3) < 10 && Math.abs(num2 - num1) < 10; boolean isCM2 = Math.abs(num3 - num1) < 10 && Math.abs(num3-num2) <10; boolean isCM3 = Math.abs(num1 - num2) < 10 && Math.abs(num1-num3) <10; boolean isOkMatch = Math.abs(num2 - num3) >=10 && Math.abs(num2 - num3)<=30; boolean isOM2 = Math.abs(num3 - num1) >=10 && Math.abs(num3 - num1)<=30; boolean isOM3 = Math.abs(num1 - num2) >=10 && Math.abs(num1 - num2)<=30; boolean isMismatch = Math.abs(num2 - num3) >=31; boolean isMM2 = Math.abs(num3 - num1) >=31; boolean isMM3 = Math.abs(num1 - num2) >=31; //small to largest if (num1<num2 && num1<num3 && num2<num3){ S = num1; M =num2; L =num3;} else if (num2<num1 &&num2<num3&&num1<num3){ S = num2; M = num1; L = num3;} else if (num3<num1 &&num3<num2 && num1<num2){ S =num3; M =num1; L =num2;} else{ S = num2; M = num3; L = num1; System.out.println("Sorted BPMs a "+S +","+M +","+ L); } if (isAllSame) System.out.println("Three songs have same BPMs."); else if (isDI && isCMatch){ N(); CM(); } else if (isDI && isCM3){ N(); CM(); } else if (isDI && isCM2){ N(); CM(); } else if (isTS && isCMatch){ SBMP(); CM(); } else if (isTS && isCM2){ SBMP(); CM(); } else if (isTS && isCM3){ SBMP(); CM(); } //When two song BPM larger than 10. order from all different to two same. else if (isDI && isOkMatch){ N(); OK(); } else if (isDI && isOM3){ N(); OK(); } else if (isDI && isOM2){ N(); OK(); } else if (isTS && isOM2){ SBMP(); OK();} else if (isTS && isOM3){ SBMP(); OK();} else if (isTS && isOkMatch){ SBMP(); OK();} //When some BPMs are larger than 30, Order from all different to some are same. else if (isDI && isMismatch){ N(); PM(); } else if (isDI && isMM3){ N(); PM(); } else if (isDI && isMM2){ N(); PM(); } else if ( isTS && isMM2){ SBMP(); PM();} else if ( isTS && isMismatch){ SBMP(); PM();} else if ( isTS && isMM3){ SBMP(); PM();} } public static void SBMP(){ System.out.println("\nSome are the same BMP"); } public static void N(){ System.out.println("\nNone share the same BMP"); } public static void CM(){ System.out.println("All are within 10 BPMs of eath other");} public static void OK(){ System.out.println("All are within 10 to 30 BPMs of each other.");} public static void PM(){ System.out.println("At least two songs are Possible Match");} } ------------------------------------Output Please input three songs' BPMs 15 19 50 Sorted BPMs a 50,50,15 None share the same BMP At least two songs are Possible Match Well after much trial and error I come asking for help. I am trying to write a greasemonkey script that scans a page for all the values between certain <td> tags. When I used firebug it shows what I am looking for as <td class="username">THEUSERNAME</td> but when I view the source it just shows up as <td>THEUSERNAME</td> I want to create an array of the 100 <td>'s on the page that pertain to usernames but none of the other <td>'s I created a test page that mimicked the code, what I thought origionally, to be so I could test my script with ease. And it worked when there was an actually <td class="username"> This is what I have so far: Code: // ==UserScript== // //Displayable Name of your script // @name EXAMPLE // // brief description // @description EXAMPLE // //URI (preferably your own site, so browser can avert naming collisions // @namespace http://something.com // // Your name, userscript userid link (optional) // @author ME // //Version Number // @version 1.0 // // Urls process this user script on // @include http://example.com // ==/UserScript== var test = document.getElementsByClassName('username'); alert(test.length); test[5].style.color="yellow"; //Just to see if it actually worked How would I go about creating a random number between 1-50 that COULD include whole numbers, decimals to the tenth, hundredth and the thousandth place? Ex) 2.145, 3, 5.8, 41.002, 10.12, 7, 18.023, 33.2 Also, if the only way to do it is to put trailing zeros to the thousandth place that's fine as well ex) 2.145, 3.00, 5.800, 41.002, 10.120, 7.00, 18.023, 33.200 Hi all, I currently have this javascript that will change the cell to green with one click... Code: <script type="text/javascript"> function ColorChange(obj){ obj.style.color='#FFFFFF'; obj.style.backgroundColor='#66CC33'; obj.parentNode.style.backgroundColor='#66CC33'; } </script> echo "<td align=\"center\" bgcolor=\"#EEEEEE\"><a href=\"#\" onclick=\"ColorChange(this)\">$day_num</a></td>"; the problem is that I need around 3 different colors to be possible.. e.g. 1 click turns cell green | 2 turns is red | 3 turns it orange. I'm not sure how to take this javascript further? Would someone be kind enough to point me in the right direction? Many thanks, Greens85 Here's part of the code, problem I have is I have it set up for 5 rows, I need it to be able to make more than this, but not sure how many more, this is dependent on user input, how should I go about this? Also how would I go about making the users orders correspond with the right item number? I'd need to sort the array somehow? document.write('<table border="1">'); document.write("<tr>"); document.write('<th colspan="5">ORDER</th>') document.write("</tr>"); document.write("<tr>"); document.write('<th align="left">Item #</th>'); document.write('<th align="center">Name</th>'); document.write('<th align="center">Price</th>'); document.write('<th align="center">Quantity</th>'); document.write('<th align="center">Total</th>'); document.write("</tr>"); document.write('<td align="center">0</td>'); document.write('<td>' + productName[0] + '</td>'); document.write('<td> $' + sausagePrice + '</td>'); document.write('<td> ' + orderItemQty[0] + '</td>'); document.write('<td> ' + sausageTotal + '</td Another thing that has been driving me crazy is that css positioning is handled differently by different browsers. JS is not my area, but I can do a lot with CSS, and I do, but cross browser compatibility is killing me. I can use an IF IE statement and only IE runs that segment of code, but I haven't been able to figure out out how to make ONLY firefox or ONLY opera or safari enact an encapsulated segment of code. The same type of IF statement doesn't work for them. Is there a single method using JS that works for all browsers? Thre is probably a very simple answer and I am just missing it somehow. I have a function below where every time a question is submitted, it will add a new row in the table with a textbox which allows numbers entry only. My question is that I don't know how to code these features in this function: 1: I want the text box to be between 0 and 100, so if text box contains a number which is above 100, it will automatically change the number to the maximum number which is 100. Does any one know how to code this in my function below in javascript: Code: function insertQuestion(form) { var row = document.createElement("tr"); var cell, input; cell = document.createElement("td"); cell.className = "weight"; input = document.createElement("input"); input.name = "weight_" + qnum; input.onkeypress = "return isNumberKey(event)"; cell.appendChild(input); row.appendChild(cell); } I am trying to figure out how to make a random number I can plug into a script count down from that number at certain times of the day until it reaches 0. I would like it to reset itself at midnight every day. I'm trying to make it work with a script I found on here that resets itself at midnight every day. So instead of it counting down too fast, it would count down to the next number after a randomly generated number of minutes until it reaches 0. But it wouldn't necessarily have to end at 0 at midnight. It could go from 845 to 323 at the end of the day at a slower pace. Is that possible?
When I used toFixed() method on a number, I thought that this method round a number to a specified approximation, but I got a surprising result, the number became string! 15.23689 .toFixed ( 2 ) ==> "15.24" So does it convert the number into string? I'm a little rusty since i've been studying vb .net I forgot how to make this external. I know I'm messing up somewhere. Code: <script type="text/javascript"> function titbar(val) { var speed = 300; var pos = val; var tit1 = "V"; var tit2 = "VO"; var tit3 = "VOT"; var tit4 = "VOTI"; var tit5 = "VOTIL"; var tit6 = "VOTILL"; var tit7 = "VOTILLI"; var tit8 = "VOTILLIT"; var tit9 = "VOTILLITY"; var tit10 = "VOTILLITY.com"; if(pos==0) { titdis=tit1; pos=1; } else if(pos==1) { titdis=tit2; pos=2; } else if(pos==2) { titdis=tit3; pos=3; } else if(pos==3) { titdis=tit4; pos=4; } else if(pos==4) { titdis=tit5; pos=5; } else if(pos==5) { titdis=tit6; pos=6; } else if(pos==6) { titdis=tit7; pos=7; } else if(pos==7) { titdis=tit8; pos=8; } else if(pos==8) { titdis=tit9; pos=9; } else if(pos==9) { titdis=tit10; pos=0; } document.title = titdis; timer = window.setTimeout("titbar("+pos+")",speed); } titbar(0); </script> it works just fine when I have it internal p.s tit is short for title. no explicitive necessary. been searching everywhere for help on this javascript kit but no luck JSE internal seach engine v 1.0a http://www.javascriptkit.com/script/...se/index.shtml Description: JSE is a highly robust, 100% client side search engine for indexing and searching your own site, using JavaScript 1.3. Some of JSE's noteworthy features a * Uses regular expressions to efficiently and rapidly search the index for matches based on the entered keywords. Supports basic logic (ie: negation). * Returns the results on a seperate page from the search form itself, neatly formatted. Uses session cookies to transmit the query between the two pages. * Stores the index (url, keywords and description for each page you wish to be "crawled") in the "results" page. This means the index is loaded only when a search has actually been performed, saving on bandwidth and download time. * Searches title, description and desingated keywords within the index for a match. * Works in IE4+, NS4, and NS6+. its perfectly working on local server but when I uploaded my files to my webserver. it doesn't work. Is there anybody can help me with this? TIA Hello everyone, a few days ago I saw the new Bing mall's maps. Link here and here. I'm a newbie and I was very impressed, so I was wondering just how did they do these internal maps. It 's a simple mashup or similar? Or use some special JS library? There are JS libraries (or other languages too) that gives the ability to create internal maps of buildings outside of google maps / bing maps? Like drawing a real internal map of house or other buildings (vector or not) by JS functions, variables and data .... Thanks for your help! PS: sorry for my english I am new to Javascript and I downloaded JSE internal search engine v 1.0a from CodingForums. It works fine in all browsers other than ie6 and ie7. Have confirmed that other javascripts are working in these browsers so it is not my browser settings. Can anyone help?
I'm trying to add an internal site search to my website, and it only work for some search items, not for everything. For example, if I search for Bud Light, Budweiser, Bud Light Lime, it finds them. But if I search for Stella Artois, Paulaner, or Hoegaarden, it doesn't find anything. I'm thinking there's something wrong with the javascript code, I'm just not sure how to fix it. I really appreciate any help with this!!! Here's the code in the head region: [<script type="text/javascript"> // Google Internal Site Search script- By JavaScriptKit.com (http://www.javascriptkit.com) // For this and over 400+ free scripts, visit JavaScript Kit- http://www.javascriptkit.com/ // This notice must stay intact for use //Enter domain of site to search. var domainroot="www.mhdbud.com" function Gsitesearch(curobj){ curobj.q.value="www.mhdbud.com:"+domainroot+" "+curobj.qfront.value } </script>] Here's what I've got in the body: [<form action="http://www.google.com/search" method="get" onSubmit="Gsitesearch(this)"> <input name="q" type="hidden" /> <input name="qfront" type="text" style="width: 180px" /> <input type="submit" value="Search" /> </form> You can try the site search to see what I'm talking about on this webpage: http://www.mhdbud.com/productsalt.html] Hi! Help please: How to get the object window (in the current browser window or tab - called unsafeWindow in GM user.js files) inside these internal greasemonkey js-files extensions \ (e4a8a97b-f2ed-450b-b12d-ee082ba24781) \ content \ browser.js extensions \ (e4a8a97b-f2ed-450b-b12d-ee082ba24781) \ content \ install.js extensions \ (e4a8a97b-f2ed-450b-b12d-ee082ba24781) \ components \ greasemonkey.js Entangled with objects wrappedContentWin, chromeWin and other ... Thanks P.S.I want to slightly alter the logic of work; be grateful for links to the appropriate developers forums I used the Google Internal Site Search script for my site but its search only the index.htm, how can I make it search the entir web site.
so i have code to make a popup via javascript and it works fine, but what actually pops up is an external file that i select (in my case test.html). i want all of the code of test.html to be in my index.html and when i call the popup it doesn't call an external file but instead calls the html code in the internal file (index.html)? possible? Code: <head> <script language="javascript" type="text/javascript"> function popitup(url) { newwindow=window.open(url,'name','status = 0,resizable = 0,height=500,width=600'); if (window.focus) {newwindow.focus()} return false; } </script> </head> <body> <a href="test.html" onclick="return popitup('test.html')">About</a> </body> what's in test.html? it's a form why? i need the code of test.html to access some global javascript variables in index.html |