Jump to content

Php List Box? Import Option?


Deanznet

Recommended Posts

Well, this is what i want to do

 

I want to have a list box and 3 text box

 

The first text box i enter in 123456

 

Then the second text box i enter in 0 and the third i enter in 10

 

Then i have the php file post to it self generating numbers in the list box using the value of text box 1 so it would be

 

1234560

1234561

1234562

1234563

ect.. all the way up to 10

 

Any Idea?

<?php

if(isset($_POST['generate'])) {


$def = trim($_POST['def']);
$bot_range = trim($_POST['bot_range']);
$top_range = trim($_POST['top_range']);

echo "<select>";

for($i = $bot_range; $i<=$top_range; $i++) {

echo "<option value=\"$def$i\">$def$i</option>";

}//end for loop
echo "</select>";

}




?>

<form action="" method="post">

<input type="text" name="def" />Default Number<br />
<input type="text" name="bot_range" />Bottom Range<br />
<input type="text" name="top_range" />Top of Range<br />
<input type="submit" name="generate" value="Generate" />

</form>


 

 

here i made a few improvements so that leading 0's dont disappear in case you set the bottom range as 0001 etc

 

<?php

if(isset($_POST['generate'])) {


$def = trim($_POST['def']);
$bot_range = trim($_POST['bot_range']);
$lng = strlen($bot_range);
$top_range = trim($_POST['top_range']);

echo "<select>";

for($i = $bot_range; $i<=$top_range; $i++) {

echo "<option value=\"$def$i\">$def".str_pad($i, $lng, '0', STR_PAD_LEFT)."</option>";

}//end for loop
echo "</select>";

}





?>

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.