Jump to content

Simple mistake I'm sure.


chaosxkitten

Recommended Posts

 

When I try to echo the values selected in my select boxes  ( $first and $last ) nothing shows up....

 

I'm wondering if my user created function isn't naming them like I'd like...

 


<html xmlns="http://www/w3c.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<title>Catherine: TV Test</title>
<script type="text/javascript">
function load()
{
    var wH = window.innerHeight;
    var wW = window.innerWidth;
    document.getElementById('windowWidth').setAttribute('value',wW);
    document.getElementById('windowHeight').setAttribute('value',wH);
}
</script>
<style type="text/css">
    #main {
        position: relative;
        height: 100%;
margin-left: 20px;
margin-right: 20px;
    }
    table {
    position: relative;
    top: 20px;
    margin-left: auto;
    margin-right: auto;
    text-align: center;
    }

    
<?php
echo '#leftbar {
position: absolute;
top: 20px;
left: 0px;
width: 50%;
height: 600px;
background-color: rgb(0,0,255);
}';
?>
</style>
</head>
<body onload="load()">
<div id="main">
<?php
if (isset($_POST['submitted']))
{
    $bars = $_POST['stages'];
    $first = $_POST['first'];
    $last = $_POST['last'];
    echo "You entered $bars stage(s). ";
    echo "Your first color is $first. Your last color is $last.";
    //Gradient display code:
    // echo '<div id="leftbar"></div>';
   

} else
{
	/* The two following tags MUST included in a form that YOU design within
	 * this section of PHP code.
	 */
    // Function to create a uniquely named 20+ color select menu
    function Selectors ($a){
	echo '<select name="$a">';
	echo '<option value="127,255,212">Aquamarine</option>';
	echo '<option value="0,0,0">Black</option>';
	echo '<option value="0,0,255">Blue</option>';
	echo '<option value="220,20,60">Crimson</option>';
	echo '<option value="0,255,255">Cyan</option>';
	echo '<option value="148,0,211">Dark Violet</option>';
	echo '<option value="255,20,147">Deep Pink</option>';
	echo '<option value="255,215,0">Gold</option>';
	echo '<option value="255,0,255">Magenta</option>';
	echo '<option value="25,25,112">Midnight Blue</option>';
	echo '<option value="255,165,0">Orange</option>';
	echo '<option value="128,0,128">Purple</option>';
	echo '<option value="255,0,0">Red</option>';
	echo '<option value="65,105,255">Royal Blue</option>';
	echo '<option value="192,192,192">Silver</option>';
	echo '<option value="135,206,235">Sky Blue</option>';
	echo '<option value="0,255,127">Spring Green</option>';
	echo '<option value="64,224,208">Turquoise</option>';	
	echo '<option value="238,130,238">Violet</option>';
	echo '<option value="255,255,0">Yellow</option>';	
	echo '</select>';
    }
    
    // Variables to use when calling the previous function
    $f = "first";
    $l = "last";
    
    //begin html form
    echo '<form action="tvtest.php" method="POST">';
        //Hidden input...
	echo '<input type="hidden" name="windowWidth" id="windowWidth" />';
	echo '<input type="hidden" name="windowHeight" id="windowHeight" />';
	// Input table
	echo '<table>';
	echo '<tr>';
	echo '<td><label>First Color:</lable></td>';
	echo '<td>';
	Selectors($f);
	echo '</td>';
	echo '</tr>';
	echo '<tr>';
	echo '<td><label>Second Color:</lable></td>';
	echo '<td>';
	Selectors($l);
	echo '</td>';
	echo '</tr>';
	echo '<tr>';
	echo '<td><label>Number of Stages: </label></td>';
	echo '<td><input type="text" name="stages" /></td>';
	echo '</tr>';
	echo '<tr>';
	echo '<td colspan="2">';
	echo '<input type="submit" name="submitted" value="Show Pattern" /></td>';
	echo '</tr>';
	echo '</table>';
	echo '</form>';
	//End html form
}
?>
</div>
</body>
</html>

Link to comment
Share on other sites

to clear out some of the junk code...

 

    // Function to create a uniquely named 20+ color select menu
    function Selectors ($a){
	echo '<select name="$a">';
	echo '<option value="127,255,212">Aquamarine</option>';
	echo '<option value="0,0,0">Black</option>';
	echo '<option value="0,0,255">Blue</option>';
	echo '<option value="220,20,60">Crimson</option>';
	echo '<option value="0,255,255">Cyan</option>';
	echo '<option value="148,0,211">Dark Violet</option>';
	echo '<option value="255,20,147">Deep Pink</option>';
	echo '<option value="255,215,0">Gold</option>';
	echo '<option value="255,0,255">Magenta</option>';
	echo '<option value="25,25,112">Midnight Blue</option>';
	echo '<option value="255,165,0">Orange</option>';
	echo '<option value="128,0,128">Purple</option>';
	echo '<option value="255,0,0">Red</option>';
	echo '<option value="65,105,255">Royal Blue</option>';
	echo '<option value="192,192,192">Silver</option>';
	echo '<option value="135,206,235">Sky Blue</option>';
	echo '<option value="0,255,127">Spring Green</option>';
	echo '<option value="64,224,208">Turquoise</option>';	
	echo '<option value="238,130,238">Violet</option>';
	echo '<option value="255,255,0">Yellow</option>';	
	echo '</select>';
    }
    
    // Variables to use when calling the previous function
    $f = "first";
    $l = "last";
    
    //begin html form
    echo '<form action="tvtest.php" method="POST">';
        //Hidden input...
	echo '<input type="hidden" name="windowWidth" id="windowWidth" />';
	echo '<input type="hidden" name="windowHeight" id="windowHeight" />';
	// Input table
	echo '<table>';
	echo '<tr>';
	echo '<td><label>First Color:</lable></td>';
	echo '<td>';
	Selectors($f);
	echo '</td>';
	echo '</tr>';
	echo '<tr>';
	echo '<td><label>Second Color:</lable></td>';
	echo '<td>';
	Selectors($l);
	echo '</td>';
	echo '</tr>';
	echo '<tr>';
	echo '<td><label>Number of Stages: </label></td>';
	echo '<td><input type="text" name="stages" /></td>';
	echo '</tr>';
	echo '<tr>';
	echo '<td colspan="2">';
	echo '<input type="submit" name="submitted" value="Show Pattern" /></td>';
	echo '</tr>';
	echo '</table>';
	echo '</form>';
	//End html form

 

and then

 

if (isset($_POST['submitted']))
{
    $bars = $_POST['stages'];
    $first = $_POST['first'];
    $last = $_POST['last'];
    echo "You entered $bars stage(s). ";
    echo "Your first color is $first. Your last color is $last.";

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.