Question

writte application ask 5 word ( input) and show all of them and then show them...

writte application ask 5 word ( input)
and show all of them and then show them in order from least to greatest in word lenght.

write this word for example:
watermelon , app, oranges , grap ، cucumber

show this on input ( for example)
app , grap , oranges , cucumber , watermelon

please send it with html code and java-script thanks ?
0 0
Add a comment Improve this question Transcribed image text
Answer #1

Solution for the given question are as follows -

Code :

<!DOCTYPE html>
<html>
<body>
<p>Add & Display Names</p>
<button onclick="getNames()">Add Names</button>
<button onclick="showNames()">Display Names</button>
<p id="demo"></p>
<script>
var res = []
function getNames() {
var names = prompt("Please enter 5 names");
if (names != null) {
res = names.split(" ")
if (res.length != 5) {
res = []
names = ""
alert("Please enter 5 names")
}
}
}
function showNames() {
   res.sort(function(a, b){
       return a.length - b.length;
   });
document.getElementById("demo").innerHTML = res
}
</script>
</body>
</html>

Code Screen Shot :

Output :

1)

2)

3)

Add a comment
Know the answer?
Add Answer to:
writte application ask 5 word ( input) and show all of them and then show them...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • java Write an application that will show 5 different messages (no input, 5 types: error message,...

    java Write an application that will show 5 different messages (no input, 5 types: error message, question message, information message, warning message and plain message). Use the welcome.java example from lecture slides. You should end up with just one file. Icon Code IDE Value JOptionPane.PLAIN MESSAGE JOptionPane.ERROR MESSAGE No icon -1 X 0 JOptionPane.INFORMATION MESSAGE 1 JOptionPane.WARNING MESSAGE 2 JOptionPane QUESTION MESSAGE 3 Write an application that will show 5 different messages (no input, 5 types: error message, question message,...

  • PLEASE HELP IN JAVA: This is an exercise in using the java LinkedList class. Using input...

    PLEASE HELP IN JAVA: This is an exercise in using the java LinkedList class. Using input file words.txt , create a LinkedList BUT you must NOT add a word that is already in the list and you MUST add them in the order received to the end of the list. For example, if your input was cat, cat, dog, mouse, dog, horse your list would now contain cat, dog, mouse, horse. And the head of the list would be cat,...

  • Please complete the following: Write a Python script to do the following: 1. Ask the use...

    Please complete the following: Write a Python script to do the following: 1. Ask the use to enter several sentences, one at a time in a loop). To end the sentence entry, the user enters a blank (empty) sentence. 2. Extract each word from each sentence and put it in a list. This will require at least one loop to go through each sentence in the list. It is up to you how you want to get the words in...

  • 2.Given the following layout declarations, which of the following is/are true? Select all that applies: application_controller.rb:...

    2.Given the following layout declarations, which of the following is/are true? Select all that applies: application_controller.rb: class ApplicationController < ActionController::Base layout "main" end articles_controller.rb: class ArticlesController < ApplicationController end special_articles_controller.rb: class SpecialArticlesController < ArticlesController layout "special" end old_articles_controller.rb: class OldArticlesController < SpecialArticlesController layout false def show @article = Article.find(params[:id]) end def index @old_articles = Article.older render layout: "old" end # ... end In general, views will be rendered in the main layout SpecialArticlesController#index will use the special layout OldArticlesController#show will...

  • You will write Java programs in Eclipse to solve these word problems Read these instructions on...

    You will write Java programs in Eclipse to solve these word problems Read these instructions on how to name and submit the Java files. Please make sure your program compiles before you submit it. Make sure you name your Java file and class the same (otherwise it will not compile). For example, the class names are case-sensitive 1. will be in a file called CompareNames.java; remember, the Do not create a package. You can tell if your file is in...

  • create a new Java application called "CheckString" (without the quotation marks) according to the following guidelines....

    create a new Java application called "CheckString" (without the quotation marks) according to the following guidelines. ** Each method below, including main, should handle (catch) any Exceptions that are thrown. ** ** If an Exception is thrown and caught, print the Exception's message to the command line. ** Write a complete Java method called checkWord that takes a String parameter called word, returns nothing, and is declared to throw an Exception of type Exception. In the method, check if the...

  • I am required to use the try - catch block to validate the input as the...

    I am required to use the try - catch block to validate the input as the test data uses a word "Thirty" and not numbers. The program needs to validate that input, throw an exception and then display the error message. If I don't use the try - catch method I end up with program crashing. My issue is that I can't get the try - catch portion to work. Can you please help? I have attached what I have...

  • (Polling) The Internet and the web are enabling more people to network, join a cause, voice...

    (Polling) The Internet and the web are enabling more people to network, join a cause, voice opinions, and so on. Recent presidential candidates have used the Internet intensively to get out their messages and raise money for their campaigns. In this exercise, you’ll write a simple polling program that allows users to rate five social-consciousness issues from 1 (least important) to 10 (most important). Pick five causes that are important to you (e.g., political issues, global environ- mental issues). Use...

  • Java programming for ticket price calculator.  It should ask the user if they would like to process...

    Java programming for ticket price calculator.  It should ask the user if they would like to process another ticket order. They should indicate their selection with a Y or N. If they indicate yes, then it should repeat the entire program with the exception of the welcome screen. If they indicate no, it should show the final thank you message and end the program. If they indicate an invalid answer, it should display an error and re-prompt them for a Y...

  • Recursion and Trees Application – Building a Word Index Make sure you have read and understood...

    Recursion and Trees Application – Building a Word Index Make sure you have read and understood ·         lesson modules week 10 and 11 ·         chapters 9 and 10 of our text ·         module - Lab Homework Requirements before submitting this assignment. Hand in only one program, please. Background: In many applications, the composition of a collection of data items changes over time. Not only are new data items added and existing ones removed, but data items may be duplicated. A list data structure...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT