SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Member
    Join Date
    Oct 2010
    Posts
    1
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    selectbox show input filed

    Hello,

    I have this code:
    PHP Code:
    <script
        function 
    checkForOther(obj
        { 
            if (!
    document.layers
            { 
                var 
    txt document.getElementById("otherTitle"); 
                if (
    obj.value == "new"
                { 
                    
    txt.style.display "inline"
                    
    // gives the text field the name of the drop-down, for easy processing 
                    
    txt.name "selTitle"
                    
    obj.name ""
                } 
                else 
                { 
                    
    txt.style.display "none"
                    
    txt.name ""
                    
    obj.name "selTitle"
                } 
            } 
        } 
    </script> 
    it's should hide/show input field accourding the user choice - if he choose "<option value='new'>new</option>", the follow action should happend:

    PHP Code:
                    <li id='otherTitle'>
                        <
    label for='new'>new artist</label>
                        <
    input type='text'  name='new_artist_name' />                
                    </
    li
    The script works, but when I click "submit" the parameter that the "select box" should send don't get send...

    here is the full code:
    PHP Code:
                    <li>
                        <
    label for='artist'>Artists</label>
                        <
    select name='artist_id' onchange=\"checkForOther(this)\">
                            <option value='new'>new artist</option>"
    ;
                            
    $query mysql_query("SELECT id, name FROM `chords_artists` ORDER BY `name` ");
                            while(
    $index mysql_fetch_array($query)) 
                            {    
                                
    $artist_id $index['id'];
                                
    $artist $index['name'];
                                echo 
    "<option value='$artist_id'>$artist</option>";
                            }
                            
                        echo 
    "    
                        </select>
                    </li>    
                    
                    <li id='otherTitle'>
                        <label for='new'>new artist:</label>
                        <input type='text'  name='new_artist_name' />                
                    </li> 
    Can you please help me with it?

  2. #2
    Unobtrusively zen silver trophybronze trophy
    paul_wilkins's Avatar
    Join Date
    Jan 2007
    Location
    Christchurch, New Zealand
    Posts
    14,526
    Mentioned
    83 Post(s)
    Tagged
    3 Thread(s)
    Can you please furnish us with a test page? We can use that to figure out what issue is, and then with a solution we can feed that back in to the code itself.
    Programming Group Advisor
    Reference: JavaScript, Quirksmode Validate: HTML Validation, JSLint
    Car is to Carpet as Java is to JavaScript


Bookmarks

Posting Permissions

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