c172cpt Posted July 3, 2008 Share Posted July 3, 2008 What am i not seeing there are 2 JS functions that get called by an onsubmit call (2 separate forms) what should happen is that the "Update this call" should run through a JS verification (right not it should just alert hello for debugging purposes but it doesn't even do that) but the second onsubmit call works just fine with the confirm() below is the code any ideas?? <html> <head> <title>Call Logger</title> <script language="Javascript"> function loading(){ var form = document.logger; quick_date(); form.from.value = ""; form.result.value = ""; form.issue.value = ""; } function quick_date(){ var data = document.logger.date.value; var now = new Date(); var monthnumber = now.getMonth()+1; var monthday = now.getDate(); var year = now.getYear(); if(year < 2000) { year = year + 1900; } if(monthnumber < 10){ monthnumber = "0"+monthnumber; } if(monthday < 10){ monthday = "0"+monthday; } var today = monthnumber+"-"+monthday+"-"+year; if (data == "t" || data == "T"){ document.logger.date.value = today; document.logger.from.focus(); } fuction verify_data(){ alert("hello"); } </script> </head> <body> <form method="POST" action="updatelog.php" name="logger" onsubmit="return verify_data()"> <fieldset> <legend>Phone Call logger</legend> <?php include 'common.php'; $id = $_GET['id']; $raw_result = getemsql("Select * from log where id='$id' limit 1"); While ($log = mysql_fetch_array($raw_result)){ $rawdate = $log['date']; $time = $log['time']; $customer = $log['customer']; $result = $log['length']; $issue = $log['issue']; $direction = $log['direction']; $beg_date = substr($rawdate, 5, 5); $end_date = substr($rawdate, 0, 4); $date = $beg_date."-".$end_date; switch ($direction){ case "in": $in = "Checked"; $out = ""; break; case "out": $in = ""; $out = "Checked"; break; } echo <<<HERE <table border="0" width="300"> <tr> <label for="date"><td width="61">Date:</td></label> <td width="225"><input type="text" id="date" name="date" size="31" onfocus="document.logger.date.value = null;" onkeyup = "quick_date();" value="$date"></td> </tr> <tr> <label for="from"><td width="61">Customer</td></label> <td width="225"><input type="text" name="from" size="31" id="from" value="$customer"></td> </tr> <tr> <td colspan="2"> <input type="radio" name="direction" value="in" $in><font color="#FF3333">Incoming</font> <input type="radio" name="direction" value="out" $out>Outgoing </td> </td> <tr> <label for="length"><td width="61">Result:</td></label> <td width="225"><input type="text" name="result" size="31" id="length" value="$result"></td> </tr> <tr> <td width="286" colspan="2">Issue:<br> <textarea rows="9" cols="34" name="issue">$issue</textarea> </td> </tr> <tr> <td colspan="2"> <p align="center"><input type="submit" value="Update This Call" name="log"><input type="button" value="Reset" name="reset" onclick="loading();"><input type="button" Value="Cancel" name="cancel" onclick="self.close();"></td> </tr> </table> <input type="hidden" name="id" value="$id"> </form> <script language="javascript"> function sure(){ msg = "Are you sure you would like to delete this call from the call logger forever?"; return confirm(msg); } </script> <tr> <td colspan="2"> <form action="delete.php" method="post" onsubmit="return sure()"> <input type="hidden" name="id" value="$id"> <input type="hidden" name="confirm" value="yes"> <p align="center"> <input type="submit" value="DELETE THIS CALL" name="delete"> </p> </form> </td> HERE; } ?> </fieldset> </body> </html> Quote Link to comment Share on other sites More sharing options...
Psycho Posted July 4, 2008 Share Posted July 4, 2008 This: fuction verify_data(){ Should be this: function verify_data(){ Quote Link to comment Share on other sites More sharing options...
c172cpt Posted July 4, 2008 Author Share Posted July 4, 2008 Its always something simple isnt thank you this has bothered me for hours Quote Link to comment Share on other sites More sharing options...
c172cpt Posted July 5, 2008 Author Share Posted July 5, 2008 ok i thought that would fix it but for some reason the submit still isnt calling the verify_data() function any ideas? Quote Link to comment Share on other sites More sharing options...
Psycho Posted July 5, 2008 Share Posted July 5, 2008 Well, it worked for me. Of course, I had to strip out a lot of that code because you posted PHP code and I don't have the backend data to support it. When posting a JavaScript problem it is better, IMHO, if you only post the output - not the source data. Quote Link to comment Share on other sites More sharing options...
c172cpt Posted July 7, 2008 Author Share Posted July 7, 2008 its still not working i dumped the html output into a test.html file and here are the contents it displays fine i need the "Update this call" to call the verify() function <html> <head> <title>Call Logger</title> <script language="Javascript"> function loading(){ var form = document.logger; quick_date(); form.from.value = ""; form.result.value = ""; form.issue.value = ""; } function quick_date(){ var data = document.logger.date.value; var now = new Date(); var monthnumber = now.getMonth()+1; var monthday = now.getDate(); var year = now.getYear(); if(year < 2000) { year = year + 1900; } if(monthnumber < 10){ monthnumber = "0"+monthnumber; } if(monthday < 10){ monthday = "0"+monthday; } var today = monthnumber+"-"+monthday+"-"+year; if (data == "t" || data == "T"){ document.logger.date.value = today; document.logger.from.focus(); } function verify(){ alert("hello"); return false; } </script> </head> <body> <form method="POST" action="updatelog.php" name="logger" onsubmit="return verify();"> <fieldset> <legend>Phone Call logger</legend> <table border="0" width="300"> <tr> <label for="date"><td width="61">Date:</td></label> <td width="225"><input type="text" id="date" name="date" size="31" onfocus="document.logger.date.value = null;" onkeyup = "quick_date();" value="07-07-2008"></td> </tr> <tr> <label for="from"><td width="61">Customer</td></label> <td width="225"><input type="text" name="from" size="31" id="from" value=""></td> </tr> <tr> <td colspan="2"> <input type="radio" name="direction" value="in" ><font color="#FF3333">Incoming</font> <input type="radio" name="direction" value="out" Checked>Outgoing </td> </td> <tr> <label for="length"><td width="61">Result:</td></label> <td width="225"><input type="text" name="result" size="31" id="length" value="Development"></td> </tr> <tr> <td width="286" colspan="2">Issue:<br> <textarea rows="9" cols="34" name="issue">Im working on new features and this is a test record</textarea> </td> </tr> <tr> <td colspan="2"> <p align="center"><input type="submit" value="Update This Call" name="log"><input type="button" value="Reset" name="reset" onclick="loading();"><input type="button" Value="Cancel" name="cancel" onclick="self.close();"></td> </tr> </table> <input type="hidden" name="id" value="227"> </form> <script language="javascript"> function sure(){ msg = "Are you sure you would like to delete this call from the call logger forever?"; return confirm(msg); } </script> <tr> <td colspan="2"> <form action="delete.php" method="post" onsubmit="return sure()"> <input type="hidden" name="id" value="227"> <input type="hidden" name="confirm" value="yes"> <p align="center"> <input type="submit" value="DELETE THIS CALL" name="delete"> </p> </form> </td> </fieldset> </body> </html> Quote Link to comment Share on other sites More sharing options...
Psycho Posted July 8, 2008 Share Posted July 8, 2008 The function before verify(), quick_date(), does not have a closing bracket. Add the closing bracket and it will work. Quote Link to comment Share on other sites More sharing options...
c172cpt Posted July 8, 2008 Author Share Posted July 8, 2008 do you use an IDE, because i need to if it helps find this stuff, what would you recommend if you do use one right now i do everything in VI in linux Quote Link to comment Share on other sites More sharing options...
KevinM1 Posted July 8, 2008 Share Posted July 8, 2008 do you use an IDE, because i need to if it helps find this stuff, what would you recommend if you do use one right now i do everything in VI in linux Hmm..doesn't emacs or vim provide highlighting? In Windows-land, I use Notepad++. It has text highlighting and indent matching (I'd insert the image directly, but it breaks h-scroll): www.nightslyr.com/notepad.jpg Quote Link to comment Share on other sites More sharing options...
c172cpt Posted July 8, 2008 Author Share Posted July 8, 2008 I might try it out thanks for the tip -scott- Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.