Ir para conteúdo

POWERED BY:

Arquivado

Este tópico foi arquivado e está fechado para novas respostas.

michael and cris

[Resolvido] check box

Recommended Posts

Bom eu tenho esse código aqui que pega os valores e gera um checkbox

<?php
//Conectando com o banco de dados MysQL e selecionando a base de dados.
$con=mysql_connect('xxxxxx','xxxxxxxxxx','xxxxxxxxxx')or die('Erro na conexção, verifique os dados'.mysql_error($con));
mysql_select_db('ubccriative1',$con)or die('Erro ao selecionar a tabela'.mysql_error($con));

//Verificamos se o método enviado pelo formulário é realmente o POST.
if($_SERVER['REQUEST_METHOD']=='POST'){
//Se sim, pegamos os dados em forma de vetor (array) e passamos para a variável $apagar.
  $apagar=$_POST['excluir'];
  /*Dou um loop para pegar os arrays e comparar com o valor de $i
  Aqui que está o segredo da coisam se a variável $i que inicia em 0 for menor que os dados contidos
  no array $apagar, ele vai incrementar até chegar ao valor, repetindo dentro do laço a função para deletar
  a quantidade correta de dados selecionados...
  */
  for($i=0; $i<count($apagar); $i++){
   $sql=mysql_query("INSERT INTO add_conta_pagar WHERE codigo='$apagar[$i]'")or die('Erro ao apagar os dados'.mysql_error($con));
  }
  /* verificamos com um IF simplificado se os dados foram excluídos. */
  ($sql) ? (print('Dados excluídos com êxito !')) : die('Erro ao excluir os dados.');
}
?>

 

e esse código e java script que pega os valores do check box e joga para um text area

<!--
Guarda seleção dos checkboxs
Andreia_Sp - [url="http://scriptbrasil.com.br/forum/index.php?showuser=7818"]http://scriptbrasil.com.br/forum/index.php?showuser=7818[/url]
2007
-->
<html>
<head>
<script Language="JavaScript">
function copia(campo_origem,campo_fim) {
if(campo_origem.checked)
{
	campo_fim.value += campo_origem.value + '\r\n';
}
else
{
	campo_fim.value = campo_fim.value.toString().replace(campo_origem.value,"");
	campo_fim.value = campo_fim.value.toString().replace("\r\n","");
}
}
</script> 

</head>

<body>

<input type="checkbox" name="campo_origem" value="Opção 1" size="20" onClick="copia(this,campo_fim);" >Opção 1
<br>
<input type="checkbox" name="campo_origem" value="Opção 2" size="20" onClick="copia(this,campo_fim);" >Opção 2
<br>
<input type="checkbox" name="campo_origem" value="Opção 3" size="20" onClick="copia(this,campo_fim);" >Opção 3
<br><br>
<textarea name="campo_fim" rows="5" cols="35"></textarea>


</body>
</html>

 

o que eu quero fazer e o seguinte e a mesma idéia do javascript mas quero buscar os dados no banco de dados como e no primeiro arquivo e quando eu busca ele gere o vetor do checkbox mas quando eu selecione ele mande os dados para o textarea...

 

 

vlww e socorrooo preciso da ajuda de vccccsss??????? <_<

Compartilhar este post


Link para o post
Compartilhar em outros sites

Olá,

 

O fundamento é este:

 

<?php

$Pedido = mysql_query(' ... '); // Faz o pedido

echo "<form name='nome'>";

while ($PegaValor = mysql_fetch_array($Pedido)) // Faz o laço pegando os valores
{
	echo "<input type='checkbox' name='$PegaValor[id]' value='$PegaValor[valor]' onClick='copia(this,campo_fim);'>"; // Coloca os valores num checkbox
}

echo "<textarea name='campo_fim' rows='5' cols='35'></textarea></form>";

?>

Sucesso.

Compartilhar este post


Link para o post
Compartilhar em outros sites

velho ta quase por que agora ele ta assim

<?php
//Conectando com o banco de dados MysQL e selecionando a base de dados.
$con=mysql_connect('xxxxxxxxx','uxxxxxxxxxx','crxxxxxxxxxx0')or die('Erro na conexção, verifique os dados'.mysql_error($con));
mysql_select_db('ubccriative1',$con)or die('Erro ao selecionar a tabela'.mysql_error($con));
//Varrendo a tabela dados, para pegar todos os dados.
$selecao=mysql_query("SELECT nome FROM cliente")or die('Erro na consulta SQL'.mysql_error($con));

/*Veremos se a consulta retornou algum registro com a função, mysql_num_rows...
se sim, ou seja, se for diferente de 0 o número de registros, ele tras os dados encontrados, através de um loop WHILE.
*/
if(mysql_num_rows($selecao) != 0){
/* Buscamos os dados e jogamos na função mysql_fetch_row, em que. $ver[0] o 0 reprezenta o
primeiro campo da tabela dados e o $ver[1] o 1 reprezenta o segundo campo da tabela dados
pois o PHP começa as contagens do 0... */
   while($ver=mysql_fetch_row($selecao)){
echo "<input type='checkbox' name='$selecao[nome]' value='$selecao[nome]' onClick='copia(this,campo_fim);'>"; // Coloca os valores num checkbox
   }

echo "<textarea name='campo_fim' rows='5' cols='35'></textarea></form>";
//Libramos a memória ocupada pela consulta com o free_result.
mysql_free_result($selecao);
//Fechamos a conexão com a base de dados após as operações.
mysql_close($con);
}
?>

 

o erro e o seguinte quando registro ele cria os check box mas a um probema não está vindo o nome do registro =??????????? :wacko: :wacko: :wacko: :wacko:

Compartilhar este post


Link para o post
Compartilhar em outros sites

o meu código ta assim

 

<?php
//Conectando com o banco de dados MysQL e selecionando a base de dados.
$con=mysql_connect('xxxxxxx','xxxxxxx','cxxxxxxxxx')or die('Erro na conexção, verifique os dados'.mysql_error($con));
mysql_select_db('ubccriative1',$con)or die('Erro ao selecionar a tabela'.mysql_error($con));
//Varrendo a tabela dados, para pegar todos os dados.
$selecao=mysql_query("SELECT codigo,nome_predio,nome_sindico FROM pre_predio")or die('Erro na consulta SQL'.mysql_error($con));

/*Veremos se a consulta retornou algum registro com a função, mysql_num_rows...
se sim, ou seja, se for diferente de 0 o número de registros, ele tras os dados encontrados, através de um loop WHILE.
*/
if(mysql_num_rows($selecao) != 0){
/* Buscamos os dados e jogamos na função mysql_fetch_row, em que. $ver[0] o 0 reprezenta o
primeiro campo da tabela dados e o $ver[1] o 1 reprezenta o segundo campo da tabela dados
pois o PHP começa as contagens do 0... */
   echo "<form name='nome'>";

   while($ver=mysql_fetch_row($selecao)){
   echo "<input type='checkbox' name='$ver[nome]' value='$ver[codigo]' onClick='copia(this,campo_fim);'>";
   }

   echo "<textarea name='campo_fim' rows='5' cols='35'></textarea></form>";
//Libramos a memória ocupada pela consulta com o free_result.
mysql_free_result($selecao);
//Fechamos a conexão com a base de dados após as operações.
mysql_close($con);
}
?>

ele puxa e cria os checkbox com quando dados tem mas não esta puxando o nome dos dados???

Compartilhar este post


Link para o post
Compartilhar em outros sites

Olá Michael,

 

Você tem certeza que está fazendo a coisa certa? Olha bem, eu coloquei um código como base pra você seguir o fundamento e não pra você simplesmente copiar e colar.

 

Refiz o seu código com as alterações, veja linha por linha se está correto.

 

<?php

$con = mysql_connect('xxxxxxx','xxxxxxx','cxxxxxxxxx');
mysql_select_db('ubccriative1', $con);

$selecao = mysql_query("select codigo, nome_predio, nome_sindico from pre_predio");

if (mysql_num_rows($selecao) != 0)
{
	echo "<form name='nome'>";

	while($ver = mysql_fetch_array($selecao))
	{
		echo "<input type='checkbox' name='$ver[nome_predio]' value='$ver[codigo]' onClick=\"copia(this,campo_fim);\">";
	}

   echo "<textarea name='campo_fim' rows='5' cols='35'></textarea></form>";
}

?>

Sucesso.

Compartilhar este post


Link para o post
Compartilhar em outros sites

mais uma pergunta como eu estou um array eu num deveria estar usando um foreach para os valores ?? :unsure: :unsure: :unsure: :unsure:

No select tenta colocar aspas simples na condição do WHERE, tente fazer o SELECT assim:

 

$selecao = mysql_query("SELECT * FROM cliente WHERE codigo='%s'");

E você vai precisar usar o foreach depois para filtrar os dados da checkbox.

Compartilhar este post


Link para o post
Compartilhar em outros sites

consegui arrumar o problema do nome mas ele não esta mandando o nome para o outro campo que e o text area ta ae o novo código

<?php
//Conectando com o banco de dados MysQL e selecionando a base de dados.
$con=mysql_connect('xxxxxxxxx','xxxxxxxxxx','xxxxxxxxxxxx')or die('Erro na conexção, verifique os dados'.mysql_error($con));
mysql_select_db('ubccriative1',$con)or die('Erro ao selecionar a tabela'.mysql_error($con));
//Varrendo a tabela dados, para pegar todos os dados.
$selecao=mysql_query("SELECT codigo,nome FROM cliente")or die('Erro na consulta SQL'.mysql_error($con));


if (mysql_num_rows($selecao) != 0){

	echo "<form name='nome'>";
	
	while($ver = mysql_fetch_array($selecao))
	   
	   echo "Pré cadastro do predio:  $ver[1]<input type=\"checkbox\" value=\"$ver[0]\" onClick=\"copia(this,campo_fim);\" /><br />";  
	

   echo "<textarea name='campo_fim' rows='5' cols='35'></textarea></form>";

//Libramos a memória ocupada pela consulta com o free_result.
mysql_free_result($selecao);
//Fechamos a conexão com a base de dados após as operações.
mysql_close($con);
}
?>

Compartilhar este post


Link para o post
Compartilhar em outros sites

consegui arrumar o problema do nome mas ele não esta mandando o nome para o outro campo que e o text area ta ae o novo código

<?php
//Conectando com o banco de dados MysQL e selecionando a base de dados.
$con=mysql_connect('xxxxxxxxx','xxxxxxxxxx','xxxxxxxxxxxx')or die('Erro na conexção, verifique os dados'.mysql_error($con));
mysql_select_db('ubccriative1',$con)or die('Erro ao selecionar a tabela'.mysql_error($con));
//Varrendo a tabela dados, para pegar todos os dados.
$selecao=mysql_query("SELECT codigo,nome FROM cliente")or die('Erro na consulta SQL'.mysql_error($con));


if (mysql_num_rows($selecao) != 0){

	echo "<form name='nome'>";
	
	while($ver = mysql_fetch_array($selecao))
	   
	   echo "Pré cadastro do predio:  $ver[1]<input type=\"checkbox\" value=\"$ver[0]\" onClick=\"copia(this,campo_fim);\" /><br />";  
	

   echo "<textarea name='campo_fim' rows='5' cols='35'></textarea></form>";

//Libramos a memória ocupada pela consulta com o free_result.
mysql_free_result($selecao);
//Fechamos a conexão com a base de dados após as operações.
mysql_close($con);
}
?>

Dexa eu ver se eu entendi certo o q você precisa.

você seleciona a checkbox e o valor dela é passada no textarea?!

 

Se for isso... você disse q o nome do checkbox não está aparecendo no textarea...

Se a função q você esta usando for essa:

<script Language="JavaScript">
function copia(campo_origem,campo_fim) {
if(campo_origem.checked)
{
campo_fim.value += campo_origem.value + '\r\n';
}
else
{
campo_fim.value = campo_fim.value.toString().replace(campo_origem.value,"");
campo_fim.value = campo_fim.value.toString().replace("\r\n","");
}
}
</script>

 

Só será passado o VALUE para o textarea, pois a função em javascript só esta pegando o VALUE e não o NAME do checkbox; então é só adptar a função para pegar o NAME tbm.

 

Se tiver algum link pra dar uma olhada passa ae...

Compartilhar este post


Link para o post
Compartilhar em outros sites

ae Lucas o código inteiro está aqui

<?php
mb_http_input("utf-8");
mb_http_output("utf-8");
?>
<?php require_once('Connections/data.php'); ?><?php require_once('Connections/data.php'); ?><?php
if (!isset($_SESSION)) {
  session_start();
}
$MM_authorizedUsers = "";
$MM_donotCheckaccess = "true";

// *** Restrict Access To Page: Grant or deny access to this page
function isAuthorized($strUsers, $strGroups, $UserName, $UserGroup) { 
  // For security, start by assuming the visitor is NOT authorized. 
  $isValid = False; 

  // When a visitor has logged into this site, the Session variable MM_Username set equal to their username. 
  // Therefore, we know that a user is NOT logged in if that Session variable is blank. 
  if (!empty($UserName)) { 
	// Besides being logged in, you may restrict access to only certain users based on an ID established when they login. 
	// Parse the strings into arrays. 
	$arrUsers = Explode(",", $strUsers); 
	$arrGroups = Explode(",", $strGroups); 
	if (in_array($UserName, $arrUsers)) { 
	  $isValid = true; 
	} 
	// Or, you may restrict access to only certain users based on their username. 
	if (in_array($UserGroup, $arrGroups)) { 
	  $isValid = true; 
	} 
	if (($strUsers == "") && true) { 
	  $isValid = true; 
	} 
  } 
  return $isValid; 
}

$MM_restrictGoTo = "index.php";
if (!((isset($_SESSION['MM_Username'])) && (isAuthorized("",$MM_authorizedUsers, $_SESSION['MM_Username'], $_SESSION['MM_UserGroup'])))) {   
  $MM_qsChar = "?";
  $MM_referrer = $_SERVER['PHP_SELF'];
  if (strpos($MM_restrictGoTo, "?")) $MM_qsChar = "&";
  if (isset($QUERY_STRING) && strlen($QUERY_STRING) > 0) 
  $MM_referrer .= "?" . $QUERY_STRING;
  $MM_restrictGoTo = $MM_restrictGoTo. $MM_qsChar . "accesscheck=" . urlencode($MM_referrer);
  header("Location: ". $MM_restrictGoTo); 
  exit;
}
?>
<?php
if (!function_exists("GetSQLValueString")) {
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "") 
{
  $theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;

  $theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);

  switch ($theType) {
	case "text":
	  $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
	  break;	
	case "long":
	case "int":
	  $theValue = ($theValue != "") ? intval($theValue) : "NULL";
	  break;
	case "double":
	  $theValue = ($theValue != "") ? "'" . doubleval($theValue) . "'" : "NULL";
	  break;
	case "date":
	  $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
	  break;
	case "defined":
	  $theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
	  break;
  }
  return $theValue;
}
}

$editFormAction = $_SERVER['PHP_SELF'];
if (isset($_SERVER['QUERY_STRING'])) {
  $editFormAction .= "?" . htmlentities($_SERVER['QUERY_STRING']);
}

if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "form1")) {
  $insertSQL = sprintf("INSERT INTO add_conta_receber (Funcionario, Cliente, descricao, pago, pago1, pago2, pago3, pago4, pago5, pago6, pago7, pago8, pago9, pago10, predio, valor_d, valor_e, valor_f, valor_g, valor_h, valor_i, valor_j, valor_telefone, valor_l, valor_m, parcela_n, parcela_o, parcela_p, valor_a, parcela_q, parcela_r, parcela_m, parcela_s, parcela_l, parcela_t, parcela_u, parcela_cnpj, parcela_banco, valor_b, valor_c, insc_estadual, data_contrato, custo_criacao, valor, lancamento, documento, Hora_Entrada) VALUES (%s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s)",
					   GetSQLValueString($_POST['Funcionario'], "text"),
					   GetSQLValueString($_POST['Cliente'], "text"),
					   GetSQLValueString($_POST['descricao'], "text"),
					   GetSQLValueString($_POST['predio'], "text"),
					   GetSQLValueString($_POST['pago'], "text"),
					   GetSQLValueString($_POST['pago1'], "text"),
					   GetSQLValueString($_POST['pago2'], "text"),
					   GetSQLValueString($_POST['pago3'], "text"),
					   GetSQLValueString($_POST['pago4'], "text"),
					   GetSQLValueString($_POST['pago5'], "text"),
					   GetSQLValueString($_POST['pago6'], "text"),
					   GetSQLValueString($_POST['pago7'], "text"),
					   GetSQLValueString($_POST['pago8'], "text"),
					   GetSQLValueString($_POST['pago9'], "text"),
					   GetSQLValueString($_POST['pago10'], "text"),
					   GetSQLValueString($_POST['valor_d'], "text"),
					   GetSQLValueString($_POST['valor_a'], "text"),
					   GetSQLValueString($_POST['valor_e'], "text"),
					   GetSQLValueString($_POST['valor_f'], "text"),
					   GetSQLValueString($_POST['valor_g'], "text"),
					   GetSQLValueString($_POST['valor_h'], "text"),
					   GetSQLValueString($_POST['valor_i'], "text"),
					   GetSQLValueString($_POST['valor_j'], "text"),
					   GetSQLValueString($_POST['valor_telefone'], "text"),
					   GetSQLValueString($_POST['valor_l'], "text"),
					   GetSQLValueString($_POST['valor_m'], "text"),
					   GetSQLValueString($_POST['parcela_n'], "text"),
					   GetSQLValueString($_POST['parcela_m'], "text"),
					   GetSQLValueString($_POST['parcela_o'], "text"),
					   GetSQLValueString($_POST['parcela_p'], "text"),
					   GetSQLValueString($_POST['parcela_l'], "text"),
					   GetSQLValueString($_POST['parcela_q'], "text"),
					   GetSQLValueString($_POST['parcela_r'], "text"),
					   GetSQLValueString($_POST['parcela_s'], "text"),
					   GetSQLValueString($_POST['parcela_t'], "text"),
					   GetSQLValueString($_POST['parcela_u'], "text"),
					   GetSQLValueString($_POST['parcela_cnpj'], "text"),
					   GetSQLValueString($_POST['parcela_banco'], "text"),
					   GetSQLValueString($_POST['valor_b'], "text"),
					   GetSQLValueString($_POST['valor_c'], "text"),
					   GetSQLValueString($_POST['insc_estadual'], "text"),
					   GetSQLValueString($_POST['data_contrato'], "text"),
					   GetSQLValueString($_POST['custo_criacao'], "text"),
					   GetSQLValueString($_POST['valor'], "text"),
					   GetSQLValueString($_POST['lancamento'], "text"),
					   GetSQLValueString($_POST['documento'], "text"),
					   GetSQLValueString($_POST['Hora_Entrada'], "text"));
  mysql_select_db($database_data, $data);
  $Result1 = mysql_query($insertSQL, $data) or die(mysql_error());

  $insertGoTo = "impressao_anunc.php";
  if (isset($_SERVER['QUERY_STRING'])) {
	$insertGoTo .= (strpos($insertGoTo, '?')) ? "&" : "?";
	$insertGoTo .= $_SERVER['QUERY_STRING'];
  }
  header(sprintf("Location: %s", $insertGoTo));
}

if (!function_exists("GetSQLValueString")) {
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "") 
{
  $theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;

  $theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);

  switch ($theType) {
	case "text":
	  $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
	  break;	
	case "long":
	case "int":
	  $theValue = ($theValue != "") ? intval($theValue) : "NULL";
	  break;
	case "double":
	  $theValue = ($theValue != "") ? "'" . doubleval($theValue) . "'" : "NULL";
	  break;
	case "date":
	  $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
	  break;
	case "defined":
	  $theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
	  break;
  }
  return $theValue;
}
}

$maxRows_DetailRS1 = 10;
$pageNum_DetailRS1 = 0;
if (isset($_GET['pageNum_DetailRS1'])) {
  $pageNum_DetailRS1 = $_GET['pageNum_DetailRS1'];
}
$startRow_DetailRS1 = $pageNum_DetailRS1 * $maxRows_DetailRS1;

$colname_DetailRS1 = "-1";
if (isset($_GET['recordID'])) {
  $colname_DetailRS1 = $_GET['recordID'];
}
mysql_select_db($database_data, $data);
$query_DetailRS1 = sprintf("SELECT * FROM anunciante WHERE codigo = %s", GetSQLValueString($colname_DetailRS1, "int"));
$query_limit_DetailRS1 = sprintf("%s LIMIT %d, %d", $query_DetailRS1, $startRow_DetailRS1, $maxRows_DetailRS1);
$DetailRS1 = mysql_query($query_limit_DetailRS1, $data) or die(mysql_error());
$row_DetailRS1 = mysql_fetch_assoc($DetailRS1);

if (isset($_GET['totalRows_DetailRS1'])) {
  $totalRows_DetailRS1 = $_GET['totalRows_DetailRS1'];
} else {
  $all_DetailRS1 = mysql_query($query_DetailRS1);
  $totalRows_DetailRS1 = mysql_num_rows($all_DetailRS1);
}
$totalPages_DetailRS1 = ceil($totalRows_DetailRS1/$maxRows_DetailRS1)-1;
?>
<!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">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Lançamentos de contas a receber</title>
<script src="SpryAssets/SpryEffects.js" type="text/javascript"></script>
<script type=text/javascript>
documentall = document.all;
/*
* função para formatação de valores monetários retirada de
* [url="http://jonasgalvez.com/br/blog/2003-08/egocentrismo"]http://jonasgalvez.com/br/blog/2003-08/egocentrismo[/url]
*/

function formatamoney© {
	var t = this; if(c == undefined) c = 2;
	var p, d = (t=t.split("."))[1].substr(0, c);
	for(p = (t=t[0]).length; (p-=3) >= 1;) {
			t = t.substr(0,p) + "." + t.substr(p);
	}
	return t+"."+d+Array(c+1-d.length).join(0);
}

String.prototype.formatCurrency=formatamoney

function demaskvalue(valor, currency){
/*
* Se currency é false, retorna o valor sem apenas com os números. Se é true, os dois últimos caracteres são considerados as
* casas decimais
*/
var val2 = '';
var strCheck = '0123456789';
var len = valor.length;
	if (len== 0){
		return 0.00;
	}

	if (currency ==true){
		/* Elimina os zeros à esquerda
		* a variável  <i> passa a ser a localização do primeiro caractere após os zeros e
		* val2 contém os caracteres (descontando os zeros à esquerda)
		*/

		for(var i = 0; i < len; i++)
			if ((valor.charAt(i) != '0') && (valor.charAt(i) != ',')) break;

		for(; i < len; i++){
			if (strCheck.indexOf(valor.charAt(i))!=-1) val2+= valor.charAt(i);
		}

		if(val2.length==0) return "0.00";
		if (val2.length==1)return "0.0" + val2;
		if (val2.length==2)return "0." + val2;

		var parte1 = val2.substring(0,val2.length-2);
		var parte2 = val2.substring(val2.length-2);
		var returnvalue = parte1 + "." + parte2;
		return returnvalue;

	}
	else{
			/* currency é false: retornamos os valores COM os zeros à esquerda,
			* sem considerar os últimos 2 algarismos como casas decimais
			*/
			val3 ="";
			for(var k=0; k < len; k++){
				if (strCheck.indexOf(valor.charAt(k))!=-1) val3+= valor.charAt(k);
			}
	return val3;
	}
}

function reais(obj,event){

var whichCode = (window.Event) ? event.which : event.keyCode;
/*
Executa a formatação após o backspace nos navegadores !document.all
*/
if (whichCode == 8 && !documentall) {
/*
Previne a ação padrão nos navegadores
*/
	if (event.preventDefault){ //standart browsers
			event.preventDefault();
		}else{ // internet explorer
			event.returnValue = false;
	}
	var valor = obj.value;
	var x = valor.substring(0,valor.length-1);
	obj.value= demaskvalue(x,true).formatCurrency();
	return false;
}
/*
Executa o Formata Reais e faz o format currency novamente após o backspace
*/
FormataReais(obj,'.',',',event);
} // end reais


function backspace(obj,event){
/*
Essa função basicamente altera o  backspace nos input com máscara reais para os navegadores IE e opera.
O IE não detecta o keycode 8 no evento keypress, por isso, tratamos no keydown.
Como o opera suporta o infame document.all, tratamos dele na mesma parte do código.
*/

var whichCode = (window.Event) ? event.which : event.keyCode;
if (whichCode == 8 && documentall) {
	var valor = obj.value;
	var x = valor.substring(0,valor.length-1);
	var y = demaskvalue(x,true).formatCurrency();

	obj.value =""; //necessário para o opera
	obj.value += y;

	if (event.preventDefault){ //standart browsers
			event.preventDefault();
		}else{ // internet explorer
			event.returnValue = false;
	}
	return false;

	}// end if
}// end backspace

function FormataReais(fld, milSep, decSep, e) {
var sep = 0;
var key = '';
var i = j = 0;
var len = len2 = 0;
var strCheck = '0123456789';
var aux = aux2 = '';
var whichCode = (window.Event) ? e.which : e.keyCode;

//if (whichCode == 8 ) return true; //backspace - estamos tratando disso em outra função no keydown
if (whichCode == 0 ) return true;
if (whichCode == 9 ) return true; //tecla tab
if (whichCode == 13) return true; //tecla enter
if (whichCode == 16) return true; //shift internet explorer
if (whichCode == 17) return true; //control no internet explorer
if (whichCode == 27 ) return true; //tecla esc
if (whichCode == 34 ) return true; //tecla end
if (whichCode == 35 ) return true;//tecla end
if (whichCode == 36 ) return true; //tecla home

/*
O trecho abaixo previne a ação padrão nos navegadores. Não estamos inserindo o caractere normalmente, mas via script
*/

if (e.preventDefault){ //standart browsers
		e.preventDefault()
	}else{ // internet explorer
		e.returnValue = false
}

var key = String.fromCharCode(whichCode);  // Valor para o código da Chave
if (strCheck.indexOf(key) == -1) return false;  // Chave inválida

/*
Concatenamos ao value o keycode de key, se esse for um número
*/
fld.value += key;

var len = fld.value.length;
var bodeaux = demaskvalue(fld.value,true).formatCurrency();
fld.value=bodeaux;

/*
Essa parte da função tão somente move o cursor para o final no opera. Atualmente não existe como movê-lo no konqueror.
*/
  if (fld.createTextRange) {
	var range = fld.createTextRange();
	range.collapse(false);
	range.select();
  }
  else if (fld.setSelectionRange) {
	fld.focus();
	var length = fld.value.length;
	fld.setSelectionRange(length, length);
  }
  return false;

}
</SCRIPT>
<link href="css/style.css" rel="stylesheet" type="text/css" />
<script>

function formatar(src, mask)
{
  var i = src.value.length;
  var saida = mask.substring(0,1);
  var texto = mask.substring(i)
if (texto.substring(0,1) != saida)
  {
		src.value += texto.substring(0,1);
  }
}

</script>
<script language="JavaScript">
<!--
function muda(qual)
{
uCase = qual.value.toUpperCase();
qual.value = uCase;
}
function MM_effectAppearFade(targetElement, duration, from, to, toggle)
{
	Spry.Effect.DoFade(targetElement, {duration: duration, from: from, to: to, toggle: toggle});
}
//-->
</script>
<style type="text/css">
<!--
.style1 {
	font-size: 16px;
	font-weight: bold;
}
-->
</style>
</script>
</head>

<body>
<table width="84%" border="0" cellpadding="0" cellspacing=" 0">
  <tr>
	<td width="48"><div align="center"><img src="Imagens/998_128x128.png" alt="" width="48" height="48" /></div></td>
	<td width="640"><b><span class="style7">Contas a receber </span></b></td>
	<td width="450"><b><b><b> <img src="Imagens/4435_128x128.png" width="48" height="48" /><a href="fechar.php" target="_self">Fechar Janela</a></b></b></b></td>
  </tr>
  <tr>
	<td> </td>
	<td colspan="2"><table border="0" cellspacing="3" cellpadding="0" class="verdana" width="1218" >
	  <form action="<?php echo $editFormAction; ?>" method="POST" name="form1" id="form1">
		<tr>
		  <td height="40" colspan="3" valign="top"><table width="100%" border="0" cellspacing="0" cellpadding="0">
			<tr>
			  <td width="473" valign="top"><b>Usuário que está cadastrando:<br />
						  <input name="Funcionario" type="text" id="Funcionario" value="<?php echo $_SESSION['MM_Username']; ?>" />
						  <br />
			  </b></td>
			  <td width="739" valign="top"><b>Anunciante:</b><br />
				<input name="Cliente" type="text" id="Cliente" value="<?php echo $row_DetailRS1['nome']; ?>" onkeyup="muda(this)"/>
				<br /></td>
			</tr>
			
			
			
		  </table></td>
		</tr>
		<tr>
		  <td colspan="3"><table width="100%" border="0" cellspacing=" 0" cellpadding="0">
			<tr>
			  <td width="39%"><p><b>Valor Total: <br />
					<input name="valor" type="text" id="valor" onblur="alert('Você ditou o valor correto? Confira pois você não podera apagar')" value="<?php echo $row_DetailRS1['email']; ?>" size="23" maxlength="30" />
			  </b></p>				</td>
		  <td width="30%"><b>CNPJ: <br />
			  <input name="valor2" type="text" id="valor2" onblur="alert('Você ditou o valor correto? Confira pois você não podera apagar')" value="<?php echo $row_DetailRS1['valor_b']; ?>" size="23" maxlength="30" />
		  </b></td>
			  <td width="31%"><b>O tipo da Venda: <br />
				  <input name="valor3" type="text" id="valor3" onblur="alert('Você ditou o valor correto? Confira pois você não podera apagar')" value="<?php echo $row_DetailRS1['valor_c']; ?>" size="23" maxlength="30" />
			  </b></td>
			</tr>
		  </table></td>
		</tr>
		<tr>
		  <td width="470"><p><b>Hora 
				Entrada:
				<input name="Hora_Entrada" type="text" class="select" id="Hora_Entrada" onkeypress="formatar(this, '##:##')" size="7" maxlength="5" />
		  </b></p>			</td>
		  <td width="361"><label><b>Tipo do Lançamento:<br />
				<select name="lancamento" class="select" id="lancamento">
				  <option value="crédito">Crédito</option>
				  <option value="Débito">Débito</option>
			  </select>
		  </b></label></td>
		  <td width="375"><b>Pacote: <br />
			  <input name="valor4" type="text" id="valor4" onblur="alert('Você ditou o valor correto? Confira pois você não podera apagar')" value="<?php echo $row_DetailRS1['insc_estadual']; ?>" size="23" maxlength="30" />
		  </b></td>
		</tr>
		<tr>
		  <td height="35"><p><b>Descrição: <br />
				<input name="descricao" type="text" class="select" id="descricao" onkeyup="muda(this)" size="23"/>
		  </b></p>			</td>
		  <td height="35"><b>Forma de pagamento: <br />
			  <input name="valor5" type="text" id="valor5" onblur="alert('Você ditou o valor correto? Confira pois você não podera apagar')" value="<?php echo $row_DetailRS1['data_contrato']; ?>" size="23" maxlength="30" />
		  </b></td>
		  <td height="35"> </td>
		</tr>
		<tr>
		  <td colspan="3"><table width="100%" border="0" cellspacing="0" cellpadding="0">
			<tr>
			  <td width="39%" height="90"><script><p align="center" onclick="MM_effectAppearFade('valor', 1000, 100, 0, false)">
</script>
<?php
//Conectando com o banco de dados MysQL e selecionando a base de dados.
$con=mysql_connect('xxxxxxxxxx','xxxxxxxxx','xxxxxxxxxxx')or die('Erro na conexção, verifique os dados'.mysql_error($con));
mysql_select_db('ubccriative1',$con)or die('Erro ao selecionar a tabela'.mysql_error($con));
//Varrendo a tabela dados, para pegar todos os dados.
$selecao=mysql_query("SELECT codigo,nome FROM cliente")or die('Erro na consulta SQL'.mysql_error($con));

if (mysql_num_rows($selecao) != 0)
{
	echo "<form name='nome'>";

	while($ver = mysql_fetch_array($selecao))
	{
		echo "$ver[1]<input type=\"checkbox\" value=\"$ver[0]\" onClick=\"copia(this,campo_fim);\">";
	}

   echo "<textarea name='campo_fim' rows='3' cols='20'></textarea></form>";
}

?><br />
			  </p></td>
			  <td width="30%"><b>Documento<br />
				  <input name="documento" type="text" class="select" id="documento" onkeyup="muda(this)" value="<?php echo $row_Recordset1['cnpj']; ?>" size="23"/>
			  </b></td>
			  <td width="31%"><b>Banco: <br />
				  <input name="valor6" type="text" id="valor6" onblur="alert('Você ditou o valor correto? Confira pois você não podera apagar')" value="<?php echo $row_DetailRS1['custo_criacao']; ?>" size="23" maxlength="30" />
			  </b></td>
			</tr>
		  </table></td>
		</tr>
		<tr>
		  <td colspan="3"><table width="100%" border="0" cellspacing="0" cellpadding="0">
			<tr>
			  <td width="31%" colspan="2"><p><b><label></label>
</b><b><br />
	</b></p>  </td>
			  <td width="30%"> </td>
			</tr>
			<tr>
			  <td colspan="2"><div align="center" class="style1">Valores</div></td>
			  <td width="30%"><div align="center" class="style1">Vencimento</div></td>
			</tr>
			<tr>
			  <td height="6" align="center" class="verdana"><font color="#666666"><strong>valor(1):</strong><b>
				<input name="valor_a" type="text" class="select" id="valor_a" value="<?php echo $row_DetailRS1['parcela_o']; ?>" size="9" maxlength="10"/>
			  </b></font></td>
			  <td align="center" class="verdana"><font color="#666666"><b>
				a pagar
				<input name="pago" type="text" class="select" id="pago" value="<?php echo $row_DetailRS1['valor_d']; ?>" size="9" maxlength="10"/>
			  </b></font></td>
			  <td height="6" align="center" class="verdana"><font color="#666666"><strong>Vencimento:</strong><b>
				<input name="parcela_l" type="text" class="select" id="parcela_l" onkeypress="formatar(this, '##/##/####')" value="<?php echo $row_DetailRS1['situacao']; ?>" size="12" maxlength="10"/>
			  </b></font></td>
			  </tr>
			<tr>
			  <td height="6" align="center" class="verdana"><font color="#666666"><strong>valor(2):</strong><b>
				<input name="valor_b" type="text" class="select" id="valor_b" value="<?php echo $row_DetailRS1['parcela_p']; ?>" size="9" maxlength="10"/>
			  </b></font></td>
			  <td height="6" align="center" class="verdana"><font color="#666666"><b>a pagar
					<input name="pago1" type="text" class="select" id="pago1" value="<?php echo $row_DetailRS1['valor_f']; ?>" size="9" maxlength="10"/>
			  </b></font></td>
			  <td height="6" align="center" class="verdana"><font color="#666666"><strong>Vencimento:</strong><b>
				<input name="parcela_m" type="text" class="select" id="parcela_m" onkeypress="formatar(this, '##/##/####')" value="<?php echo $row_DetailRS1['pago']; ?>" size="12" maxlength="10"/>
			  </b></font></td>
			  </tr>
			<tr>
			  <td height="6" align="center" class="verdana"><font color="#666666"><strong>valor(3):</strong><b>
				<input name="valor_c" type="text" class="select" id="valor_c" value="<?php echo $row_DetailRS1['parcela_q']; ?>" size="9" maxlength="10"/>
			  </b></font></td>
			  <td height="6" align="center" class="verdana"><font color="#666666"><b>a pagar
					<input name="pago2" type="text" class="select" id="pago2" value="<?php echo $row_DetailRS1['valor_g']; ?>" size="9" maxlength="10"/>
			  </b></font></td>
			  <td height="6" align="center" class="verdana"><font color="#666666"><strong>Vencimento:</strong><b>
				<input name="parcela_n" type="text" class="select" id="parcela_n" onkeypress="formatar(this, '##/##/####')" value="<?php echo $row_DetailRS1['pago1']; ?>" size="12" maxlength="10"/>
			  </b></font></td>
			  </tr>
			<tr>
			  <td height="2" align="center" class="verdana"><font color="#666666"><strong>valor(4):</strong><b>
				<input name="valor_d" type="text" class="select" id="valor_d" value="<?php echo $row_DetailRS1['parcela_r']; ?>" size="9" maxlength="10"/>
			  </b></font></td>
			  <td height="2" align="center" class="verdana"><font color="#666666"><b>a pagar
					<input name="pago3" type="text" class="select" id="pago3" value="<?php echo $row_DetailRS1['valor_h']; ?>" size="9" maxlength="10"/>
			  </b></font></td>
			  <td height="2" align="center" class="verdana"><font color="#666666"><strong>Vencimento:</strong><b>
				<input name="parcela_o" type="text" class="select" id="parcela_o" onkeypress="formatar(this, '##/##/####')" value="<?php echo $row_DetailRS1['pago2']; ?>" size="12" maxlength="10"/>
			  </b></font></td>
			  </tr>
			<tr>
			  <td height="0" align="center" class="verdana"><font color="#666666"><strong>valor(5):</strong><b>
				<input name="valor_e" type="text" class="select" id="valor_e" value="<?php echo $row_DetailRS1['parcela_s']; ?>" size="9" maxlength="10"/>
			  </b></font></td>
			  <td height="0" align="center" class="verdana"><font color="#666666"><b>a pagar
					<input name="pago4" type="text" class="select" id="pago4" value="<?php echo $row_DetailRS1['valor_i']; ?>" size="9" maxlength="10"/>
			  </b></font></td>
			  <td height="0" align="center" class="verdana"><font color="#666666"><strong>Vencimento:</strong><b>
				<input name="parcela_p" type="text" class="select" id="parcela_p" onkeypress="formatar(this, '##/##/####')" value="<?php echo $row_DetailRS1['pago3']; ?>" size="12" maxlength="10"/>
			  </b></font></td>
			  </tr>
			<tr>
			  <td height="-1" align="center" class="verdana"><font color="#666666"><strong>valor(6):</strong><b>
				<input name="valor_f" type="text" class="select" id="valor_f" value="<?php echo $row_DetailRS1['parcela_t']; ?>" size="9" maxlength="10"/>
			  </b></font></td>
			  <td height="-1" align="center" class="verdana"><font color="#666666"><b>a pagar
					<input name="pago5" type="text" class="select" id="pago5" value="<?php echo $row_DetailRS1['valor_j']; ?>" size="9" maxlength="10"/>
			  </b></font></td>
			  <td height="-1" align="center" class="verdana"><font color="#666666"><strong>Vencimento:</strong><b>
				<input name="parcela_q" type="text" class="select" id="parcela_q" value="<?php echo $row_DetailRS1['pago4']; ?>" size="12" maxlength="10"/>
			  </b></font></td>
			  </tr>
			<tr>
			  <td height="-1" align="center" class="verdana"><font color="#666666"><strong>valor(7):</strong><b>
				<input name="valor_g" type="text" class="select" id="valor_g" value="<?php echo $row_DetailRS1['parcela_u']; ?>" size="9" maxlength="10"/>
			  </b></font></td>
			  <td height="-1" align="center" class="verdana"><font color="#666666"><b>a pagar
					<input name="pago6" type="text" class="select" id="pago6" value="<?php echo $row_DetailRS1['parcela_l']; ?>" size="9" maxlength="10"/>
			  </b></font></td>
			  <td height="-1" align="center" class="verdana"><font color="#666666"><strong>Vencimento:</strong><b>
				<input name="parcela_r" type="text" class="select" id="parcela_r" value="<?php echo $row_DetailRS1['pago5']; ?>" size="12" maxlength="10"/>
			  </b></font></td>
			  </tr>
			<tr>
			  <td height="-2" align="center" class="verdana"><font color="#666666"><strong>valor(8):</strong><b>
				<input name="valor_h" type="text" class="select" id="valor_h" value="<?php echo $row_DetailRS1['cnpj']; ?>" size="9" maxlength="10"/>
			  </b></font></td>
			  <td height="-2" align="center" class="verdana"><font color="#666666"><b>a pagar
					<input name="pago7" type="text" class="select" id="pago7" value="<?php echo $row_DetailRS1['parcela_m']; ?>" size="9" maxlength="10"/>
			  </b></font></td>
			  <td height="-2" align="center" class="verdana"><font color="#666666"><strong>Vencimento:</strong><b>
				<input name="parcela_s" type="text" class="select" id="parcela_s" value="<?php echo $row_DetailRS1['pago6']; ?>" size="12" maxlength="10"/>
			  </b></font></td>
			  </tr>
			<tr>
			  <td height="-2" align="center" class="verdana"><font color="#666666"><strong>valor(9):</strong><b>
				<input name="valor_i" type="text" class="select" id="valor_i" value="<?php echo $row_DetailRS1['banco']; ?>" size="9" maxlength="10"/>
			  </b></font></td>
			  <td height="-2" align="center" class="verdana"><font color="#666666"><b>a pagar
					<input name="pago8" type="text" class="select" id="pago8" value="<?php echo $row_DetailRS1['parcela_n']; ?>" size="9" maxlength="10"/>
			  </b></font></td>
			  <td height="-2" align="center" class="verdana"><font color="#666666"><strong>Vencimento:</strong><b>
				<input name="parcela_t" type="text" class="select" id="parcela_t" value="<?php echo $row_DetailRS1['pago7']; ?>" size="12" maxlength="10"/>
			  </b></font></td>
			  </tr>
			<tr>
			  <td height="28" align="center" class="verdana"><font color="#666666"><strong>valor(10):</strong><b>
				<input name="valor_j" type="text" class="select" id="valor_j" value="<?php echo $row_DetailRS1['forma_pagamento']; ?>" size="8" maxlength="10"/>
			  </b></font></td>
			  <td height="28" align="center" class="verdana"><font color="#666666"><b>a pagar
					<input name="pago10" type="text" class="select" id="pago10" value="<?php echo $row_DetailRS1['telefone']; ?>" size="9" maxlength="10"/>
			  </b></font></td>
			  <td height="28" align="center" class="verdana"><font color="#666666"><strong>Vencimento:</strong><b>
				<input name="parcela_u" type="text" class="select" id="parcela_u" value="<?php echo $row_DetailRS1['pago8']; ?>" size="12" maxlength="10"/>
			  </b></font></td>
			  </tr>
		  </table></td>
		</tr>
		
		<tr align="right">
		  <td height="16">
			<div align="left"><?
setlocale(LC_TIME,"portuguese");
echo strftime("Hoje é %A, %d de %B de %Y");
?></div></td>
		  <td height="16" colspan="2">			
			<div align="left">
			  <input type="submit" name="button" id="button" value=" Efetuar Cadastror") />
			  <input type="reset" name="button2" id="button2" value="Limpar Cadastro" />
			  </div></td>
		</tr>
		
		<input type="hidden" name="MM_insert" value="form1" />
	  </form>
	</table></td>
  </tr>
</table>
<table width="200" border="0" align="center">
  <tr>
	<th scope="col"> </th>
  </tr>
</table>
<p> </p>
<p> </p>
<p> </p>
<table width="1362" border="0">
<tr>
  <td><div align="center">
</body>
</html>
<?php
mysql_free_result($DetailRS1);
?>

Lucas to quase lá agora ele manda para dentro do textarea , mas esta indo números esse números são os id???

Compartilhar este post


Link para o post
Compartilhar em outros sites

Desculpa ao moderadores do fórum mas até quem fim eu consegui a galera vlw ae quem me ajudo principalmente ao Lucas e vw também kimura vou posta o código aqui

 

Esse e da função javascript

 

<script Language="JavaScript">
function copia(nome,campo_fim) {
if(nome.checked)
{
campo_fim.value += nome.value + '\r\n';
}
else
{
campo_fim.value = campo_fim.value.toString().replace(nome.value,"");
campo_fim.value = campo_fim.value.toString().replace("\r\n","");
}
}
</script>

esse aqui e o do php

 

<?php
//Conectando com o banco de dados MysQL e selecionando a base de dados.
$con=mysql_connect('xxxxxxxxx','xxxxxxxxxx','xxxxxxxxxxx')or die('Erro na conexção, verifique os dados'.mysql_error($con));
mysql_select_db('ubccriative1',$con)or die('Erro ao selecionar a tabela'.mysql_error($con));
//Varrendo a tabela dados, para pegar todos os dados.
$selecao=mysql_query("SELECT codigo,nome FROM cliente")or die('Erro na consulta SQL'.mysql_error($con));

if (mysql_num_rows($selecao) != 0)
{
	echo "<form name='nome'>";

	while($ver = mysql_fetch_array($selecao))
	{
		echo "$ver[1]<input type=\"checkbox\" value=\"$ver[1]\" onClick=\"copia(this,campo_fim);\">";
	}

   echo "<textarea name='campo_fim' rows='3' cols='20'></textarea></form>";
}

?>

 

http://forum.imasters.com.br/public/style_emoticons/default/clap.gif http://forum.imasters.com.br/public/style_emoticons/default/clap.gif http://forum.imasters.com.br/public/style_emoticons/default/clap.gif http://forum.imasters.com.br/public/style_emoticons/default/clap.gif http://forum.imasters.com.br/public/style_emoticons/default/clap.gif http://forum.imasters.com.br/public/style_emoticons/default/clap.gif http://forum.imasters.com.br/public/style_emoticons/default/clap.gif http://forum.imasters.com.br/public/style_emoticons/default/clap.gif http://forum.imasters.com.br/public/style_emoticons/default/clap.gif http://forum.imasters.com.br/public/style_emoticons/default/clap.gif http://forum.imasters.com.br/public/style_emoticons/default/clap.gif

Compartilhar este post


Link para o post
Compartilhar em outros sites

×

Informação importante

Ao usar o fórum, você concorda com nossos Termos e condições.