Find Factors Of Number And Pick Two Closest To Middle?
Mar 10, 2011
Basically I want to factor a number and select the two closest numbers to the middle of the factors for example: 20 factors to 1, 2, 4, 5, 10, 20 I want it to return 4 and 5 If the number is has an odd number of factors (has to be a perfect square) I want it to select the middle number and say it twice for example:
64 factors to 1, 2, 4, 8, 16, 32, 64
I want it to return 8 and 8 Would I use an array or what? My code should probably look like:
[Code]....
View 21 Replies
ADVERTISEMENT
Jun 12, 2010
I am trying to pick the larger of 5 numbers and sometimes there is a tie. I would like to prioritize variable c1 if there is a tie. This data is from a quiz I am writing.
var c1 = 2; // Takes priority if there is a tie.
var c2 = 1;
var c3 = 2;
var c4 = 0;
var c5 = 0;
View 3 Replies
View Related
Jul 14, 2010
I have a textarea with a specific width. I have wrap="off" set because I don't want to force my users to wrap if they don't want to. The reason for this is because this textarea is where the user is typing an email message. However I have a background image set on the textarea with a verticle line going down the textarea which indicates to the user the "Recommend Width"What I want to do is provide them with a link to click on which says something like "Wrap Lines" and when they click on it, the text within the textarea would wrap to the "Recommended Width" line in the background image. The maximum length of a line should be 53 characters when they click on "Wrap Lines" link.So I did some searching around and the code I came up with is:
Code:
function showLines(max, text) {
max--;
text = "" + text;
var temp = "";
var chcount = 0;
[Code].....
View 5 Replies
View Related
Aug 22, 2010
finding a "find on page" script that will display the results in the middle of the page for IE. I have tried several different ones to no avail. The ones that work in all the browsers display the result in IE at the very bottom of the page. I am not very familiar with programing in Java and I am unable to modify any for my needs. The one I found that did work in IE didn't work in any other browsers.
View 4 Replies
View Related
Mar 12, 2011
I need some help putting the factors of a number (y) into an array.For example if y = 20: [1, 2, 4, 5, 10, 20]Once I have this, I can use it to factor a quadratic:(ax = c)(bx = d)if c = 3 and d = 5 then I could check if 1c was a decimal, if 20d was a decimal and then vice versa.Basically, I can use these numbers to see if b or d is a whole number and if it isn't, try the next one.If none of them are, then I can do y(ax + c)(bx + d)
View 4 Replies
View Related
Sep 23, 2010
I am working on my assignment: The assignment is: The process of finding the largest value (i.e., the maximum of a group of values) is used frequently computer applications. Write a Javascript program that input a series of 10 single digit numbers as characters, determines the largest of the number and output XHTML text that displays the largest number. Your program should use 3 variables as follows:
a.) COUNTER: A counter to count to 10 (i.e. to keep track of how many number have been input and to determine when all 10 number have been processed). b.) NUMBER: The current digit input to the program.
c.) LARGEST: The largest number found so far.
Below is my code so far:
[Code]...
View 1 Replies
View Related
Feb 12, 2011
When I find a record such as this in a textarea:
[Code]....
There will be from 1 to 4 Pts, if one is missing there will not be a next one. My problem is I replace the first occurrence of any number I find and for certain factors (2 in this case) it could change an already converted number and leave other fields in the record alone. I could split the line on commas to change the first number I find but can't be certain if there are no other commas elsewhere on the line.
View 2 Replies
View Related
Nov 8, 2009
FRom this page: [URL]I need to find the VIN number and store it in a variable, however there's no ID located in it, so getelementbyid doesn't work.
View 4 Replies
View Related
Feb 1, 2010
I need to find the average number in javascript. It is the only bit of javascript that I have to do in the course but it carries a high mark of which I cannot afford to lose. Any way the question is : "Write code to calculate the average height and write it out in the browser window"
<HEAD><TITLE> average</TITLE>
<SCRIPT LANGUAGE = "JavaScript">
//Experimental results of Table 1 stored in arrays.
var Height = [15,16,17,18,19];
var Number = [2,1,6,4,2];
//Part (ii).
//Write code to declare and initialise new array to represent the third row of the table.
var avg = new Array(5)
var avg = ["60","80","187","180","114"] ;
avg[0] = "60";
avg[1] = "80";
avg[2] = "187";
avg[3] = "180";
avg[4] = "114";
//Part (iv).
//Write code to calculate the average height and write it out in the browser window.
avg = 0;
for (var count = 1; count <= 5; count = count + 1)
Array.average = function(){
var avg = 0;
for(var a = 0; a < this.length; a++){
avg += this[a];
} return avg / this.length;
};
document.write('average height is ' +avg + '<br>');
</SCRIPT></HEAD><BODY>
</BODY></HTML>
View 10 Replies
View Related
Aug 7, 2009
How to find out the number of checked boxes length without looping thru the whole set of check boxes....
View 9 Replies
View Related
Nov 11, 2011
If i have 4 vars
var one = 29.1
var two = 5.4
var three = 12.4
var four = 15
how can compare all 4 and find the smallest? in this case the result would be two
View 9 Replies
View Related
Mar 25, 2010
Is there an efficient way (ie. not looping through all members and counting) to find out what number an li will get in an ordered list? For example: [code]...
Naturally #first and #second will be 1 and 2, respectively. Without looping though all children of ol and counting, can I determine the number for #first and #second?
View 2 Replies
View Related
Oct 22, 2009
I'm just a starter and I'm looking for a function I can't find.
What I want:
I want the row number of the row i clicked of the item list.
For instance I click on third row then I want that var i returns 2. code...
View 2 Replies
View Related
Apr 29, 2003
After retrieving a record from the database and displaying one of its text field in an input-type textbox, I click on a word and it'll store or show the current position of cursor in a variable. I have no success with IE's caretPos.
View 4 Replies
View Related
Dec 6, 2010
I am having some difficulty in constructing a window.confirm() function that works with my code.So if the form data is valid, I need to use a window.confirm() dialog box to show the user's total cost based on the rental rate of equipment chosen and the reservation period. The user must accept the cost by pressing the confirm button, and if user cancels do not submit data.I have written this code but cannot figure out how to find the number of days from the 2 date fields and use that to calculate and display the total cost.
//confirm submit and display rental cost
var equip = document.forms[0].equipment.value
var pDate = document.forms[0].pickupDate.value[code].....
View 5 Replies
View Related
Jan 18, 2011
Been trying for about an hour to traverse the DOM to get the value of an input when the quantity is changed, total it and put it back. I have not been very successful unfortunately. erstanding of .closest() is that it will traverse up and find the first of whatever you're looking for. Below is the <ul> structure.
<ul>
<li>Type: Beverage</li>
<li>Price: $<input name="product_price" type="text" id="<?php echo $row['productID']; ?>" value="<?php echo $row['productPrice']; ?>" class="product_price" size="11" /></li>
[Code].....
Seems like it should be simple. I've worked on more complicated jquery stuff. Course my .parent(), .child() skills leave much to be desired..
View 2 Replies
View Related
Oct 5, 2010
I'm looking for an alternative for .closest(). My script refers to jQuery 1.3.2 which is not the latest, but does its job. By trying to implement my code into another script I noticed that this script uses jQuery 1.2.6. Well, 'changing that version was no option'.[code]This is my code. It should be used to clone special comments containing "In[" and in some cases "text".Unfortunately .closest() doesn't work out for me. i'm looking for an alternative.
View 1 Replies
View Related
May 16, 2011
I have the following code. Either of the statementsworks fine in IE8 but not in IE7.
var $parentTabId = $(this).closest("div.column").attr("tabindex");
var $parentTabId = $(this).parents("div.column").attr("tabindex");
I get "undefined" for $parentTabId in IE7. What is the alternative solution which works for both IE7 and IE8 ?
View 3 Replies
View Related
Aug 27, 2009
I want to animate ALL classes called ".article" to opacity=.2 and then fire a callback,which animates ONLY the closest ".article" to ".button" back to opacity=1.Know, what i mean?Here's the script:
$('.button').click(function() {
$('.article').animate({
opacity: '.2'
[code]....
View 1 Replies
View Related
Jul 19, 2010
I am trying to figure out the syntax for the following. For this version I am simply trying to select the 2nd child of the SLIDE HOLDER div. For this test I am just making the width grow. My next pass will be to get the index of the DOT clicked and then pass it to the child of the other parent. Please see line 24. I know this is incorrect but placed it to give you an idea of what I am trying to accomplish.
[Code]...
View 4 Replies
View Related
Sep 30, 2011
I have a table with 5000 rows. In each row I have an html element. myElementList is the list of those elements. Now I need to select all the tr's of these elements. I am using the following code.
[Code]...
This work great in FF. But when I run the same in IE 8. The browser hangs out and a popup messgae appears that propmt for to stop the script.
View 2 Replies
View Related
Jun 16, 2011
I have the following script using the closet method. It works fine for the inner most li tags however the outer li tags don't get seen? So both Root 1 and Root 2 don't get selected but the Sub Cat 1 and Sub Cat 2 get selected fine. I'm sure I'm missing some code to make this work.
[Code]...
View 3 Replies
View Related
Jun 16, 2010
My HTML looks something like the following:
<label for="myTextBox">
Name:<span style="color:red;">*</span>
<input type="text" id="myTextBox"></input>
</label>
In my document ready I have a function which runs 'on blur' of the textbox and hides the span. The following code DOESN'T work to hide the span:
$('#myTextBox').closest('span').hide();
I'm currently using the code below which does work but was wondering why the above code doesn't....
$('#myTextBox').parent().children(':first').hide();
View 3 Replies
View Related
May 29, 2006
I'm new and naive at JS, but use a lot of modified JS snippets in web
design. I'm working on a six-language site for a client right now that has
a small nav bar at the bottom of each template-based page.
I've had success in previous projects, writing out language-specific nav-bar
code nested in a document.write statement; a unique .js file for each
language.
An idea that I came up with that would allow me to create a function that
would cover all languages was this: if javascript could somehow detect the
"lang" attribute of the <html> tag, it could automatically choose which
"langage" js file to reference for my nav bar.
Example, if my german nav bar was in a file, "/scripts/de.js" the function
would pick up "de" from the "lang" attrib in the <html> tag, assign it to a
variable, say "navlang", and render a document.write statement that would
"write" out my script source reference as such:
<script>
document.write('<script src="/scripts/' + navlang +'.js"></script>');
</script>
my problem is I'm not adept enough at JS to write a function that would grab
the LANG attrib of the page .
View 5 Replies
View Related
Feb 19, 2010
Let's say I have a string, something like this: sadasd4assadasd8ssssda5asadasd3asdasdasd8dsdsd
and I want to pick out the numbers and add them to each other. How do I do that? I have tried and know how to pick out one number, but how do I pick out several numbers and add them?
View 12 Replies
View Related
Mar 10, 2009
With html you can have a file input that browses for a file to upload.
As far as I can tell you have to pick a file and can't pick a folder.
Is there a way to pick a folder with JS. I don't want to upload, I just need the path.
View 5 Replies
View Related