Home / Expert Answers / Computer Science / using-the-lt-script-gt-tag-given-inside-the-html-file-write-your-javascript-code-and-satisfy-t-pa916

(Solved): Using the <script> tag given inside the html file, write your JavaScript code and satisfy t ...



    1. Using the <script> tag given inside the html file, write your JavaScript code and satisfy the needed data:
    1. When the user presses submit button, display an alert popup saying:

 “Hi, Mr. the Name from theCountry”.

  • “Mr.” if the gender selected is male, otherwise Mrs.
  • (“theName” is the name the user enters in the field)
  • (“theCountry” is the name the country the user selects from the drop-down list).
  1. When the user presses submit, display an alert popup saying “Hi, Mr./Dr. theName from theCountry”. (If the checkbox is selected, then use Dr. or else use Mr./Mrs)

 

 

<!DOCTYPE html>

<html>

<head>

<title></title>

<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">

</head>

<body>

<div id="wrapper">

<div id="header">

</div>

<div id="formbody">

<form name="personal">

Name: <input type="text" size="20" name="name"/> <br/>

Gender: <input type="radio" name="gender" value="Mr."/>Male

<input type="radio" name="gender" value="Mrs."/>Female<br/>

Country: <select name="country">

<option value="India">India</option>

<option value="Saudi Arabia">Saudi Arabia</option>

</select> <br/>

<input type="checkbox" name="phd" value="Dr."/>Are you a PhD holder?"<br/>

<input type="button" value="Submit" id ="submit"/>

</form>

 

</div>

</div>

 

<script>

//Write your JavaScript code here

 

</script>

</body>

</html>

 



We have an Answer from Expert

View Expert Answer

Expert Answer


JavaScript Code function displayAlert(event) { const name = form.elements['name'].value; const gender = form.elements[
We have an Answer from Expert

Buy This Answer $5

Place Order

We Provide Services Across The Globe