Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Return values from a pulldown

Status
Not open for further replies.

OldSmelly

Programmer
Nov 22, 2001
70
NL
Hello all,
I have the following problem, I have a pulldown in my form with all the countrycodes. I populate the pulldown from my mysql table and present it to the customer. So far so good.
But If the customer changes the country code via the pulldown it doesn't change and the variable will be empty in my table.

Here is the code..

The call to populate the pulldown

$land = dropmenu_landen($landcode);

The function code...

function dropmenu_landen($landcode)
{
$q = mysql_query("SELECT * from landen order by omschrijving") or die("data niet opgehaald");
$Ret = '';
$Ret .= "<select name=\"code\">";
while($a = mysql_fetch_array($q))
{
$Ret .= "<option value=\"".$a['code']."\"".($post['code'] == $a['code']?" SELECTED":"").">".$a['code'].' '.$a['omschrijving']."</option>";
}
$Ret .= "</select>";
return $Ret;
}

Here you see how I use it in the form

$form_page = <<< NAWFORMPAGE
<HTML>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" " <HEAD>
<style type="text/css">
h1 {color: Blue;}
h1 {font-size: 16pt;}
BODY, P {color: black; font-family: monospace; font-size: 9 pt}
table {margin-left: 10px}
table {margin-right: 10px;}
table {width: 70%;}
table,table *{border: 1pt solid black;}
TD {background-color: #99CCFF; }
TH {background-color: #99CCCC; }
THEAD {background-color: #99CCC; }
TFOOT {background-color: #99CCC; font-family: monospace; font-size: 9 pt}
</STYLE>
</HEAD>
<TBODY>

<TABLE>
<THEAD><TR><TD>Wijzig hier uw gegevens </TD></TR></THEAD>
Support</TD></TR></TFOOT>
<TR><TD>
<FORM METHOD=POST ACTION = "$thispage">
<H1> NAW gegevens</H1>
voorl &nbsp&nbsp&nbsp&nbsp&nbsp&nbsp:
<INPUT TYPE="text" NAME="voorl" SIZE=10 VALUE="$voorl"><br>
voorv &nbsp&nbsp&nbsp&nbsp&nbsp&nbsp:
<INPUT TYPE="text" NAME="voorv" SIZE=10 VALUE="$voorv"><br>
Achternaam &nbsp:
<INPUT TYPE="text" NAME="achternaam" SIZE=40 VALUE="$achternaam"><br>
Straat &nbsp&nbsp&nbsp&nbsp&nbsp:
<INPUT TYPE="text" NAME="straat" SIZE=40 VALUE="$straat"><br>
Huisnr &nbsp&nbsp&nbsp&nbsp&nbsp:
<INPUT TYPE="text" NAME="huisnr" SIZE=5 VALUE="$huisnr">
&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp Toev :
<INPUT TYPE="text" NAME="toev" SIZE=10 VALUE="$toev"><br>
Postcode &nbsp&nbsp&nbsp:
<INPUT TYPE="text" NAME="postcode" SIZE=10 VALUE="$postcode">
Plaats&nbsp :
<INPUT TYPE="text" NAME="plaats" SIZE=30 VALUE="$plaats">
Land &nbsp : $land <br>
Telnr &nbsp&nbsp&nbsp&nbsp&nbsp&nbsp:
<INPUT TYPE="text" NAME="telnr" SIZE=15 VALUE="$telnr"><br>
Mobielnr &nbsp&nbsp&nbsp:
<INPUT TYPE="text" NAME="mobielnr" SIZE=15 VALUE="$mobielnr"><br>
Email &nbsp&nbsp&nbsp&nbsp&nbsp&nbsp:
<INPUT TYPE="text" NAME="email" SIZE=50 VALUE="$email"><br><br>
</TD></TR>
<TR><TD>
<input type="hidden" name="stage" value="set">
<BR><BR>
<INPUT TYPE="submit" NAME="opslaan" VALUE="Opslaan">
</FORM>
</TD></TR>
</TBODY>
</HTML>
NAWFORMPAGE;

And last how I update my table...

{
$landcode = $POST['code'];
$query = "update naw set voorl = '$voorl',
voorv = '$voorv',
achternaam = '$achternaam',
extraregel = '$extraregel',
extraregel2 = '$extraregel2',
straat = '$straat',
huisnr = '$huisnr',
toev = '$toev',
postcode = '$postcode',
land = '$landcode',
plaats = '$plaats',
telnr = '$telnr',
mobielnr = '$mobielnr',
email = '$email' where idnr = '$leasid'";
$result = mysql_query($query);

I must be doing something stupid but I cant figure out why
$posr['code'] doesnt has the value from the pulldown

Hope someone can help me

Thanks
 
the value is held in $_POST['code'] variables are case sensitive and you missed the underscore.
 
ok changed that in the function ass wel as in the update to

$_POST['code']

Now the update goes well (jippie) but when the function is called with the field from the database it doens't show the correct code but it always shows the first record in the table

 
Ok fixed it :D

In the function I did

$_POST['code'] = $landcode



Thanks guys for the help....
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top