So I have a program that is meant to output a message based on their form input on the previous page which I have grabbed with $_GET
on the next page with php.
If believe it is something to do with setting the array with an if else statement.
Here is my php and JavaScript code :
<?php
session_start();
$theirname = $_GET['theirname'];
$yourname = $_GET['yourname'];
$slct2 = $_GET['slct2'];
$slct1 = $_GET['slct1'];
?>
<script type="text/javascript">
var theirName = "<?php echo $theirname; ?>";
var yourName = "<?php echo $yourname; ?>";
var cardType = "<?php echo $slct1; ?>";
var personType = "<?php echo $slct2; ?>";
var myArray=[
"i need",
"to make the contents of ",
"this array",
"conditional",
"to the variable",
"cardType",
"and the variable",
"personType",
];
//shuffle array:
myArray.sort(function(){return Math.round(Math.random());});
//print to screen
function printGreet()
{
document.getElementById('demo').innerHTML= [myArray.pop()];
}
</script>
And html:
<button onclick="printGreet()" class="large-btn" id="generate-Btn" rows="20">Generate</button>
</div>
<div id="yourMes">
<p>Your message:</p>
</div>
<textarea name="text1" class="large-fld" id="demo"> </textarea>
Demo of my site for more elaboration, here: http://ngrdev.com/jack/greatgreets2/index.php