Jump to content

select dropdown box function


seanfacer@yahoo.co.uk

Recommended Posts

Ive tried to create a function to create a dropdown select box but im getting alot of errors to do with the if statement saying the ($_POST[$name]) value is not set???

 

function selectBox($name, $firstvalue, $limit, $increment)

{

 

// echo "<br>";

// echo $name;

// echo "<br>";

// print_r($_POST[$name]);

// echo "<br>";

$select ="selected=\"selected\"";

$body = "<select name='$name' id='$name' method='POST'>

<option value=''>$name</option>";

for ($value = $firstvalue; $value <= $limit; $value += $increment)

{

$body .= "<option value= '$value'  "; 

if ($_POST["$name"] === $value)

{

$body .= $select;

}

$body .= ">$value</option>";

}

$body .= "</select>";

// echo $value;

// echo $_POST[$name];

// echo $_POST['Width'];

return $body;

}

 

Any help would be greatly appreciated

 

Link to comment
https://forums.phpfreaks.com/topic/212760-select-dropdown-box-function/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.