View Full Version : Plz Help me

06-08-2005, 07:51 AM
I am having multiple select fields on my page, Now I want to change their content dynamically , I tried that by submitting the form every time the any of the select box value is changed and try to fetch the content from the database but I donot succeed plz help me out I am new in web developement

SeeIT Solutions
06-08-2005, 08:36 AM
Do you want to change it dynamically or change it by reloading the page.

If you want dynamicness it is a javascript question.

If not, can you post some code so we can debug it

06-08-2005, 09:14 AM
If you're simply using data from a database to populate a form and want to pre-select an item in a drop down menu you can do that by just adding "selected" to the <option> tag if the option's value is the same as the item you're trying to match.

A quick example using an array instead of database data, but it shows the basic principle:

$current_item = 2; // this would be the data from the database
$array = array('foo', 'bar', 'baz', 'some', 'data', 'here');

<select name="select">

for($i=0; $i < count($array); $i++) {
if($i == $current_item) {
echo '<option value="' . $i . '" selected>' . $array[$i] . '</option>';
} else {
echo '<option value="' . $i . '">' . $array[$i] . '</option>';

If you need more specifics then, like SeeIT said, you'll need to post some code or give us some more information to work with. Also, please read and follow the posting guidelines (http://www.codingforums.com/postguide.htm) as you will then find people more willing to help.

06-08-2005, 01:33 PM
You already have a thread open on this topic.


Stick with one of them. Also read our posting guidelines especially number 2.


Closing thread...