www.webdeveloper.com
Results 1 to 2 of 2

Thread: Trying to use two drop downs on one page

  1. #1
    Join Date
    Mar 2012
    Location
    Battle Ground, Washington
    Posts
    30

    Trying to use two drop downs on one page

    I am trying to create a page that has more than one drop down. I am having trouble with the syntax. I am also having trouble trying to separate the two Buttons that both submit form data. There are two pages here. One PHP page and one HTML page

    Here is the HTML page:
    Code:
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    
    <head>
    <meta content="en-us" http-equiv="Content-Language" />
    <meta content="text/html; charset=utf-8" http-equiv="Content-Type" />
    <title>Portland Climate Data</title>
    <style type="text/css">
    .banner {
    	background-color: #000000;
    	color: #FFFFFF;
    	text-align: center;
    	font-size: x-large;
    }
    .button {
    	background-color: #00FFFF;
    	position: relative;
    	width: 100%;
    	text-align: center;
    }
    .content {
    	background-color: #000080;
    	color: #FFFFFF;
    }
    </style>
    </head>
    
    
    <div class="auto-style1">
    
    <div id="banner" class="banner">
    	PORTLAND CLIMATE DATA</div>
    
    <div id="button" class="button">
    	<table cellpadding="0" cellspacing="0" style="width: 100%">
    		<tr>
    			<td style="width: 268px" class="auto-style1">
    			<form  action="process4.php" method="post">
                <select name="item" style="width: 72px; height: 27px;">
                    <?php for($i=2010; $i>=1949; $i--){?>
                      <option value="<?php echo $i?>" <?php if($i==$_POST['item']) echo 'selected="selected"'?>><?php echo $i?></option>
                    <?php }?>
                </select>   &nbsp
    			
                <input name="Submit1" type="submit" value="submit" style="height: 27px" /></div>
             <br />
    		 <td style="width: 258px; text-align: center;">
    			<form action="process4.php" method="post">
    			<select name="item2" style="width: 109px">
    		<?php $M1= 'Jan-2012'?>;
    
    			<option value = "<?php echo $M1?>" <?php echo 'selected="selected"'?><?php echo $M1?></option>
    			<option value = "Feb-2012">Feb-2012</option>
    			</select>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
    			<input name="submit2" type="submit" value="submit" /></td>
    			<td>&nbsp;</td>
    			<td>&nbsp;</td>
    			<td>&nbsp;</td>
    			</tr>
                <div id="content" align="center" class="content"><?php echo $url ?></div>
    			</td>
    			
    			
    			</form> 
    	</table>
    
    
    </div>
    
    <div id="content" class="content"<?php echo $url ?>
    
    </div>
    
    </body>
    
    </html>
    Lines 50-52 are giving me problems. I am trying to get dropdown/button #2 to react like button #1 is. Here is the line 50-52 code
    Code:
    	<?php $M1= 'Jan-2012'?>;
    			<option value = "<?php echo $M1?>" <?php echo 'selected="selected"'?><?php echo $M1?></option>
    			<option value = "Feb-2012">Feb-2012</option>
    Here is the PHP PAGE:
    Code:
    <?php
    error_reporting(E_ALL ^ E_NOTICE);
    if($_POST['item']) 
      $item = $_POST['item']; 
    else 
      $item = 2010; 
    $url = "<img src='/FORMPROCESSING/ClimateImages/{$item}.png' />"; 
    
    if($_POST['item2']) 
      $item2 = $_POST['item2']; 
    else 
      $item2 = Jan-2012; 
    $url2 = "<img src='/FORMPROCESSING/ClimateImages/{$item2}.png' />"; 
    
    //include_once('portland.html');
    include_once('2button.html');
    ?>

  2. #2
    Join Date
    Mar 2012
    Posts
    3

    end tag =)

    Seems like you forgot to end the <option> tag

    change:
    <option value = "<?php echo $M1?>" <?php echo 'selected="selected"'?><?php echo $M1?></option>

    to:
    <option value = "<?php echo $M1?>" <?php echo 'selected="selected"'?>><?php echo $M1?></option>

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles