Question

I need a different code other than what is already posted online. (HTML5)  Write a script that...

I need a different code other than what is already posted online.

(HTML5)  Write a script that reads a series of strings and outputs in an HTML5 textarea only those strings beginning with the character ‘b’. Only the strings beginning with the letter 'b' should be printed out. Thank you.

ALREADY ANSWERED!! ACCIDENTLY REPOSTED

0 0
Add a comment Improve this question Transcribed image text
Answer #1

html code:

<html>
<head>
   <title>Strings start with B</title>
</head>
<body>
<h1 align="center">Strings start with leter B</h1>
<center>Enter no of strings : <input type="number" name="no_of_strings" id="no_of_strings" onchange="func()"></center>
<br /><br />
<div id="string_values" align="center">           <!-- div to print the input boxes based on no of employees using func() function -->
</div>
<br /><br />
<div id="results" align="center"> <!--- div to print the table results using range() function --->
   <h3>TextArea - B strings will be displayed</h3>
   <textarea id="b_strings" cols="80" rows="10" style="border-radius: 20px;padding:20px"></textarea>
</div>
<script>
function func(){           // funtion to take no of employees and to print that many input boxes
   var no_of_employees = document.getElementById("no_of_strings").value;
   var i, id, content;
   text = "";
   for(i=0;i<no_of_employees;i++){
       id = "string"+(i+1);
       content = "Enter "+id + ": <input type='text' id='"+id+"' /><br /><br />";
       text = text+content;
   }
   text +="<input type='submit' onclick='bstrings()' value='Submit' />";
   document.getElementById("string_values").innerHTML = text;
}
function bstrings(){           // function to calculate no of persons in certain range and printing the table.
   var arr = new Array();
   var no_of_strings = document.getElementById("no_of_strings").value;
   for(i=0;i<no_of_strings;i++){
       id = "string" + (i + 1);
       sales = document.getElementById(id).value || "";
       arr.push(sales);
   }
   text = ""
   for(i=0;i<no_of_strings;i++){
       if(arr[i].startsWith("b")){
           text = text + arr[i] + " "
       }
   }
   document.getElementById("b_strings").value = text;
}
</script>
</body>
</html>

output screenshot:

Add a comment
Know the answer?
Add Answer to:
I need a different code other than what is already posted online. (HTML5)  Write a script that...
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
  • *has to with R program, I need the code for R script* I already have questions...

    *has to with R program, I need the code for R script* I already have questions 1 through solved and posted a picture of them. I need help with questions 4-11 please!!! thank u 4 plots a histogram showing the distribution of your X. 5 generates a data series Y with a length equal to 'howmany' 6 plots the distribution Y 7 assigns the series X to a new variable Z. 8 calculates the variance of the series Z using...

  • I have already posted this before and I am looking at different answer. using C outputs...

    I have already posted this before and I am looking at different answer. using C outputs and comments will be appreciated. QUESTION: Write a function to check if a machine uses little endian or big endian notation.The basic structure of the program is givenbelow. You are expected to write the function checkEndianess(), complete the main function implementation to print the value returned by the function and print if the machine is “Little Endian” or “Big Endian”, compile and run the...

  • The first script is validate.sh. This is a simple form validation script that will be used...

    The first script is validate.sh. This is a simple form validation script that will be used to verify the inputs given. Normally, this would be done to validate input from a website or another program before entry into a database or other record storage. In this case, we will keep it simple and only focus on the input validation step. In particular, the script should prompt the user for four values: first name, last name, zip code, and email address....

  • I need help with this code This is what I need to do: Implement the Stack...

    I need help with this code This is what I need to do: Implement the Stack Class with an ArrayList instead of an array, including the following functions: • empty • push • peek • pop • overrided toString( ) function which returns all of the stack’s contents Things to note: • You no longer need a size. • You no longer need to define a constant DEFAULT_CAPACITY. Since ArrayLists grow dynamically. • Whenever possible, use ArrayList functions instead of...

  • Need different C code then what has been posted here Problem In this assignment, you have...

    Need different C code then what has been posted here Problem In this assignment, you have to simulate the Josephus problem. There are n number of prisoners standing in a circle waiting to be executed. The counting out begins at some point in the circle and proceeds around the circle in a fixed direction. In each step, a certain number of people are skipped and the next person is executed. The elimination proceeds around the circle (which is becoming smaller...

  • Already posted and got parts 1-4. Need the test of the questions please!! 5) Iran an...

    Already posted and got parts 1-4. Need the test of the questions please!! 5) Iran an ANOVA for this test. When I printed out the Word Doc in Google Docs, it eliminated a few of the values I highlighted in the ANOVA table. Use your knowledge of the ANOVA table and fill in the blanks. In this test, there are 5 groups and each group consist of 20 samples (100 total). df MS ANOVA Source of Variation Between Groups Within...

  • Hey guys I need help with this assignment. However it contains 7 sub-problems to solve but I figured only 4 of them can...

    Hey guys I need help with this assignment. However it contains 7 sub-problems to solve but I figured only 4 of them can be solved in one post so I posted the other on another question so please check them out as well :) Here is the questions in this assignment: Note: Two helper functions Some of the testing codes for the functions in this assignment makes use of the print_dict in_key_order (a dict) function which prints dictionary keyvalue pairs...

  • I need help with this code, I'm stuck on it, please remember step 4, I'm very...

    I need help with this code, I'm stuck on it, please remember step 4, I'm very much stuck on that part. It says something about putting how many times it appears Assignment #1: Sorting with Binary Search Tree Through this programming assignment, the students will learn to do the following: Know how to process command line arguments. 1 Perform basic file I/O. 2. Use structs, pointers, and strings. Use dynamic memory. 3. 4. This assignment asks you to sort the...

  • # In this file, fill in the ... parts with lines of code. Do not # create new functions. from ran...

    # In this file, fill in the ... parts with lines of code. Do not # create new functions. from random import seed, randrange P=[" ♟♜♝♞♛♚"]; L,R,BL,TL=["▌▐▄▀"] BonR=WonR=WonB=DonR=DonB=RonB=GonR=GonB=RonG='\033[1;m\033[' WonR+='7;31;47m' # For drawing a white piece on a red background WonB+='7;30;47m' # For drawing a white piece on a black background DonR+='2;37;41m' # For drawing a dark piece on a red background DonB+='2;37;40m' # For drawing a dark piece on a black background GonR+='2;33;41m' # For drawing gold on a red...

  • C++ Code

    "For two thousand years, codemakers have fought to preserve secrets while codebreakers have tried their best to reveal them." - taken from Code Book, The Evolution of Secrecy from Mary, Queen of Scots to Quantum Cryptography by Simon Singh.The idea for this machine problem came from this book.You will encrypt and decrypt some messages using a simplified version of a code in the book. The convention in cryptography is to write the plain text in lower case letters and the encrypted text in upper case...

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