ake the attached application and modify the second function so that if the user enters ANY name , for example Lawrence Michael Wolk into the input box next to the second function, the span output will be L.Michael.W. So if the name were instead Michael William Jackson, the output will be M.Wiiliam.J. (See output png attachments)

Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:James Kurose, Keith Ross
Chapter1: Computer Networks And The Internet
Section: Chapter Questions
Problem R1RQ: What is the difference between a host and an end system? List several different types of end...
icon
Related questions
Question

HTML/JAVASCRIPT

Take the attached application and modify the second function so that if the

user enters ANY name , for example Lawrence Michael Wolk into the input box next to the second function, the span output will be L.Michael.W.

So if the name were instead Michael William Jackson, the output will be M.Wiiliam.J.

(See output png attachments)

CISC_2350_CH_8_pp300_converter_asplithw.html

<html> <head> <script src="split.js" defer></script> </head> <body> <h1>Name Converter</h1> <p>Type your name:</p> <div> <input id="name" type="text" size="24" /> </br> <span id ="span1">second output goes here</span></br> <button id="but0">Convert to last, First</button> </br></br> <button id="buta"> Convert From Name MI. Lname to FI.MI.LI.</button></br> <input id ="name1" type ="text" size ="24"/> <span id= "span2">Third output goes here</span> </div> </body> </html>

split.js

onja = document.getElementById("but0");
onja.onclick=convertName;

onjb = document.getElementById("buta");
onjb.onclick=fnli;

function convertName() {
var input = document.getElementById("name");
var name = input.value;
var spaceIndex = name.indexOf(" ");
var firstName = name.substring(0, spaceIndex);
var lastName = name.substring(spaceIndex + 1);
/* lastName = lastName.toUpperCase();*/

var firstInitial = firstName.charAt(0);
input.value = lastName + ", " + firstInitial;

var s = " ";
objspan = document.getElementById("span1");
  

for ( var k= 0; k < firstName.length ; k++) {
if (k % 2 == 0) {
var position = firstName.length - k -1 ;

var smid = firstName.charAt(position);
s = s + smid;
}
}
var s1 = " ";
for ( var k= 0; k < lastName.length ; k++) {
if (k % 2 == 0) {
var position = lastName.length - k -1 ;
  
var s1mid = lastName.charAt(position);
s1 = s1 + s1mid;
}
  
}


objspan.innerHTML = s+ s1 ;


}

function fnli() {

var input = document.getElementById("name1");
var name = input.value;
var spaceIndex = name.indexOf(" ");
var firstName = name.substring(0, spaceIndex);
var lastName = name.substring(spaceIndex + 4);
var p1 = name.substring(spaceIndex+1,spaceIndex+2);

st = firstName.substring(0,1);
stm = p1;
st1 = lastName.substring(0,1);

stf = st + " ." + stm +"." +st1+"." ;
spanp = document.getElementById("span2");
spanp.innerHTML = stf;

}

 

Name Converter
Type your name:
Larry Wolk
first output goes here
Convert to last, First
Convert ANY Name to First Initial, Middle Name, last Initial
second output goes here
Name Converter
Type your name:
Wolk, L
yrL ko
Convert to last, First
Convert ANY Name to First Initial, Middle Name, last Initial
second output goes here
Name Converter
Type your name:
Wolk, L
yrL ko
Convert to last, First
Convert ANY Name to First Initial, Middle Name, last Initial
Lawrence Michael Wolk
second output goes here
Name Converter
Type your name:
Wolk, L
yrL ko
Convert to last, First
Convert ANY Name to First Initial, Middle Name, last Initial
Lawrence Michael Wolk
L.Michael.W.
Transcribed Image Text:Name Converter Type your name: Larry Wolk first output goes here Convert to last, First Convert ANY Name to First Initial, Middle Name, last Initial second output goes here Name Converter Type your name: Wolk, L yrL ko Convert to last, First Convert ANY Name to First Initial, Middle Name, last Initial second output goes here Name Converter Type your name: Wolk, L yrL ko Convert to last, First Convert ANY Name to First Initial, Middle Name, last Initial Lawrence Michael Wolk second output goes here Name Converter Type your name: Wolk, L yrL ko Convert to last, First Convert ANY Name to First Initial, Middle Name, last Initial Lawrence Michael Wolk L.Michael.W.
Expert Solution
steps

Step by step

Solved in 2 steps

Blurred answer
Recommended textbooks for you
Computer Networking: A Top-Down Approach (7th Edi…
Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON
Computer Organization and Design MIPS Edition, Fi…
Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science
Network+ Guide to Networks (MindTap Course List)
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning
Concepts of Database Management
Concepts of Database Management
Computer Engineering
ISBN:
9781337093422
Author:
Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:
Cengage Learning
Prelude to Programming
Prelude to Programming
Computer Engineering
ISBN:
9780133750423
Author:
VENIT, Stewart
Publisher:
Pearson Education
Sc Business Data Communications and Networking, T…
Sc Business Data Communications and Networking, T…
Computer Engineering
ISBN:
9781119368830
Author:
FITZGERALD
Publisher:
WILEY