dear all...please help me...i want a program in java script...which has only a text box in which we enter a numbers or string seperated by comma ....should be sorted and values to be displayed...please any body write program for me...i am not getting it...pzz..anybody help...
20 1790
actually i dnt know getting how to get values frm single text box and put in array and sort and display...pls help...if u know
getting the textbox value is simple: - var value = <textbox>.value;
note that <textbox> stands for a reference to the textbox element. (so plain copy/past won’t work)
the functions you’ll likely use next are String.split() and Array.sort().
i want to get multiple numbers from single text box...and sort it manually...pls wilu do d pgm for mee...
- <html>
-
<head>
-
<title>
-
Sorting Numbers....!!!!!
-
</title>
-
<script type="text/javascript">
-
var myArray = [];
-
function bubblesort()
-
{
-
var inputValue = document.getElementById("valueField");
-
for (var i = 0; i < inputValue.value; ++i)
-
{
-
inputValue.innerHTML = "";
-
myArray[i] = document.getElementById("valueField").value;
-
}
-
var length=myArray.length;
-
var returnArray=new Array(length);
-
for (var i =0; i < (arrayToSort.length-1); i = i+1)
-
{
-
-
if ((arrayToSort[i+1]) < (arrayToSort[i]))
-
{
-
-
var temp = arrayToSort[i+1];
-
arrayToSort[i+1] = arrayToSort[i];
-
arrayToSort[i] = temp;
-
-
}
-
-
}
-
return returnArray;
-
-
-
-
</script>
-
</head>
-
<body>
-
<form>
-
Enter number of values:
-
<input id="valueField" type="number">
-
<input id="submitButton" value="Submit" type="button">
-
</form>
-
-
</body>
-
</html>
this is what so far i did...plzzz help....
any corrections and further completion
#1 input fields do not have an innerHTML property. they’re empty elements.
#2 why creating an explicit bubblesort implementation? doesn’t the native sort work for you?
#3 on line 11 you treat the input as a max value. on line 14 you put the same value that many times in an array, i.e. you get an array of size n with the number n as each element. due to that the sorting afterwards does not make any sense.
#4 if your input is not a single number (e.g. a comma-separated list of numbers) your code will bail out due to impossible number conversion (i.e. resulting in NaN (not a number))
pls..will u write the pgm for me??/plss...
np means??//anybody...pls helppp..........
it's short for nope (I mean, you’re abbreviating words as well, so why shouldn’t I?). we will not do the work for you, but we will help you with problems you encounter.
hmm...i dnt know dats y...is there any other place...where i can get the required program
pls tell me how to get input value numbers from one input texbox and get them into array
erm, I did that on post #4.
are u telling that more than one number in an input box is invalid??
no, I tell you that your program logic is busted.
pls tell any corrections...and how to complete the pgm
why do you insist on creating your own sort() implementation?
i hav to do it without built in functions....thatsy............
that would have been nice to know in the first place …
anyways, the first thing to do is analysing the current problems.
- #1 is the conversion from an input to an array
- #2 is the sorting of the array
what you need to do is solve each problem separately instead of trying all at once.
there are different approaches you could do.
- make a temporary page that only concerns with a single problem. i.e. you completely neglect problem #2 while working on #1 (and vice versa)
- mock all other problems while working on one. i.e. use use Array.sort() while working on problem #1 and use a predefined array as input while working on problem #2.
Sign in to post your reply or Sign up for a free account.
Similar topics
by: Tim |
last post by:
I've been working on this for over a week now, and just can't get this
figured out. Hoping one of you gurus can help me out here.
I have an xml data island that I'm representing on an htm page as...
|
by: Gareth Gale |
last post by:
I'm trying to implement a way of allowing a user to sort a HTML table
via Javascript on the client. I've seen lots of samples where single
column sorting (asc or desc) is shown, but I'd like nested...
|
by: Mosher |
last post by:
Hi all, is there a good way to have a popup window appear using Javascript
and the html "map" tag? Here is my code:
<map name="navigation">
<area shape="rect" coords="5,57,45,70"...
|
by: ian ward |
last post by:
Hello,
I want to show the result of some JavaScript on an HTML page. I've had
a look at some threads and it seems the conclusion is the following -
javascript entities are usable on the...
|
by: ksr |
last post by:
Hello,
I have a HTML page, which loads an activeX control in the browser.
In the <HEADsection, I have javascript similar to the following,
<SCRIPT language="JavaScript">
var Index = "";
//...
|
by: myselfrajotia |
last post by:
DEAR FRIENDS,
I need a software which can calculates the time taken by a sorting program written in C language. or if there is no s/w, then is there any other alternative.
plz do help me.
|
by: jessy |
last post by:
i need to know if its possible to write the value of a Javascript variable inside HTML tag ..and here's the line :
var x=document.getElementById('div1').value;
formdiv.innerHTML =...
|
by: LindaDhasan |
last post by:
Hi,
I am a beginner with javascript.Please help me clarify how to display the result of a javascript function within html underline tag.PFA the code.
<html>
<head>
<script...
|
by: taylorcarr |
last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: ryjfgjl |
last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
|
by: ryjfgjl |
last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
|
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
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
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...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
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...
| |