SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Zealot
    Join Date
    Jun 2006
    Posts
    166
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    cannot get the correct value of interactive form

    please excuse me if this is the wrong place put my thread!

    i got an two layer interactive select form (using javascript), the form select functions well, but i always got the wrong or "null" value when i try to echo it out.

    here's the code
    HTML Code:
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
        "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    
    <HTML>
    <head>
    <script>
    function ShowMenu(num, menu, max)
    {
                    //num is selected value, menu is the name of the div, max is the number of divs
                    for(i = 1; i <= max; i++){
                            //add number onto end of menu
                            var menu_div = menu + i;
    
                            //if current show
                            if(i == num) {
                                    document.getElementById(menu_div).style.display = 'block';
                            } else {
                                    //if not, hide
                                    document.getElementById(menu_div).style.display = 'none';
                            }
                    }
    }
    </script>
    </head>
    <BODY>
    <form method="post" action="echo.php">
    
    <p>&nbsp;</p>
    
    Category
    <select name="cata" id="cata" onChange="javascript: ShowMenu(document.getElementById('cata').value,'divcata', 3);">
            <option value="0">
            <option value="1">A
            <option value="2">B
            <option value="3">C
    </select>
    
    <div id="divcata1" style="display: none;">
    				<FONT COLOR="#006400">Sub-Cat-1</FONT>
    				<select name="catb" id="catb" onChange="javascript: ShowMenu(document.getElementById('catb').value,'divcatb', 3);">
         			<option value="0">
                    <option value="1">a1
                    <option value="2">a2
                    <option value="3">a3
    				</select>
    				<div id="divcatb1" style="display: none;">
    								<div><FONT COLOR="#006400">Sub-Cat-2</FONT>
    								<select name="catc">
    								<option value="0">
    								<option value="red">a11
    								<option value="white">a12
    								<option value="blue">a13
    								</select></div>
    				</div>
    				<div id="divcatb2" style="display: none;">
    								<div><FONT COLOR="#006400">Sub-Cat-2</FONT>
    								<select name="catc">
    								<option value="0">
    								<option value="red">a21
    								<option value="white">a22
    								<option value="blue">a23
    								</select></div>
    				</div>
    				<div id="divcatb3" style="display: none;">
    								<div><FONT COLOR="#006400">Sub-Cat-2</FONT>
    								<select name="catc">
    								<option value="0">
    								<option value="red">a31
    								<option value="white">a32
    								<option value="blue">a33
    								</select></div>
    				</div>
    </div>
    
    <div id="divcata2" style="display: none;">
    				<FONT COLOR="#006400">Sub-Cat-1</FONT>
    				<select name="catb" id="catbb" onChange="javascript: ShowMenu(document.getElementById('catbb').value,'divcatbb', 3);">
         			<option value="0">
                    <option value="1">b1
                    <option value="2">b2
                    <option value="3">b3
    				</select>
    </div>
    <div id="divcata3" style="display: none;">
    				<FONT COLOR="#006400">Sub-Cat-1</FONT>
    				<select name="catb" id="catbc" onChange="javascript: ShowMenu(document.getElementById('catbc').value,'divcatbc', 3);">
         			<option value="0">
                    <option value="1">c1
                    <option value="2">c2
                    <option value="3">c3
    				</select>
    </div>
    <input type="submit" value="echo">
    
    
    </BODY>
    </HTML>
    is there anyway to get this select form to work, i mean i can insert selected data into database?

  2. #2
    SitePoint Zealot
    Join Date
    Jun 2006
    Posts
    166
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    i found something interesting here:
    http://www.sitepoint.com/forums/show...ultiple+select

    good day!


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
  •