I'm trying to create a few random word generators on the same page which generates verbs, nouns etc. (creating eventually a plot generator but the user can select suggestions that randomly generate)
I've managed to create it, however, I want the random word generated to stay in the box when I click another generator on the same page (for example if I click suggest a noun and a word is generated, then I go to click suggest a Adjective and an adjective generates, but the noun disappears from the previous box)
Any help would be great!
Cheers G
<!doctype html>
<html>
<head>
<meta charset="UTF-8">
<title>Untitled Document</title>
</head>
<body>
<?php
{
{
$Noun=array("throat",
"hammer",
"glass",
"root",
"bike",
"verse",
"mailbox",
"payment",
"things",
"beach ball",
"business",
"lake",
"hill",
"cheese",
"dime",
"lock",
"board",
"reason",
"thrill",
"example",
"curve",
"balance",
"house",
"flavor",
"page",
"wealth",
"house",
"wave",
"star",
"bucket",
"expert",
"notebook",
"form",
"window",
"bed",
"birthday",
"maid",
"rat",
"shake",
"spy",
"ice",
"carriage",
"cup",
"lace",
"magic",
"whistle",
"party",
"books",
"week",
"bone",
"cemetery",
"berry",
"bag",
"jam",
"pocket",
"fork",
"curtain",
"side",
"night",
"wood",
"street",
"noise",
"wind",
"sign",
"interest",
"middle",
"soup",
"shoes",
"month",
"mind",
"trip",
"mountain",
"shirt",
"animal",
"change",
"sock",
"sidewalk",
"bottle",
"rabbit",
"profit",
"crown",
"watch",
"volcano",
"mass",
"weight",
"town",
"flowers",
"stem",
"roll",
"sleep",
"farm",
"creature",
"songs",
"woman",
"boy",
"color",
"slope",
"jump",
"account",
"error");
//echo rand(0, 2);
$myRandom = rand(0, 99);
//echo $Cars[$myRandom];
//if first name is blank/null then put
}
?>
<form action="quote.php">
Noun<br>
<input type="text" name="firstname"
value="
<?php if (isset($_GET['Noun'])){echo $Noun[$myRandom];}
}?>"><br>
<input type="submit" name ="Noun" value="Suggest">
</form>
<?php
{
{
$Adj=array("throat",
"hammer",
"glass",
"root",
"bike",
"verse",
"mailbox",
"payment",
"things",
"beach ball",
"business",
"lake",
"hill",
"cheese",
"dime",
"lock",
"board",
"reason",
"thrill",
"example",
"curve",
"balance",
"house",
"flavor",
"page",
"wealth",
"house",
"wave",
"star",
"bucket",
"expert",
"notebook",
"form",
"window",
"bed",
"birthday",
"maid",
"rat",
"shake",
"spy",
"ice",
"carriage",
"cup",
"lace",
"magic",
"whistle",
"party",
"books",
"week",
"bone",
"cemetery",
"berry",
"bag",
"jam",
"pocket",
"fork",
"curtain",
"side",
"night",
"wood",
"street",
"noise",
"wind",
"sign",
"interest",
"middle",
"soup",
"shoes",
"month",
"mind",
"trip",
"mountain",
"shirt",
"animal",
"change",
"sock",
"sidewalk",
"bottle",
"rabbit",
"profit",
"crown",
"watch",
"volcano",
"mass",
"weight",
"town",
"flowers",
"stem",
"roll",
"sleep",
"farm",
"creature",
"songs",
"woman",
"boy",
"color",
"slope",
"jump",
"account",
"error");
//echo rand(0, 2);
$Random = rand(0, 99);
//echo $Cars[$myRandom];
//if first name is blank/null then put
}
?>
<form action="quote.php">
Noun<br>
<input type="text" name="firstname"
value="
<?php if (isset($_GET['Adjective'])){echo $Adj[$Random];}
}?>"><br>
<input type="submit" name ="Adjective" value="Suggest">
</form>
</body>
</html>
Aucun commentaire:
Enregistrer un commentaire