views:

102

answers:

2

The following code was working very well. Suddenly, the Edit button click stopped working. When the user used to click Edit button, a JSON code executed. But it is not recognizing the click now. Something happened accidentally? Please assist.

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"&gt;
<html>
    <head>

     <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"></meta>
     <script type="text/javascript" src="js/jquery.min.js"></script>
     <script type="text/javascript" src="js/jquery.cookie.js"></script>
     <script src="js/calendar.js" type="text/javascript"></script>
     <link href="js/calendar.css" type="text/css" rel="stylesheet" />
     <link rel="stylesheet" href="css/wysiwyg.css" type="text/css">
     <script type="text/javascript" src="js/wysiwyg.js"></script>
     <script type="text/javascript" src="js/wysiwyg-settings.js"></script>

     <!-- JSON implementation to get data through JQuery/AJAX -->
     <script type="text/javascript">
       $(document).ready(function(){
        $("#Edit").click(function(){
          $.getJSON("fetchvalues.php?UpdateRecordID=" + $.cookie('UpdateRecordID'),
                function(data){

          //Fill the Form with the data values 
          document.getElementById('LDate').value = data[0];
          document.getElementById('Places').value = data[1];
          document.getElementById('Company').value = data[2];
          document.getElementById('Designation').value = data[3];
          document.getElementById('ProjectDetails').value = data[4];
          document.getElementById('DesiredCandidate').value = data[5];
          document.getElementById('HRName').value = data[6];
          document.getElementById('HRContact').value = data[7];
          document.getElementById('Email').value = data[8];
         });
        });
       });
     </script>

     <title>Job Listing Entry</title>
    </head>
    <body>
     <table id="main" cols="2">
     <tr> 
     <td>
     <Form id="frmNewEntry" method="post" action="insert_listing.php">
      <table id="tblEntry" cols="3" style="border-color:lightblue; border-style:solid;">
       <tr><td colspan="3" bgcolor="lightblue" align="center"><strong>Real-Time Vacancy Entry</strong></td></tr>
       <tr><td>Date:</td><td><input id="LDate" name="LDate" type="text" size="20" maxlength="11"/>[Select Date from the Calendar Control]
        <script type="text/javascript">
         WYSIWYG.attach('all', full);
         calendar.set("LDate");
        </script></td>
        <td>
         <table>
          <tr>
           <td rowspan="6">
           <!-- <iframe src="show_db_vacancy_entries.php" height="800px" width="300px" bordercolor="cyan">

            </iframe> -->
           </td>
          </tr>
         </table>
        </td>
       </tr>
       <tr><td>Places:</td><td><input id="Places" name="Places" type="text" size="35" maxlength="30" onblur="this.value=MakeInitialCapital(this.value);"></td></tr>
       <tr><td>Company:</td><td><input id="Company" name="Company" type="text" size="50" onblur="this.value=MakeInitialCapital(this.value);">
       <!-- <input type="button" value="Make Initial Capital" align="left" onclick="this.value=MakeInitialCapital(this.value);"></tr> -->
       <tr><td>Designation:</td><td><input id="Designation" name="Designation" type="text" size="50" onblur="this.value=MakeInitialCapital(this.value);"></td></tr>
       <tr><td>Project Details:</td><td><textarea id="ProjectDetails" name="ProjectDetails" cols="100" rows="10"></textarea></td></tr>
       <tr><td>Desired Candidate:</td><td><textarea id="DesiredCandidate" name="DesiredCandidate" rows="3" cols="100"></textarea> <br></td></tr>
       <tr><td>HR Name:</td><td><input id="HRName" name="HRName" type="text" size="50" onblur="this.value=MakeInitialCapital(this.value);"> <br></td></tr>
       <tr><td>HR Contact:</td><td><input id="HRContact" name="HRContact" type="text" size="50"> <br></td></tr>
       <tr><td>Email:</td><td><input id="Email" name="Email" type="text" size="50"> <br></td></tr>
       <tr></tr>
       <tr>
        <td  bgcolor="lightblue">
         <input id="Clear" name="Clear" value="Clear" type="button" onclick="ClearFields();">
        </td> 
        <td bgcolor="lightblue">
         <input id='Submit' name='Submit' value='Submit' type='submit' />
        </td>
       </tr>

      </table>
     </Form>
     </td>
     <td>
      <table id="list" cols="2" style="border:none">
       <tr>
        <td colspan="2" style="border:none">
         <iframe src="show_db_vacancy_entries.php" height="600px" style="border:none;">

         </iframe>
        </td>
       </tr>
       <tr>
        <td align="left">
         <input id="Edit" name="Edit" value="Edit Record" type="button"  />
        </td>
        <td align="right">
         <input id="Delete" name="Delete" value="Delete" type="button" />
        </td>     
       </tr>
      </table>
     </td>
     </tr>
     </table>
    </body>
</html>

<script language="JavaScript" type="text/javascript">
    function MakeInitialCapital(str)
    {
       return str.toLowerCase().replace(/\b[a-z]/g, cnvrt);
        function cnvrt() {
            return arguments[0].toUpperCase();
        }

    }

    //Convert initials to capital in a certain control
    function MakeInitialCapitalControl(controlName)
    {
    var ctrl = document.getElementById(controlName).value;

    if(/^[A-Z]/.test(ctrl.value)) {
        ctrl.value = ctrl.value.toLowerCase();
        return;
    }        

   /* ctrl.value = ctrl.value.toLowerCase().replace(/\b[a-z]/g, function {
        return arguments[0].toUpperCase();
    });*/
    }

    function ClearFields()
    {
     document.getElementById('Email').value = "";
     document.getElementById('HRContact').value = "";
     document.getElementById('HRName').value = "";
     document.getElementById('DesiredCandidate').value = "";
     document.getElementById('ProjectDetails').value = "";
     document.getElementById('Designation').value = "";
     document.getElementById('Company').value = "";
     document.getElementById('Places').value = "";
     document.getElementById('LDate').value = "";
    }

</script>
A: 

I've tested the code, after removing all the external JS and CSS files, and it seems to work fine.

The problem is most likely with the JSON data that you are getting back. Perhaps you did something to the PHP file it is calling, so that the JSON object is malformed, or there is a PHP warning being printed. (Could be a result of a change in the PHP configuration, too)

I would suggest that you try using the page in Firefox with the Firebug addon active (or something equivalent). It will show you exactly what the JSON request is returning, and whether there are any errors with the request.

Atli
If I put an alert box there, still it is not showing the alert box.
RPK
A: 

As Atli said, the code looks fine. Im curious about this $.cookie('UpdateRecordID'), being part of the querystring. What happens if the cookie is not set?

Can you verify a proper response via firebug?

czarchaic