Page 1 of 1

Checkbox is not working

Posted: Tue Jun 22, 2010 5:51 pm
by olaren202
Anytime i check the checkbox on the page and i return to the page, the checkbox always is empty by not saving.

I really need help on this guys.

Thanks.

Code: Select all

<?
function sendMessage($from, $subject, $message, $email) {



   $message  = nl2br(stripslashes($message));

   $headers  = "Content-type: text/html; charset=utf-8\r\n";
   $headers  = $headers.'From: '.$from;



   return mail($email,$subject,$message,$headers);

}




$arr = array(

 '1) Check Quickbooks to make sure there is a recurring billing template for them. If this is a white-label account it might sometimes be combined on a "master" billing template of the white-label affiliate vs. having it is own billing template in quickbooks.',
 '2) Check Quickbooks Activity Log to make sure merchant payment was processed for that account. If you do not see the payment processed, check that clients affiliate, to see if it has been added to a master billing template. ',
 '3) Double-check the email containing the contract to make sure the correct affiliate / reseller is assigned',
 '4) If the client is setup through a WHITE-LABEL affiliate, check to see if a "Provider" has been assigned to that client, (in addition to selecting an affiliate / reseller from the drop down list). ',
 '5) Check to make sure tasks have been posted correctly and that all files have been uploaded.',
 '6) Setup gmail.com email address for client',
 '7) Add client\'s email to E-Consulting clients list in icontact.com (seocompanyquotes, lakers1972)',
 '8)Check to see if client already has Google analytics
<p>If not, create a new analytics account and update their Google Analytics login and Analytics code on the Client page, in the Notes section. </p>

<p>Make sure that weekly reports are sent from Google Analytics (to the sales rep who signed the account as well as the client).</p>',
'9) http://www.google.com/local/add/businessCenter?gl=US&hl=en-US ',
'10) http://listings.local.yahoo.com/ (basic listing is free) ',
'11) http://advertising.superpages.com/spportal/business-listing',
'12) http://www.reddit.com',
'13) http://www.digg.com',
'14) Paste log in information for all profiles on client\'s page',
'15) Pages have been uploaded to client\'s server',
//'11) Sent Login information',
//'12) Sent intro email to schedule phone call.',

'16) Verify that Google analytics is present on all pages.',
'17) Verify that the Google login information is entered into the Client’s page',
'18) Verify that sitemap is present',
'19) Check all page titles / metas to make sure it reads perfectly and that there are no coding errors or typos',);
//'17) Had Introductory Phone call.'





 session_start();
 include_once "const.php";
 if ($_SESSION["type"] != "admin") Header("Location: proc.php");

 $a = @$_GET["a"];


if (isset($_POST["Go"]))
{

 $ready = intval(@$_POST["ready"]);




// print_r($_POST);
  $a = $_POST["id"];


   if ($ready > 0)
 {

 	  $sql = "INSERT INTO review(company_id,reviewed,date) VALUES('$a','0',".time().")";
   mysql_query($sql);


 }

 // $s = "00000000000000000000000";

 $s = "";

 for ($i=1;$i<=count($arr);$i++) $s = $s . '0';

  foreach($_POST as $k => $v)
    {
      if (is_int($k)  )
      {
       $s[intval($k) ] = $v;


      if (intval($k) == 9 && intval($v) == 1) {

      $sql = "SELECT * FROM company WHERE id = $a";
      $r   = mysql_query($sql);
      @$d   = mysql_fetch_array($r);

      if (is_array($d)) {

      $client  = $d["companyName"];
      $contact = $d["companyContact"];
      $phone   = $d["companyPhone"];
      if (empty($phone)) $phone   = $d["companyPhone2"];
      $email   = $d["companyEmail"];
      if (empty($email)) $email   = $d["companyEmail2"];
      $web     = $d["companyWeb"];


      $message = "<html><head></head><body><p>$client is ready to be contacted for their intro call!</p>
                  <p>
                  <div><strong>CONTACT INFO</strong></div>
                  <div><strong>Client:</strong>$client</div>
                  <div><strong>Contact Name:</strong>$contact</div>
                  <div><strong>Phone:</strong>$phone</div>
                  <div><strong>Email:</strong>$email</div>
                  <div><strong>Website:</strong>$web</div>
                  </p></body></head>";

      sendMessage("Colin O'Brien <cobrien@econsultingnetwork.net>", "Pages for $client have been uploaded!", $message, "melstaceecn@gmail.com, derek.coburn@econsultingnetwork.net, mwatson@eliteconsultingnetwork.net,cobrienecn@gmail.com");
      }

      }

      }


    }

  //  echo " S: ".$s;
    $sql = "UPDATE new_client SET code = '".$s."', ready = $ready WHERE id = ".$a;
    mysql_query($sql);
}




if (isset($_POST["OK"])) {

	$a = $_POST["a"];

	$c = mysql_fetch_array(mysql_query("SELECT company_id FROM new_client WHERE id = $a")) or die(mysql_error());

$c = $c["company_id"];

//@$c_word = mysql_fetch_array(mysql_query("SELECT * FROM company WHERE id = $c"));


//if (is_array($c_word)) $c_word = $c_word["companyWord"]; else $c_word = "";

	  $sql = "SELECT MAX(id) FROM new_clients_notes";
      $r   = mysql_query($sql);
      @$data = mysql_fetch_array($r);
      $id = @$data[0] + 1;

 	$sql = "INSERT INTO new_clients_notes VALUES(
 	        ".$id.",
 	        ".$a.",
 	        '".$_SESSION["Name"]."',
 	        '".time()."',
 	        '".@$_POST["note"]."'
 	        )";
 	        mysql_query($sql) or die($sql."<br>".mysql_error());


 	  $sql = "SELECT MAX(id) FROM notes";
      $r   = mysql_query($sql);
      @$data = mysql_fetch_array($r);
      $id = @$data[0] + 1;

 //	$sql = "SELECT client FROM messages WHERE id = $a";
//	$cl  = mysql_fetch_array(mysql_query($sql));
//	$cl = $cl["client"];


 	$sql = "INSERT INTO notes VALUES(
 	        ".$id.",
 	        ".$c.",
 	        '".$_SESSION["Name"]."',
 	        '".time()."',
 	        '".@$_POST["note"]."'
 	        )";
 	        mysql_query($sql) or die($sql."<br>".mysql_error());


}

if (isset($_POST["del"]))
{
  $a = $_POST["id"];
  $sql = "DELETE FROM new_client WHERE id = ".$a;
    mysql_query($sql) or die($sql."<br>".mysql_error());
    Header("Location: main.php");
}



 //print_r($data);

 $checked = $data["ready"];

 if ($checked == 1) $checked = " checked ";
    else $checked = "";

 $TITLE = "CLIENT'S PROGRESS";
   include "head.php";

 echo '<div align="center" style="width: 100%; margin-top: 20px; font-size: 25px;">'.$TITLE."</div>";


	 $sql = "SELECT * FROM new_client WHERE id = ".$a;
 $r = mysql_query($sql);
 $data = mysql_fetch_array($r);


	$sql = "SELECT * FROM company WHERE id = ".$data["company_id"];
	$r = mysql_query($sql) or die($sql."<br>".mysql_error());
	$com = mysql_fetch_array($r);

?>

 <script language="JavaScript"  src="ajax-1.js"></script>
<script language="JavaScript">

var id, value = 0;

var checkboxes_count = <?=count($arr)?>;

function showResponse12345(req){
				 //alert(req.responseText);
			}


function sendMarkRead(a)
{
new Ajax.Request("send_mark_control_read.php",
				    {
					method: 'post',
					postBody: 'a='+a+'&id=<?=@$a?>',
					onComplete: showResponse12345
					}
					);
}


function markRead(a) {

	if (a.checked) sendMarkRead(0); else sendMarkRead(1);

}



function updateWord(v) {
				new Ajax.Request("updateWord.php",
				    {
					method: 'post',
					postBody: 'a='+<?=$data["company_id"]?>+'&value='+v.value,
					onComplete: showResponse
					}
					);
				}

function showResponse(req){
				//alert(req.responseText);

			//	if ( req.responseText != "OK" ) alert(req.responseText);
			}
</script>


<script >

function checkCondition() {

n = 0;
for(i=0; i<checkboxes_count; i++)
	if ( document.getElementById(i+"").checked ) n++;

if ( n == checkboxes_count) {
	document.getElementById('go').value = "Completed";
	//document.getElementById('del').style.display = "block";
	}
	else
	{

	document.getElementById('go').value = "Save";
	//document.getElementById('del').style.display = "none";

	}

}


function YesOrNo(a)
{

	if (a.id) id = a.id; else id = a;
	YN = id.charAt(0);
	id = id.substr(1);

	tr_id = 'tr_' + (id*1 + 1);

	y = document.getElementById('Y'+id);

	n = document.getElementById('N'+id);

	t = document.getElementById(tr_id);

	if (YN == 'Y') { n.checked = false; y.checked = true; t.style.color = '#C0C0C0'; document.getElementById(id*1 + 1).style.display = 'none'; }

	if (YN == 'N') { y.checked = false; n.checked = true; t.style.color = 'black'; document.getElementById(id*1 + 1).style.display = 'block';}

}

</script>
<?
	$ccc = $data["company_id"];
	include_once "client_info.php";

?>
<form  method="POST">
<input type="hidden" name="id" value="<?=@$a?>">
 <table align="center" style="margin-top: 40px; width: 100%;" cellpadding="0"  cellspacing="0">
   <tr>
     <td align="center" ><b><?=@$com["companyName"]?></b></td>

   </tr>

     <tr>

	  	 <td align="center" style="height: 40px;" valign="bottom"> <input type="checkbox" value="1" name="read" onclick="markRead(this);" <? if (intval($data["read"]) != 1) echo ' checked '; ?>>Mark as Read</td>

     </tr>



   <tr>


   		<td align="center">

   			<form method="post">

  <input type="hidden" name="a" value="<?=@$a?>">

  <table width="420" style="border-bottom: 1px solid gray;">

     <tr>

	  	 <td align="center" style="height: 40px;" valign="bottom"> New Note</td>

     </tr>

     <tr>

 		 <td align="center"> <textarea name="note" cols="50" rows="10" style="padding: 5px;"></textarea></td>

 	 </tr>

 	 <tr>

 		 <td align="center"> <input type="submit" value="OK" name="OK" style="width: 120px;"></td>

 	 </tr>

  </table>

  <?

  $r = mysql_query("SELECT * FROM new_clients_notes WHERE new_client_id = $a ORDER BY date DESC");

  if (mysql_num_rows($r) > 0) {

  ?>

   <table width="400" cellpadding="0" cellspacing="0" id="maintable">

   <?

   while(@$dataM = mysql_fetch_array($r))
   {
   ?>

   <tr>

		<td width="80px"  height="30px">

		<strong>Date: </strong>

		</td>

		<td>

		<? echo date("m/d/Y",$dataM["date"] - 60*60)." ".date("h:i A",$dataM["date"] - 60*60); ?>

		</td>

   </tr>

    <tr >

		<td  width="80px" height="30px">

		<strong>Author: </strong>

		</td>

		<td>

		<? echo $dataM["user"]; ?>

		</td>

   </tr>

    <tr>

		<td style="border-bottom: 1px solid gray;"  width="80px" valign="top">

		<strong>Note:</strong>

		</td>

		<td  style="border-bottom: 1px solid gray; padding-bottom: 6px;">

		<? echo "<span>".$dataM["message"] ."</span><br><div id=\"none\"></div>"; ?>

		</td>


   <?
   }

   ?>


   </table>

  <? } ?>

  </form>

   		</td>

   </tr>





   <tr>

   	<td align="center" style="height: 40px;" valign="middle">  <input type="checkbox" name="ready" value="1" <?=@$checked?>> Ready for Intro Phone Call  </td>

   </tr>


     <tr>

   	<td align="center" style="height: 40px;" valign="middle"> Industry to Use for Crawler <input type="text" name="word" value="<?=@$com["companyWord"]?>" onkeyup="updateWord(this);">   </td>

   </tr>

   <?

   //  $i = 1;
   //  echo "<tr style=\"height: 30px;\"><td valign=\"bottom\" style=\"border-bottom: 1px solid black;\">New Client</td><td valign=\"bottom\" style=\"border-bottom: 1px solid black;\"><input   type=\"checkbox\" name=\"".intval($i)."\"  id=\"".intval($i)."\"></td></tr>";
   //  $i++;

// print_r($data);



     for($i = 0; $i < count($arr); $i++)
     {

   //    if ($i == 5)  echo '<tr style="height: 80px;"><td valign="middle" align="left"><b><u>Campaign Setup:</u></b></td></tr>';

       if ($i == count($arr) - 8) echo '<tr style="height: 60px;"><td valign="bottom" align="left"><b><u>Completion:</u></b></td></tr>';

    //   if ($i == 8) echo '<tr ><td style="height: 60px;" valign="bottom"><br>Check to see if the client already has listings at the following sites and if they don\'t, create them. Make sure all URLs link back to client\'s website:<br><br></td><td></td></tr>';

       if ($i >=8 && $i <= 10) $borderSize = 0;
                      else    $borderSize = 1;
       $text = $arr[$i];

       if ($text[0] == "@") {

       							 $text = substr($text, 1);

       							 if ($data["code"][intval($i)] == 1) { $checkedY = " checked "; $checkedN = " "; $script = $script."\nYesOrNo(Y".intval($i)."); "; }

       							 else { $checkedN = " checked "; $checkedY = " "; }




       							 $control = '<table border="0">

       							 				<tr>

       							 					<td valign="bottom">

       							 						Yes <input type="checkbox" '.$checkedY.' name="'.intval($i).'" id="Y'.intval($i).'" value="1" onclick="YesOrNo(this);">	</td>

       		<td style="min-width: 10px;"><div id="none"></div></td>

       			<td valign="bottom">				 						No <input '.$checkedN.'  type="checkbox" name="'.intval($i).'" id="N'.intval($i).'" value="0" onclick="YesOrNo(this);">


       							 					</td>

       							 				</tr>

       							 			</table>';



       						} else {
       						$control = "<input onclick=\"checkCondition();\"  type=\"checkbox\" value=\"1\" name=\"".intval($i)."\"  id=\"".intval($i)."\" ";


       						//echo intval($data["code"][intval($i)]);

       						if ($data["code"][intval($i)] == "1") $control=$control." checked ";

       						$control = $control.">";
       						}

       echo "<tr id=\"tr_".intval($i)."\" style=\"height: 50px;\"><td valign=\"bottom\" style=\"border-bottom: ".$borderSize."px solid black;\">".$text."</td><td valign=\"bottom\" style=\"border-bottom: ".$borderSize."px solid black;\">$control</td></tr>";

     } ?>

     <tr>
     <td align="center" colspan="2" style="height: 60px;" valign="bottom"><input id="go" type="submit" name="Go" value="Completed"></td>

   </tr>

     <tr>
     <td align="center" colspan="2" style="height: 80px;" valign="bottom"><input id="del" type="submit" name="del" value="Delete"></td>

   </tr>
 <script >

 checkCondition();

 <?=@$script?>
 </script>
 </table>
 </form>


 <? mysql_close(); ?>

Re: Checkbox is not working

Posted: Tue Jun 22, 2010 7:20 pm
by requinix
I, for one, am not going to go through all that with the brief problem description you gave. How about narrowing down what code we should look at?

Re: Checkbox is not working

Posted: Wed Jun 23, 2010 11:15 am
by olaren202
The code is below..



for($i = 0; $i < count($arr); $i++)
{

// if ($i == 5) echo '<tr style="height: 80px;"><td valign="middle" align="left"><b><u>Campaign Setup:</u></b></td></tr>';

if ($i == count($arr) - 8) echo '<tr style="height: 60px;"><td valign="bottom" align="left"><b><u>Completion:</u></b></td></tr>';

// if ($i == 8) echo '<tr ><td style="height: 60px;" valign="bottom"><br>Check to see if the client already has listings at the following sites and if they don\'t, create them. Make sure all URLs link back to client\'s website:<br><br></td><td></td></tr>';

if ($i >=8 && $i <= 10) $borderSize = 0;
else $borderSize = 1;
$text = $arr[$i];

if ($text[0] == "@") {

$text = substr($text, 1);

if ($data["code"][intval($i)] == 1) { $checkedY = " checked "; $checkedN = " "; $script = $script."\nYesOrNo(Y".intval($i)."); "; }

else { $checkedN = " checked "; $checkedY = " "; }




$control = '<table border="0">

<tr>

<td valign="bottom">

Yes <input type="checkbox" '.$checkedY.' name="'.intval($i).'" id="Y'.intval($i).'" value="1" onclick="YesOrNo(this);"> </td>

<td style="min-width: 10px;"><div id="none"></div></td>

<td valign="bottom"> No <input '.$checkedN.' type="checkbox" name="'.intval($i).'" id="N'.intval($i).'" value="0" onclick="YesOrNo(this);">


</td>

</tr>

</table>';



} else {
$control = "<input onclick=\"checkCondition();\" type=\"checkbox\" value=\"1\" name=\"".intval($i)."\" id=\"".intval($i)."\" ";


//echo intval($data["code"][intval($i)]);

if ($data["code"][intval($i)] == "1") $control=$control." checked ";

$control = $control.">";
}

echo "<tr id=\"tr_".intval($i)."\" style=\"height: 50px;\"><td valign=\"bottom\" style=\"border-bottom: ".$borderSize."px solid black;\">".$text."</td><td valign=\"bottom\" style=\"border-bottom: ".$borderSize."px solid black;\">$control</td></tr>";

} ?>