Search the Community
Showing results for tags 'arrays dropdown lists radio b'.
-
Create an associative array that will be used in a form for a dropdown box for user to pick their favorite color. The entries should be:RedBlueGreenCyanMagentaYellowCreate a second associative array that will populate a set of radio buttons. The buttons should ask the user to choose their favorite type of food from following list.BarbequeChineseJapaneseThaiSteakVeganMexicanThe form should also ask for first and last name. Data should be validated. If invalid data is entered, and error should be displayed, otherwise, output the data. I have to create a form that sends the answers to the php. I don't understand where to put the arrays/ I have this but it don't seem right for the dropdown box.Even so after getting it to work how do I valid the information of a dropbox or radio button. I'm so confused. <body> <?php$color = array( 0=>"Red", 1=>"Blue", 2=>"Green", 3=>"Cyan", 4=>"Magenta", 5=>"Yellow");$food = array(0=>"Barbeque", 1>="Chinese", 2="Japanese", 3=>"Thai", 4=>"Steak", 5=>"Vegan", 6=>"Mexican"); $color = str_repalce(" "," ",$color);$food = str_replace(" "," ", $food);echo '<SELECT name=color>';echo '<SELECT name=food>';foreach ($color as $pick => $value){echo '<OPTION value='.$value.'>'.$value.;}echo '</select>'; ?> <form action="CISP1720-dpatter3-Lab7.php" method="post"> <p> Please provide your First Name. <input name="Fname" type="text" /><p/> <p> Please provide your Last Name. <input name="Lname" type="text" /><p/> <input type="submit" name="Submit" id="Submit" value="Submit"></body></html>