In this the JS Codes (in the code tag)are not working only in this page can any one help me on this

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"><!-- InstanceBegin template="/Templates/main.dwt.php" codeOutsideHTMLIsLocked="false" -->
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<!-- InstanceBeginEditable name="doctitle" -->
<title>Luxmi Lanka</title>
<!-- InstanceEndEditable -->
<!-- InstanceBeginEditable name="head" -->
<!-- InstanceEndEditable -->
<link href="CSS/style.css" rel="stylesheet" type="text/css" />
<script language="javascript" src="calendar/calendar.js"></script>
<script type="text/javascript" src="js/jquery.js"></script>

<script type="text/javascript" src="js/js1.js"></script>
<script language="javascript" type="text/javascript" src="js/mootools.js"></script>
<script language="javascript" type="text/javascript" src="js/getchqno.js"></script>

</head>

<body onload="GetValues()">
<div id="body" >
<div id="head"><img src="images/banner.png" width="498" height="123" />
<div id="menutop">
    <ul>
        <li><a href="index.php"><span>&nbsp; Home&nbsp; </span></a></li>
        <li><a href="addsupcus.php"><span> &nbsp;Controll&nbsp; </span></a></li>

        <li><a href="report.php"><span> &nbsp;Reports&nbsp; </span></a></li>
        <li><a href="#"><span> &nbsp;Other&nbsp; </span></a></li>
    </ul>
</div>
</div>


<div id="content"><!-- InstanceBeginEditable name="EditRegion3" --><div id="sidemenu">
    <p><a href="index.php?supstatus=1&cusstatus=0">Supplier Transactions</a></p>
    <p><a href="index.php?supstatus=0&cusstatus=1">Coustomer Transactions</a></p>
    <p><a href="index.php?supstatus=0&cusstatus=1">Cheque</a></p>

</div>
<div id="divadd">

div for add informations
<div  id="cheqdes">
  <p><b>Clearence Cheques Of Today</b></p>
  <table width="185" border="0" bgcolor="#fff3ff" style="margin-left:auto; margin-right:auto;">
    <tr style="background-color: #eab8eb;" >
      <td width="95"><b>Name</b></td>
      <td width="74"><b>Ammount</b></td>
    </tr>
    <?php 
    include("init/db.php");
       $today=date("Y-m-d");
      $sql="SELECT *
FROM `cheques_details` where date='$today'";
$result=mysql_query($sql);
while($info=mysql_fetch_array($result)){
    $name=$info['name_of_owner'];
    $ammount=$info['ammount'];
    $id=$info['id'];
    $url="'chq/chqpopup.php?id=$id'";
     echo '<tr onclick="javascript:popUpchq('.$url.')" id="chqtb">
      <td>'.$name.'</td>
      <td>'.$ammount.'</td>
    </tr>';
    }

      ?>

  </table>
  <p>&nbsp;</p>
</div>

<script type="text/javascript">
function buildSelect(select, options)
{
    var select = $(select);
    select.empty();
    options.each(function(item) {
        if($type(item) != "array")
        {
            item = [item, item];
            var option = new Element("option", {
                text: item[0].toString(),
                value: item[1].toString()
            });
            option.inject(select);
        }
    });
}

function domready()
{
    $('master').addEvent('change', master_changed);
}

function master_changed()

{

    var req = new Request.JSON({
        url: 'getowner.php',
        method: 'post',
        data: 'id=' + encodeURIComponent($('master').get('value'))
    });
    req.addEvent('success', function(response) {
        buildSelect('slave', response);
    });
    req.send();
}
window.addEvent('domready', domready);
</script>
<div id="deks">desk
  <form action="" method="post" name="F2" id="F2" >
    <p>Make
      <select name="make" id="master">
        <option selected="selected" >d1</option>
        <?php
   include("init/db.php");
       $sql="SELECT *
FROM `customers`";

        $result=mysql_query($sql);
        while ($info=mysql_fetch_array($result)){
            $id= $info['id'];
            $name = $info['fname']." ".$info['lname'];
            echo '<option value="'.$id.'">'.$name.'</option>';
            }       

        ?>
      </select>
    </p>
    <p>Model
      <select name="model" id="slave">
        <option>SELECT</option>
      </select>
    </p>
  </form>
</div>




</div> <!-- InstanceEndEditable --></div>


</div>
</body>
<!-- InstanceEnd --></html>

Dani AI

Generated

As asked for specifics and clarified the behavior, the most likely cause is a library conflict rather than a PHP or SQL problem. The page uses MooTools-style APIs (MooTools names like Request.JSON, addEvent, $type, and Element.inject) while also loading jQuery. Both frameworks use the global $ and have different DOM-ready and AJAX conventions; when both are present without coordination, one library can overwrite the other or a script error can stop further execution. Other possible causes to rule out: missing/incorrect script path (404), syntax errors in any included script, or invalid JSON returned from the server.

Checklist and practical fixes

  • Open the browser console (F12) and check for JavaScript errors and 404s. A single runtime error will halt subsequent scripts.
  • Verify the AJAX endpoint returns clean, valid JSON (no PHP warnings/HTML before the JSON). Use the Network panel to inspect the response and headers (Content-Type: application/json helps).
  • Avoid $ collisions: call jQuery.noConflict() and use an alias for jQuery-only code so MooTools can keep $.

Example approaches (keep MooTools code as-is, isolate jQuery)

<script src="path/to/jquery.js"></script>
<script>
var $j = jQuery.noConflict();  // releases $ so MooTools can own it
$j(function(){
  // jQuery-only code uses $j instead of $
});
</script>
<script src="path/to/mootools.js"></script>

If converting the AJAX call to jQuery is preferred, use the jQuery JSON helper and populate the select via jQuery methods (example uses the alias from above):

$j.getJSON('getowner.php', { id: $j('#master').val() }, function(data) {
  var $slave = $j('#slave').empty();
  $j.each(data, function(i, item){
    $slave.append($j('<option>').text(item[0]).val(item[1]));
  });
});

References: jQuery.noConflict() documentation and jQuery.getJSON documentation are useful starting points: jQuery.noConflict(), jQuery.getJSON().

Recommended Answers

All 2 Replies

Hey.

Can you explain this a little better? Just so we know what we are looking for.

The phrase "is not working" (in any form) is a completely useless statement when you are describing your problem. We already know it's not working. That is why you posted it. What we need to know is how it is supposed to be working and how it is actually working.

Thanks :)

Hey.

Can you explain this a little better? Just so we know what we are looking for.

The phrase "is not working" (in any form) is a completely useless statement when you are describing your problem. We already know it's not working. That is why you posted it. What we need to know is how it is supposed to be working and how it is actually working.

Thanks :)

im sorry about that

in this codes what i want to do is when i selected a value in master (select list/menu) and get the relevant data from db and put in to slave(select list/menu) thi codes are working without file but the thing is i want jquery file also
thank you for the reply im sorry im not good in english

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.