mercredi 18 juillet 2018

HTML/Javascript && Condition in an If Statement

I am sure there is a very simple fix to this and that I am most likely not doing this the most efficient way possible.

I am trying to create an if statement that will check to see if multiple radio buttons are selected in multiple questions. If they are selected, I would like an alert box to pop up with a certain message. There will be many selection combinations possible so I am assuming many if/else statements(?)

The Javascript in question is located at the bottom.

<!doctype html>

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

  <title>Spigit Input Form</title>
  <meta name="description" content="Spigit Input Form">
  <meta name="author" content="SitePoint">

  <link rel="stylesheet" href="css/styles.css?v=1.0">
  <link rel="stylesheet" href="Project_File_CSS.css">

  <!--[if lt IE 9]>
    <script src="https://cdnjs.cloudflare.com/ajax/libs/html5shiv/3.7.3/html5shiv.js"></script>
  <![endif]-->

  <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
  <script src="jquery_spigit.js"></script>
</head>

<body>

  <!--<script src="js/scripts.js"></script>
  <script src="New_File_JS.js"></script>-->
  <script type="text/javascript" src="selection_storage.js"></script>
  <!--<script type="text/javascript" src="recommendation_logic.js"></script>-->

<!---------------------------------------------------------Operating Company Question----------------------------------->
<form name="operatingCompany">
<h3>What Operating Company Are You Employeed With?</h3>
<input type="radio" name="opco" value="GPC" >GPC</br>
<input type="radio" name="opco" value="APC" >APC</br>
<input type="radio" name="opco" value="MPC" >MPC</br>
<input type="radio" name="opco" value="Gulf" >Gulf</br>
<input type="radio" name="opco" value="SCS" >SCS</br></br>

<input type="button" value="Display User Selection" onclick=get_opco() />
</form>

<p id="opco_result"> </p></br>


<!---------------------------------------------------------Prototyped Question----------------------------------->
<form name="prototyped">
<h3>Has the innovation been prototyped?</h3>
<input type="radio" name="prototyped" value="Yes" >Yes</br>
<input type="radio" name="prototyped" value="No" >No</br></br>

<input type="button" value="Display User Selection" onclick=get_prototype() />
</form>

<p id="prototyped_result"> </p></br>

<!--------------------------------------------------------Adopted or Tested Question---------------------------->
<form name="adopted_tested">
<h3>Has the innovation been adobpted or tested?</h3>
<input type="radio" name="adopt" value="Yes" >Yes</br>
<input type="radio" name="adopt" value="No" >No</br></br>

<input type="button" value="Display User Selection" onclick=get_adopt_test() />
</form>

<p id="adopted_tested_result"> </p></br>

<!------------------------------------------------------Can it make money Question------------------------------->
<form name="makeMoney">
<h3>Is this a product or service that can make money?</h3>
<input type="radio" name="money" value="Yes" >Yes</br>
<input type="radio" name="money" value="No" >No</br></br>

<input type="button" value="Display User Selection" onclick=get_money() />
</form>

<p id="makeMoney_result"> </p></br>

<!---------------------------------------------------Alabama Power Specific Question----------------------------->
<h3>What is your innovative idea to help Alabama Power improve safety, grow revenue, reduce cost, or increase operational efficiency?</h3>
<textarea id="alabamaPower" rows="8" cols="50">

</textarea> </br></br>

<input type="button" value="Display User Input" onclick=textareacapture() />

<p id="result"> </p></br>

<!------------------------------------------------IT Specific Question------------------------------------------->
<form name="innovativeTechnology">
<h3>Is your innovation an innovative technology or process that boosts the company's productivity or brings additional value from a vendor relationship?</h3>
<input type="radio" name="innovative" value="Yes" >Yes</br>
<input type="radio" name="innovative" value="No" >No</br></br>

<input type="button" value="Display User Selection" onclick=get_innovative() />
</form>

<p id="innovativeTechnology_result"> </p></br>

<input type="button" value="Submit Form" onclick=get_recommendation() />

<script>
function get_recommendation(){
        if((document.operatingCompany.opco[0,1,2,3,4].checked) && (document.prototyped.prototyped[0,1].checked) && (document.adopted_tested.adopt[0,1].checked))
        {
            alert("Everyday Solutions");
        }       
}
</script>

</body>
</html>

Aucun commentaire:

Enregistrer un commentaire