Jump to content

[SOLVED] Javascrip onsubmit


c172cpt

Recommended Posts

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>

 

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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>

Link to comment
Share on other sites

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

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.