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 2 of 2
  1. #1
    Regular Coder
    Join Date
    Jun 2008
    Posts
    682
    Thanks
    114
    Thanked 2 Times in 2 Posts

    Select Menu Dropping Down a Space

    My question is why does the second select menu drop down a line. Why isn't it beside "Show Name:"? One more thing I want to know. When a user selects the showname out of the drop down I want it to take that show name to the DB and match that against all the same shownames and find the one with the highest show label (tiny int.) and and one to the that number and place that into the readonly input text box. How do I do that?

    Here's my php page:
    PHP Code:
    <html>
    <head>
    <title>Untitled Document</title>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
    <script type="text/javascript">
    function ajaxGet()
    {

        var xmlHttp;

        try

        {

              // Firefox, Opera 8.0+, Safari

              xmlHttp=new XMLHttpRequest();

        }

        catch (e)

          {

              // Internet Explorer

              try

            {

                xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");

            }

              catch (e)

            {

                try

                  {

                      xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");

                  }

                catch (e)

                  {    

                      alert("Your browser does not support AJAX!");

                      return false;

                  }

            }

        }

        xmlHttp.onreadystatechange=function()

        {

              if(xmlHttp.readyState==4)

            {

                  document.getElementById('shownam').innerHTML = xmlHttp.responseText;

            }

        }

        //alert("Selected: " + document.getElementById("ajax1").value);

        xmlHttp.open("GET","showAjax.php?type=" + document.getElementById("ajax1").value,true);

        xmlHttp.send(null);

    }

    </script>
    </head>
    <body>
    <?php
    /* setupshow.php */

    /* This form after submission takes the results of the form and makes a new show ready for adding matches. */
    require ('database.php');
    echo 
    '<form action="setupshow.php" method="post" name="myForm">';
    echo 
    '<fieldset>';
    echo 
    '<legend>Enter the following information to setup a show:</legend>';
    echo 
    '<p>Weekly Show or Pay-Per View:<select name="type" id="ajax1" onChange="ajaxGet();"><option value="">Select a Show Type</option>';

                      
    $query 'SELECT type FROM shows';

                    
    $result mysql_query($query);

                while (
    $row mysql_fetch_assoc($result)){

                        echo 
    "<option value=\"{$row['type']}\">{$row['type']}</option>\r";

                    }            
    echo 
    '</select></p>';
    echo 
    "<p>Show Name:<div id=\"shownam\"><select id=\"names\"></select></div>";
    echo 
    '<p>Show Label:<input name="showlabel" type="text" readonly="true" size="5"></p>';
    echo 
    '<p>Location:<input name="location" type="text"></p>';
    echo 
    '<p>Arena:<input name="arena" type="text"></p>';
    echo 
    '<div align="center"><input name="submit" type="submit" value="Submit"><input name="sumbitted" type="hidden" value="TRUE"></div>';
    echo 
    '</fieldset>';
    echo 
    '</form>';
    ?> 
    </body>
    </html>
    Here's my ajax page:
    PHP Code:
    <?php

    require('database.php');

    if(isset(
    $_GET['type']))

    {

        
    $type mysql_real_escape_string($_GET['type'],$link);

        
    $res mysql_query("SELECT `showname` FROM `shows` WHERE `type` = '".$type."';") or die("ERROR 1");

        echo 
    "<select id=\"names\">";

        while(
    $list mysql_fetch_assoc($res))

        {

            echo 
    "<option value=\"".$list['showname']."\">".$list['showname']."</option>";

        }

        echo 
    "</select>";

    }

    ?>

  • #2
    Senior Coder shyam's Avatar
    Join Date
    Jul 2005
    Posts
    1,563
    Thanks
    2
    Thanked 163 Times in 160 Posts
    Quote Originally Posted by CoolAsCarlito View Post
    My question is why does the second select menu drop down a line. Why isn't it beside "Show Name:"?
    because its within a div element...change it to span and it will behave (but, thats semantically wrong :O...)

    Quote Originally Posted by CoolAsCarlito View Post
    One more thing I want to know. When a user selects the showname out of the drop down I want it to take that show name to the DB and match that against all the same shownames and find the one with the highest show label (tiny int.) and and one to the that number and place that into the readonly input text box. How do I do that?
    construct the correct html and add it to the innerHTML portion
    Last edited by shyam; 10-15-2008 at 12:46 PM. Reason: grammar :(
    You never have to change anything you got up in the middle of the night to write. -- Saul Bellow


  •  

    Posting Permissions

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