Solved

PHP- why does this not select the posted value?

Posted on 2006-06-26
2
256 Views
Last Modified: 2010-04-17


<!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 http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Untitled Document</title>
</head>

<body>

<form action="testy.php" method="post">
<select name="listname">
<option value="php3"<? if(isset($_POST['listname']) && $_POST['listname'] == 'php3'){echo  ' selected = "selected" '; }?>> PHP 3</option>

<option value="php4"<? if(isset($_POST['listname']) && $_POST['listname'] == 'php3'){echo  ' selected = "selected"'; }?>> PHP 4</option>

<option value="php5"<? if(isset($_POST['listname']) && $_POST['listname'] == 'php3'){echo  ' selected = "selected"'; }?>>PHP 5</option>

</select>

<input type="submit" name="Submit" value="Submit" />
</form>
</body>
</html>
0
Comment
Question by:roscoeh23
2 Comments
 
LVL 3

Accepted Solution

by:
AndyWHV earned 500 total points
ID: 16982885
The Problem is the login in the if structure...

look at
if ( (isset($_POST['listname'])) && ($_POST['listname'] == 'php3') )

you check for php3 every time.

Greetz
Andy ;-)
0
 
LVL 2

Expert Comment

by:T3Logic
ID: 16984016
<option value="php3"<? if(isset($_POST['listname']) == 'php3'){echo  ' selected = "selected" '; }?>> PHP 3</option>

<option value="php4"<? if(isset($_POST['listname']) == 'php4'){echo  ' selected = "selected"'; }?>> PHP 4</option>

<option value="php5"<? if(isset($_POST['listname']) == 'php5'){echo  ' selected = "selected"'; }?>>PHP 5</option>
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Java Loop 6 74
VBSCRIPT string remove all characters to the right after extension 4 72
How to Have Macro Files Automatically "Edit" 5 49
Developing a front end to SPLUNK 1 62
This article will show, step by step, how to integrate R code into a R Sweave document
Displaying an arrayList in a listView using the default adapter is rarely the best solution. To get full control of your display data, and to be able to refresh it after editing, requires the use of a custom adapter.
With the power of JIRA, there's an unlimited number of ways you can customize it, use it and benefit from it. With that in mind, there's bound to be things that I wasn't able to cover in this course. With this summary we'll look at some places to go…
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

733 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question