I am trying to create a javascript form where there is an input which outputs words into a textbox, then based on the presence of some of the words (not exact phrases) within that box there is a second output in another textbox.
I have a feeling it probably requires a .search command and something to do with regexp but I am struggling to work out how to implement it.
The below is not the final implementation, but an example form of the same idea:

```
<html>
<head>
<script type="text/javascript">

function calculate(){

var input = document.input.value;
var output1 = document.output1.value;

if (input = 1){
output1 = "x type 1";
}

else if (input = 2){
output1 = "y type 1";
}

else if (input = 3){
output1 = "y type 2";
}

if (output1.search("type 1"){
document.output2.value = "z";
}

}
</script>
</head>
<body>
<form>
Input<input type="textbox" name="input"><br>
<input type="button" onclick="calculate()" value="Calculate" /><br>
<textarea rows="2" name="output1" ></textarea>
<textarea rows="2" name="output2" ></textarea>
</form>
</body>
</html>

```

So I'm trying to get the function to search the textbox "output1" and if it contains the words "type 1" in this example, then it outputs something into textbox "output2". I don't think the output1 as a result of the input is working in this example (not sure why) but I'm mainly trying to figure out output2 based on words contained in box output1.

Any help would be greatly appreciated. Thanks.