Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 4 of 4

Thread: Plz Help me

  1. #1
    New to the CF scene
    Join Date
    Jun 2005
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Plz Help me

    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
    thanks

  • #2
    Regular Coder
    Join Date
    May 2005
    Posts
    563
    Thanks
    0
    Thanked 3 Times in 3 Posts
    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

  • #3
    Regular Coder
    Join Date
    Feb 2005
    Location
    West Midlands, UK
    Posts
    623
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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:
    PHP Code:
    <?php
    $current_item 
    2// this would be the data from the database
    $array = array('foo''bar''baz''some''data''here');

    ?>
    <select name="select">
    <?php

    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>';
        }
    }

    ?>
    </select>
    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 as you will then find people more willing to help.

  • #4
    Supreme Overlord Spookster's Avatar
    Join Date
    May 2002
    Location
    Marion, IA USA
    Posts
    6,278
    Thanks
    4
    Thanked 83 Times in 82 Posts
    You already have a thread open on this topic.

    populating select boxes on the basis of the choices

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

    http://www.codingforums.com/postguide.htm

    Closing thread...
    Spookster
    CodingForums Supreme Overlord
    All Hail Spookster


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •