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
    New to the CF scene
    Join Date
    Mar 2009
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    php is not function with onchange dropdown menu

    hello..hi...i have a little prob here where i need to display selected item from dropdown menu into text box. what i want to do is when user select the item it will display on textbox call programme (java script) and also when button search is click it will display the total number of particular programme (php). for now, selected programme is function but the other one is not.here is the code and interface...
    Code:
    //for display on textbox function
    <script>
    function addOption(x) {
    sOption=document.getElementById('programme').value;
    sOptions=sOption.split("\n");
    if (sOption == '') {document.getElementById('programme').value=x+"\n";}
    else {  
      if (sOptions.length > 1) {document.getElementById('programme').value=sOption+x+"\n";}
      else {document.getElementById('programme').value=sOption+"\n"+x+"\n";}
    }
    document.getElementById('programme').focus();
    }
    </script>
    Code:
    //for interface and php code
          <table width="200" align="left" cellpadding="0" cellspacing="0">
            <tr>
              <td><div align="left"><span class="style14">Welcome <?php echo $_SESSION['nama'];?></span></div></td>
            </tr>
          </table>
          <a href="logout.php"><img align="absmiddle"src="images/001_20.gif" border="0"width="24" height="24"/><kbd><span class="style8">[Logout]</span></kbd></a>
        </div>    </td>
      </tr>
      <tr>
        <td width="691" colspan="3" rowspan="17"bgcolor="#EEEEEE"><div align="right"></div>
          <table width="648" border="0" align="center" cellspacing="0">
            <tr>
              <td width="615"></td>
            </tr>
            <tr bgcolor="#CCFF66">
              <td height="21" bgcolor="#CCFF66"><div align="center" class="style4">Programme Summary </div></td>
            </tr>
            <tr>
              <td bgcolor="#EEEEEE"><label></label>
                <p> </p>
                <table width="597" align="center">
                  <tr>
                    <td width="162"><span class="style8">Programme Selected : </span></td>
                    <td width="264"><form id="form1" name="form1" method="post" action="">
                      <input name="programme" type="text" id="programme" value="" size="60" readonly="true" />
                    </form></td>
                  </tr>
                  </table>
                <label><br />
                </label>
                <label></label>
                <form action="RepProgtry.php" method="post" class="style8">
                  <p align="center"><br />
                    </p>
                  <div align="center">Programme     :
                    <select name="selectBox1" id="selectBox1" onchange="addOption(value);">
                      <option> --- Select Programme --- </option>
                      <option>DIP IN MULTIMEDIA TECHNOLOGY </option>
                      <option>DIP IN MULTIMEDIA (BUSINESS COMPUTING) </option>
                      <option>DIP IN MARKETING WITH MULTIMEDIA</option>
                      <option> DIP IN MANAGEMENT WITH MULTIMEDIA </option>
                      <option>DIP IN COMPUTER SCIENCE</option>
                    </select>
                      <input name="Search" type="submit" value="Search" />
                    </div>
                </form>
                <label></label>
                <div align="center">
                  <table width="183" cellspacing="1" bordercolor="#ECE9D8" bgcolor="#EEEEEE">
                    <tr>
                      <td width="116" class="style8"><div align="right">
                          <?php
                
                        include'dbconnect.php';
            
            if (isset($_POST['Search']))        
                $programme = $_POST['programme'];
            else
                $programme = 0;
            
            $query = "SELECT COUNT( matric ) AS MYCOUNT
                                    FROM `student` 
                                    WHERE `programme` = '$programme'";
            
            $result = mysql_query($query);
            $row = mysql_fetch_array($result, MYSQL_ASSOC);
                   
             ?>
                        Total Student </div></td>
                      <td width="14" class="style8"><div align="center">=</div></td>
                      <td width="41" class="style8"><div align="left"><?php echo $row['MYCOUNT']; ?></div></td>
                    </tr>
                    </table>
                </div>
              <label></label></td>
            </tr>
              </table>
          <p> </p>
        <p> </p>      
        <p> </p></td>
      </tr>
      
        <tr>
        <td bgcolor="2219d3" width="154"><div align="center"><span class="style4"><img src="images/register.gif" width="154" height="30" /></span></div></td>
      </tr>
      <tr>
        <td bgcolor="#3399FF" height="30"><span class="style11"><a href="insertstudent.php"><img src="images/bullet.png" width="12" height="12" />Student Details </a></span></td>
      </tr>
      <tr>
        <td bgcolor="#3399FF" height="30"><span class="style11"><a href="insertstudent.php"><img src="images/bullet.png" width="12" height="12" /></a>Student Hostel </span></td>
      </tr>
      <tr>
        <td  bgcolor="#3399FF" height="30"><span class="style11"><a href="insertstudent.php"><img src="images/bullet.png" width="12" height="12" /></a>Student Fee </span></td>
      </tr>
      <tr>
        <td bgcolor="2219d3"><div align="center"><img src="images/payment.gif" width="154" height="30" /></div></td>
      </tr>
      <tr>
        <td bgcolor="#3399FF" height="30"><span class="style11"><a href="insertstudent.php"><img src="images/bullet.png" width="12" height="12" /></a><a href="insertpayment.php">Student Payment </a></span></td>
      </tr>
      <tr>
        <td bgcolor="2219d3"><div align="center"><img src="images/search.gif" width="154" height="30" /></div></td>
      </tr>
      <tr>
        <td bgcolor="#3399FF" height="30"><span class="style8"><a href="insertstudent.php"><img src="images/bullet.png" width="12" height="12" /></a><a href="searchstudent.php">Student Information </a></span></td>
      </tr>
      <tr>
        <td bgcolor="#3399FF" height="30"><span class="style8"><a href="insertstudent.php"><img src="images/bullet.png" width="12" height="12" /></a><a href="searchfee.php">Student Fees </a></span></td>
      </tr>
      <tr>
        <td bgcolor="2219d3"><div id="Layer8">
          <? include('calendar.inc'); ?>
        </div>
            <img src="images/summary.gif" width="154" height="30" /></td>
      </tr>
      <tr>
        <td bgcolor="#3399FF" height="30"><span class="style8"><a href="insertstudent.php"><img src="images/bullet.png" width="12" height="12" /></a><a href="RepProg.php">Programme</a></span></td>
      </tr>
      <tr>
        <td bgcolor="#3399FF" height="30"><span class="style8"><a href="insertstudent.php"><img src="images/bullet.png" width="12" height="12" /></a><a href="RepPayment.php">Payment</a></span></td>
      </tr>
      <tr>
        <td bgcolor="2219d3"><img src="images/message.gif" width="154" height="30" /></td>
      </tr>
      <tr>
        <td bgcolor="#3399FF" height="30"><span class="style8"><a href="insertstudent.php"><img src="images/bullet.png" width="12" height="12" /></a>Inbox</span></td>
      </tr>
      <tr>
        <td bgcolor="#3399FF" height="30"><span class="style8"><a href="insertstudent.php"><img src="images/bullet.png" width="12" height="12" /></a>Send</span></td>
      </tr>
      <tr>
        <td rowspan="8" bgcolor="2219d3"> </td>
      </tr>
      <tr>
        <td bgcolor="#EEEEEE"><div align="center"><span class="style14">Copyright  2009 MMC Kuching</span></div></td>
      </tr>
    </table>

  • #2
    Kor
    Kor is offline
    Red Devil Mod Kor's Avatar
    Join Date
    Apr 2003
    Location
    Bucharest, ROMANIA
    Posts
    8,478
    Thanks
    58
    Thanked 379 Times in 375 Posts
    I don't quite understand. You want to change php variables (or call a php function) dynamically with javascript only? That is not possible. You need AJAX to do that.

    Can you re-form your problem or detail it?
    KOR
    Offshore programming
    -*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*


  •  

    Posting Permissions

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