JSFiddle - React, Tailwind, and code Playground

by btevfik

HTML

<title>Assignment 4</title>
<h1> Assignment 4 - Sample Solution </h1>
</head>
<body>
<p>
  Name:         <input type="text" id = "input" value= "names" size="10" />
  <br />

  Verb Phrase:  <input type="text" id = "input2" value="verbs" size="10" />
  <br />

  Adjective:    <input type="text" id = "input3" value="adjs" size="10" />
  <br />

  Noun:         <input type="text" id = "input4" value="nouns" size="10" />
  <br />
HOW MANY SENTENCES? <select id = "numOfSentences" size = "1">

    <option>1</option>
    <option>2</option>
    <option>3</option>
    <option>4</option>
    <option>5</option>
    <option>6</option>
    <option>7</option>
    <option>8</option>
    <option>9</option>
    <option>10</option>
</select>

<button id = "displaySilly">
    Display Silly
</button>
<p id = "output"></p>
<script src = "silly.js"></script>

JavaScript

//arrays containing values for sentence components
var names = ["Alice","Rowena","Carol","David","Erin"];
var verbs = ["jumped on", "ran from", "scolded", "yelled at","talked to"];
var adjs  = ["yellow","big","smelly","hairy","bad"];
var nouns = ["bear","tree","rock","student","instructor"];

// variables for the sentence components
var name, verb, adj, noun; 

//when window loads
window.onload = function () {
    var names =     document.getElementById("input");
    names.value = null;
    var verbs = document.getElementById("input2");
    verbs.value= null;
    var adjs = document.getElementById("input3");
    adjs.value= null;
    var nouns = document.getElementById("input4");
    nouns.value= null;
}


// display what is put into the text fields in the sentences
//names.push(document.getElementById('input').value);
//verbs.push(document.getElementById('input2').value);
//adjs.push(document.getElementById('input3').value);
//nouns.push(document.getElementById('input4').value);

// display silly sentences 
document.getElementById('displaySilly').onclick = function() {
    var names = document.getElementById("input").value;
    document.getElementById("output").innerHTML = names;

    // get number of sentences from drop down
    var numOfSentences = 
        document.getElementById('numOfSentences').value;
    //convert to integer
}