Question

Using Javascript, I have two radio buttons, depending on the value of the radio button 1...

Using Javascript, I have two radio buttons, depending on the value of the radio button 1 or 2, you will send a different form to the user. So, if radio button is value "1" send new form1 or if value "2" send new form 2.  New form will ask for letter grades for four courses in textboxes. Onsubmit of new form letter grades A,B,C,D need to be changed to numeric values 1,2,3,4 so an average grade for the four couses can be computed and returned to user.

Form courses code:

<!DOCTYPE html>

<html lang="en">
<head>
<meta charset="utf-8" />
<title></title>

<script>
function ValidateCourses() {
var x = document.forms["Courses"][""].value;
if (x == "") {
alert("Enter a course grade for each course.");
return functionCourses();
}
}
</script>

<script>
function functionCourses() {
var x;

var y:

if ( C1 == "A,a" ) {
score = "4";
} else if (C1 == "B,b") {
score = "3";
} else if (C1 == "C,c"){
score = "2";
} else if (C1 == "D,d") {
score = "1";
} else if (C1 == "F,f"){
score = "0";

if ( C2 == "A,a" ) {
score1 = "4";
} else if (C2 == "B,b") {
score1 = "3";
} else if (C2 == "C,c"){
score1 = "2";
} else if (C2 == "D,d") {
score1 = "1";
} else if (C2 == "F,f"){
score1 = "0";
var avg = score / score1;

Here I need to send back the score and link to a new webpage or show a msgbox. Thinking window.open event.
}
</script>

</head>
<body>
<p><b>Courses :</b></p>

<form name="Courses" action="/action_page.php" onsubmit=" ValidateCourses()" method="post">

C1:<br>
<input type="text" name="C1" value=" " maxlength="4" size="3">
<br> <br>
C2:<br>
<input type="text" name="C2" value=" " maxlength="4" size="3">
<br> <br>
C4:<br><input type="text" name="C4" value=" " maxlength="4" size="3">
<br> <br>
C3:<br>
<input type="text" name="C3" value=" " maxlength="4" size="3">
<br> <br>
<input type="submit" value="Submit">
</form>
</body>
</html>

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

<!DOCTYPE html>

<html lang="en">
<head>
<meta charset="utf-8" />
<title></title>


<script>
function ValidateCourses() {
var x = document.forms["Courses"][""].value;
if (x == "") {
alert("Enter a course grade for each course.");
return functionCourses();
}
}
</script>

<script>
function functionCourses() {
var x;
var y:
score="0"; /*These are the value initialization for input score converted value
score1="0";
scor2="0";
score3="0";

if ( C1 == "A,a" ) {
score = "4";
} else if (C1 == "B,b") {
score = "3";
} else if (C1 == "C,c"){
score = "2";
} else if (C1 == "D,d") {
score = "1";
} else if (C1 == "F,f"){
score = "0";

if ( C2 == "A,a" ) {
score1 = "4";
} else if (C2 == "B,b") {
score1 = "3";
} else if (C2 == "C,c"){
score1 = "2";
} else if (C2 == "D,d") {
score1 = "1";
} else if (C2 == "F,f"){
score1 = "0";


if ( C3 == "A,a" ) {
score2 = "4";
} else if (C3 == "B,b") {
score2 = "3";
} else if (C3 == "C,c"){
score2 = "2";
} else if (C3 == "D,d") {
score2 = "1";
} else if (C3 == "F,f"){
score2 = "0";


if ( C2 == "A,a" ) {
score3 = "4";
} else if (C4 == "B,b") {
score3 = "3";
} else if (C4 == "C,c"){
score3 = "2";
} else if (C4 == "D,d") {
score3 = "1";
} else if (C4 == "F,f"){
score3 = "0";

var avg = score+score1+score2+score3 / 4; //taking average of the total score

Here I need to send back the score and link to a new webpage or show a msgbox. Thinking window.open event.

// output message box, that'll work on submit

<!DOCTYPE html>

<html lang="en">
<head>
<meta charset="utf-8" />
<title></title>


<script>
function ValidateCourses() {
var x = document.forms["Courses"][""].value;
if (x == "") {
alert("Enter a course grade for each course.");
return functionCourses();
}
}
</script>

<script>
function functionCourses() {
var x;
var y:
score="0"; /*These are the value initialization for input score converted value
score1="0";
scor2="0";
score3="0";

if ( C1 == "A,a" ) {
score = "4";
} else if (C1 == "B,b") {
score = "3";
} else if (C1 == "C,c"){
score = "2";
} else if (C1 == "D,d") {
score = "1";
} else if (C1 == "F,f"){
score = "0";

if ( C2 == "A,a" ) {
score1 = "4";
} else if (C2 == "B,b") {
score1 = "3";
} else if (C2 == "C,c"){
score1 = "2";
} else if (C2 == "D,d") {
score1 = "1";
} else if (C2 == "F,f"){
score1 = "0";


if ( C3 == "A,a" ) {
score2 = "4";
} else if (C3 == "B,b") {
score2 = "3";
} else if (C3 == "C,c"){
score2 = "2";
} else if (C3 == "D,d") {
score2 = "1";
} else if (C3 == "F,f"){
score2 = "0";


if ( C2 == "A,a" ) {
score3 = "4";
} else if (C4 == "B,b") {
score3 = "3";
} else if (C4 == "C,c"){
score3 = "2";
} else if (C4 == "D,d") {
score3 = "1";
} else if (C4 == "F,f"){
score3 = "0";

var avg = score+score1+score2+score3 / 4; //taking average of the total score

Here I need to send back the score and link to a new webpage or show a msgbox. Thinking window.open event.

// output message box, that'll work on submit
document.getElementById("msg-btn").onclick = function(){
msg("Your grade point average is"+ "3.2");
}

var msg = function(mensagem){
return new messagebox(mensagem);
}

function messagebox(msg){
  
var cortina = document.createElement("div");
cortina.setAttribute("style","width:100%;height:100%;display:block;position:fixed;background:#000;opacity:0;top:0;left:0;transition:opacity 0.5s;");
  

var palco = document.createElement("div");
palco.setAttribute("style","background:#fff;display:table;opacity:0;position:fixed;padding:10px;border-radius:5px;transition: opacity 0.5s;");
palco.style.top = "100px";
palco.style.left = "100px";
  
  
   var pergunta = document.createElement("span");
pergunta.innerHTML = msg;
pergunta.setAttribute("style","padding:10px;max-width:200px;display:block;");
palco.appendChild(pergunta);
  
var botao = document.createElement("span");
botao.innerHTML ="Close";
botao.setAttribute("style", "display:block;margin:5px auto;background:#16a085;width:50px;text-align:center;padding:5px 20px;color:#fff;cursor:pointer;border-radius:5px;text-shadow:1px 1px 1px #000");
palco.appendChild(botao);
botao.onmouseover = function(){this.style.background = "#1abc9c";}
botao.onmouseout = function(){this.style.background = "#16a085";}
document.body.appendChild(cortina);
document.body.appendChild(palco);
setTimeout(function(){
cortina.style.opacity = "0.5";
palco.style.opacity = "1";
},10);
botao.onclick = function(){
palco.style.opacity = "0";
cortina.style.opacity = "0";
setTimeout(function(){
cortina.style.display = "none";
palco.style.display = "none";
},500);
}
}

}
</script>

</head>
<body>
<p><b>Courses :</b></p>

<form name="Courses" action="/action_page.php" onsubmit=" ValidateCourses()" method="post">

C1:<br>
<input type="text" name="C1" value=" " maxlength="4" size="3">
<br> <br>
C2:<br>
<input type="text" name="C2" value=" " maxlength="4" size="3">
<br> <br>
C4:<br><input type="text" name="C4" value=" " maxlength="4" size="3">
<br> <br>
C3:<br>
<input type="text" name="C3" value=" " maxlength="4" size="3">
<br> <br>
<input type="submit" value="Submit" id="msg-btn">
</form>

  

</body>
</html>

</script>

</head>
<body>
<p><b>Courses :</b></p>

<form name="Courses" action="/action_page.php" onsubmit=" ValidateCourses()" method="post">

C1:<br>
<input type="text" name="C1" value=" " maxlength="4" size="3">
<br> <br>
C2:<br>
<input type="text" name="C2" value=" " maxlength="4" size="3">
<br> <br>
C4:<br><input type="text" name="C4" value=" " maxlength="4" size="3">
<br> <br>
C3:<br>
<input type="text" name="C3" value=" " maxlength="4" size="3">
<br> <br>
<input type="submit" value="Submit" id="msg-btn">
</form>

  

</body>
</html>

I could not understand the radio button part, as there is only one form. I put in the message box on the same page.

Add a comment
Know the answer?
Add Answer to:
Using Javascript, I have two radio buttons, depending on the value of the radio button 1...
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
  • Using JavaScript, I want to make a function that will open a new alert box that will say hello fi...

    Using JavaScript, I want to make a function that will open a new alert box that will say hello first name, last name after the person logs into the sign in form. This will happen aftrer the validation function is invoked. See code below. See the welcomefunction(). <!DOCTYPE html> <html> <head> <script> //validate the login form function validateForm() { var x = document.forms["LoginForm"]["fname"].value; //set x and y to first name and last name var y = document.forms["LoginForm"]["lname"].value; if (x ==...

  • i'm having trouble with 1 and 3 using html, javascript and jquery 1) Change the "Search"...

    i'm having trouble with 1 and 3 using html, javascript and jquery 1) Change the "Search" link on the left to a button that when clicked, hide all the fields on the form and display the text "This is a search feature..." 3) When the user fills the form and clicks "Login", the values inputted should be displayed in the empty row (under Login) of the page. The display should be in the form: Student ID: <input value> Student Name:...

  • I am trying to make it so that radio buttons when clicked execute a javascript file....

    I am trying to make it so that radio buttons when clicked execute a javascript file. I have to to have the exercises in external files. Here is what I have so far. I am reusing a script that was used to make radio buttons switch CSS files so I think I have to change the set attribute options. HTML <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>Document</title> </head> <body> <p> 4.2 Output: The first 20 Fibonacci numbers, which are...

  • Modify this code to store the form elements as variables and display them on the page...

    Modify this code to store the form elements as variables and display them on the page in an HTML table. <!DOCTYPE html> <html> <head> <script> function getValues() {     var result = ""; result += "First Name: " + document.forms["myForm"]["fname"].value + "<br>"; result += "Last Name: " + document.forms["myForm"]["lname"].value + "<br>"; result += "Address: " + document.forms["myForm"]["address"].value + "<br>"; result += "City: " + document.forms["myForm"]["city"].value + "<br>"; result += "State: " + document.forms["myForm"]["state"].value + "<br>"; document.getElementById("output").innerHTML = result; } </script>...

  • <html>     <head>       <title>Sign Up page</title>   <form name="validationForm" method="post" onsubmit="return checkvalidation()">      &n

    <html>     <head>       <title>Sign Up page</title>   <form name="validationForm" method="post" onsubmit="return checkvalidation()">         <!--div class-->       <div class="formvalidation">       <label>Your first Name</label>        <span id="showname"></span>        <!--label for firstname-->       <input type="text" name="firstname" class="formsignup"  id ="firstn" placeholder="Enter your Name">      <br><br>           <!--lastname-->       <label>Your last Name</label> <span id="showlname"></span>       <input type="text" name="lastname" class="formsignup" id="lastn" placeholder="Enter your last Name">       <br><br>        <!--email-->         <label>Your Email</label>          <span id="showemail"></span>         <input type="email" name="emailid" class="formsignup" size="45" id="emailn" placeholder="Enter your Email">        <br><br> <input type="submit" value="send">     </div>           </form> <script>      function checkvalidation(){     var name = document.forms["validationForm"]["firstname"].value;     var lname...

  • NEED HELP with HTML with Javascript embedding for form validation project below. I have my code...

    NEED HELP with HTML with Javascript embedding for form validation project below. I have my code below but I'm stuck with validation. If anyone can fix it, I'd really appreciate. ****************************************************************************** CODE: <!DOCTYPE html> <!-- To change this license header, choose License Headers in Project Properties. To change this template file, choose Tools | Templates and open the template in the editor. --> <html> <head> <title>Nice</title> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <script> var textFromTextArea; function getWords(){ var text =...

  • LANGUAGE JAVASCRIPT, PHP Need help with PHP and ajax code. The user needs to login but,...

    LANGUAGE JAVASCRIPT, PHP Need help with PHP and ajax code. The user needs to login but, I keep getting an error that I coded "Wrong username and password!" ***PLEASE DONT GIVE ME A NEW CODE THAT IS NOWHERE NEAR THE CODE I SUBMITTED***** PLEASE LOOK AT THE CODE AND SEE ANY ISSUES login.html <!DOCTYPE html> <html> <head> <title>login popup</title> <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script> <style type="text/css"> body { background-color: white; } </style> </head> <body> <center> <h1 style="text-align: center;"> Login </h1> <form>             Login ID:...

  • Using form events functions to answer this question. Use the attached form html file which contains...

    Using form events functions to answer this question. Use the attached form html file which contains 2 html radio buttons. When the first choice is chosen, display the text ”First” under the first choice. When the second choice is chosen, display the text ”Second” under the second choice. Instead of using JavaScript complete this question using JQuery <!DOCTYPE html> <html> <head>     <title>midterm exam</title>     <link rel="stylesheet" href="css/q1.css" /> </head> <body>     <div id = "page">        <form>   ...

  • PHP Can't get my code to work, what am I doing wrong? <!DOCTYPE html> <html> <head>...

    PHP Can't get my code to work, what am I doing wrong? <!DOCTYPE html> <html> <head> <script> </script> </head> <body> <h2>Temperature Conversion Table</h2> <h4>Enter a starting value in degrees Fahrenheit and an increment value.</h4> <form name="myTemp" onsubmit="convertCelcius()" method="post"> <input type="text" name="temperature"> Enter an value in degrees Fahrenheit<br><br> <input type="radio" name="degIncrement" id="degIncrement5"> Convert in increment in 5 degrees<br> <input type="radio" name="degIncrement" id="degIncrement10"> Convert in increment in 10 degrees <br/><br/><input type="submit" value="Submit"> </form> <?php if( $_POST["temperature"] || $_POST["degincrement"] ) { //get he...

  • I need to complete 3 validation cases in this Javascript code. I need to validate email,...

    I need to complete 3 validation cases in this Javascript code. I need to validate email, phone and street address. How would I go about validating these 3 cases in this code: <!DOCTYPE html> <html> <head> <meta charset="UTF-8" /> <title>Week 10: Regular Expressions</title> <style type="text/css"> span { padding: 2px; } .success { color: #008000; background: #99cc99; } .failure { color: #ff0000; background: #ff9999; } </style> <script type="text/javascript"> function validateInput(form) { var result0 = document.getElementById('result0'), result1 = document.getElementById('result1'), result2 = document.getElementById('result2'),...

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