Mais uma vez eu aqui!!!!
Não estou sabendo relacionar uma função javascript com o codigo html. No meu código possuo vários forms com ids do tipo myform[0], myform[1], myform[2],....Queria saber como colocar esses valores no meu código javascript, já que o submit desses códigos e com essa linguagem.
o código dos forms é esse.
[codebox]<TABLE cellpadding="2" cellspacing="0" width="100%" class="bordasimples">
<TR>
<TD class="titulo" width="35%">Nome</TD>
<TD class="titulo" width="15%">CPF</TD>
<TD class="titulo" width="25%">Filiação(mãe)</TD>
<TD class="titulo" width="15%">Nascimento</TD>
</TR>
<form id="myform[0]" method = "POST" action = "ficha.php">
<TR class="linhac" onclick="formSubmit()" onmouseover="this.className='linhac2'" onmouseout="this.className='linhac'">
<TD align="left">Roberto</TD>
<TD align="center">1452789525</TD>
<TD align="left">Maria5</TD>
<TD align="left">0000-00-00</TD>
<input type = 'hidden' name = 'id' value = "13"></TR>
</form>
<form id="myform[1]" method = "POST" action = "paciente_ficha.php">
<TR class="linhacalt" onclick="formSubmit()" onmouseover="this.className='linhac2'" onmouseout="this.className='linhacalt'">
<TD align="left">Amanda Pereira</TD>
<TD align="center">6543345676</TD>
<TD align="left">Socorro Almeida</TD>
<TD align="left">2007-04-26</TD>
<input type = 'hidden' name = 'id' value = "19"></TR>
</form>
<form id="myform[2]" method = "POST" action = "paciente_ficha.php">
<TR class="linhac" onclick="formSubmit()" onmouseover="this.className='linhac2'" onmouseout="this.className='linhac'">
<TD align="left">Amanda Pereira</TD>
<TD align="center">6543345676</TD>
<TD align="left">Socorro Almeida</TD>
<TD align="left">2007-04-26</TD>
<input type = 'hidden' name = 'id' value = "17"></TR>
</form>
<form id="myform[3]" method = "POST" action = "paciente_ficha.php">
<TR class="linhacalt" onclick="formSubmit()" onmouseover="this.className='linhac2'" onmouseout="this.className='linhacalt'">
<TD align="left">Camila Pererira</TD>
<TD align="center">7687688</TD>
<TD align="left">Carolina Lima</TD>
<TD align="left">2007-04-25</TD>
<input type = 'hidden' name = 'id' value = "23"></TR>
</form>
<form id="myform[4]" method = "POST" action = "paciente_ficha.php">
<TR class="linhac" onclick="formSubmit()" onmouseover="this.className='linhac2'" onmouseout="this.className='linhac'">
<TD align="left">Carlos Nascimento Pereira</TD>
<TD align="center">017454853-25</TD>
<TD align="left">Carla</TD>
<TD align="left">2005-01-01</TD>
<input type = 'hidden' name = 'id' value = "9"></TR>
</form>
<form id="myform[5]" method = "POST" action = "paciente_ficha.php">
<TR class="linhacalt" onclick="formSubmit()" onmouseover="this.className='linhac2'" onmouseout="this.className='linhacalt'">
<TD align="left">Creuza Maria</TD>
<TD align="center">989766565</TD>
<TD align="left">Maria Creuza</TD>
<TD align="left">2007-04-19</TD>
<input type = 'hidden' name = 'id' value = "18"></TR>
</form>
<form id="myform[6]" method = "POST" action = "paciente_ficha.php">
<TR class="linhac" onclick="formSubmit()" onmouseover="this.className='linhac2'" onmouseout="this.className='linhac'">
<TD align="left">Creuza Maria</TD>
<TD align="center">989766565</TD>
<TD align="left">Maria Creuza</TD>
<TD align="left">2007-04-19</TD>
<input type = 'hidden' name = 'id' value = "20"></TR>
</form>
<form id="myform[7]" method = "POST" action = "paciente_ficha.php">
<TR class="linhacalt" onclick="formSubmit()" onmouseover="this.className='linhac2'" onmouseout="this.className='linhacalt'">
<TD align="left">Maria Felix</TD>
<TD align="center">01234567890</TD>
<TD align="left">Roberta Felix</TD>
<TD align="left">2007-04-09</TD>
<input type = 'hidden' name = 'id' value = "15"></TR>
</form>
<form id="myform[8]" method = "POST" action = "paciente_ficha.php">
<TR class="linhac" onclick="formSubmit()" onmouseover="this.className='linhac2'" onmouseout="this.className='linhac'">
<TD align="left">Marilene</TD>
<TD align="center">14</TD>
<TD align="left"></TD>
<TD align="left">0000-00-00</TD>
<input type = 'hidden' name = 'id' value = "14"></TR>
</form>
<form id="myform[9]" method = "POST" action = "paciente_ficha.php">
<TR class="linhacalt" onclick="formSubmit()" onmouseover="this.className='linhac2'" onmouseout="this.className='linhacalt'">
<TD align="left">Numto Deixarecado</TD>
<TD align="center">345354353</TD>
<TD align="left">Carta Perdida</TD>
<TD align="left">2007-04-19</TD>
<input type = 'hidden' name = 'id' value = "21"></TR>
</form>
<form name= "enter" method = "POST" action = "operacao1.php"><TR>
<TD class="linha" align="center" colspan="4">
<A class="a"><img src="imagens\seta_inicio.gif" align="bottom" width="15" height="15" border="0"></A>
<A class="a"><img src="imagens\seta_esq.gif" align="bottom" width="12" height="15" border="0"></A>
<input onKeyPress="enter();" align="center" onclick="Foco()" type = "text" name = "pagina" size = "2" value = "1"><b>de 2</b>
<A class="a" href="?pagina=2 "><img src="imagens\seta_dir.gif" width="12" align="bottom" height="15" border="0"></A>
<A class="a" href="?pagina=2"><img src="imagens\seta_fim.gif" align="bottom" width="15" height="15" border="0"></A>
</TD>
</TR>
</form> </TABLE>[/codebox]
e este é o código em javascript
[codebox]<script LANGUAGE="JavaScript">
function formSubmit()
{
document.getElementById("myform").submit()
}
</script>[/codebox]
Não se esquecam que vão existir n forms (esse número vai ser de acordo com o bancodedados).
Desde já grato pela ajuda!!!
- Fórum WMO
- → Viewing Profile: Tópicos: Macfall
Community Stats
- Group Usuários
- Active Posts 5
- Profile Views 572
- Member Title Novato no fórum
- Age Age Unknown
- Birthday Birthday Unknown
-
Sexo
Não informado
0
Neutral
User Tools
Friends
Macfall hasn't added any friends yet.
Latest Visitors
-
Guest
04/11/2007, 00:09
Topics I've Started
Array Com Java Script
17/04/2007, 00:11
Mudar Cor Da Linha (toda) Da Tabela
15/04/2007, 22:45
Ai galera, eu nao to conseguindo mudar a cor da lina de uma tabela com a função JS onmouseover, pq acho que eu ja definir antes a cor da linha. O código é esse:
principal.css
[codebox]table.bordasimples
{
border-collapse: collapse;
}
table.bordasimples tr td
{
border:1px solid #C3C3C3;
}
td.titulo
{
background: #FF0000;
color: white;
text-align: center;
font-family: Arial, Helvetica, sans-serif;
font-weight: bold;
}
td.linha
{
background: #FFFFFF;
color: #404040 ;
font-family: Arial, Helvetica, sans-serif;
}
a
{
color: #404040;
font-family: Arial, Helvetica, sans-serif;
text-decoration: none;
}
a:hover
{
color: red;
font-family: Arial, Helvetica, sans-serif;
text-decoration: none;
}[/codebox]
parte do código da página(código que imprime a tabela)
paginacao.php
[codebox]<? //IMPRIME OS RESULTADOS
if ($_REQUEST['pagina'] > $n_pags) {
$pagina= $n_pags;
$limite_inf = ($pagina - 1) * $n_pag; }
if ($_REQUEST['pagina'] < 1) {
$pagina=1;
$limite_inf = 0; }
$consulta_exec = $consulta . " limit $limite_inf, $n_pag";
$resposta = mysql_query($consulta_exec);
$n_reg = mysql_num_rows($resposta);
for($x=0;$x<$n_reg;$x++)
{
if ($x % 2 != 0) {
$dif = $linhaAlternada; }
else {
$dif = ""; }
$campos = mysql_fetch_row($resposta);
$linha = "<TR>\n";
for($j=0;$j<5;$j++)
{
if ($j<4) {
$linha .= "<TD " . $linhas[$j] . " " . $dif . $linhasProp . ">" . $campos[$j] . "</TD>\n";}
else {
$linha .= "<TD " . $linhas[$j] . " " . $dif . $linhasProp . "><form id=\"myform\" method = \"POST\" action = \"ficha.php\"><input type = 'hidden' name = 'id' value = \" $campos[$j] \"><A href=\"java script: formSubmit() \">Abrir</A></form></TD>\n"; }}
$linha .= "</TR>\n";
echo $linha; }
?>
[/codebox]
parte do código index.php(onde a tabela vai ser exibida)
index.php[codebox]<?php include ("confere1.php") ;
include ("conecta_db.php");
include ("paginacao.php"); ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR...l1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<link rel="stylesheet" type="text/css" href="principal.css" />
<script LANGUAGE="JavaScript">
function formSubmit()
{
document.getElementById("myForm").submit()
}
</script>
</head>
<body>
<?
//PROPRIEDADES DAS LINHAS DE RESULTADOS
$linhasProp = "class=\"linha\"";
$linhaAlternada = "style=\"background:#E7FFE1;\" ";
//CHAMA A FUNÇÃO QUE GERA A PAGINAÇÃO
paginacao($consulta, $n_campos, $n_pag, $titulos, $titulosProp, $linhas, $linhasProp, $linhaAlternada, $tabelaProp, $linksProp, $rangePag);
?>
</body>
</html>
[/codebox]
Já tentei adicionar a funcao onmouseover no TR da tabela, mas não aconteceu nada, só muda quando eu tiro o valor do background da linha. Entao eu queria uma forma da linha mudar de cor na tabela com o passar do mouse , e se possivel quando eu clicasse na linha ela me remetesse a uma outra pagina com mais detalhes sobre a linha escolhida, que no caso dessa eu estou fazendo com um form e um submit com javascript de valor abrir.
Desde já grato!
principal.css
[codebox]table.bordasimples
{
border-collapse: collapse;
}
table.bordasimples tr td
{
border:1px solid #C3C3C3;
}
td.titulo
{
background: #FF0000;
color: white;
text-align: center;
font-family: Arial, Helvetica, sans-serif;
font-weight: bold;
}
td.linha
{
background: #FFFFFF;
color: #404040 ;
font-family: Arial, Helvetica, sans-serif;
}
a
{
color: #404040;
font-family: Arial, Helvetica, sans-serif;
text-decoration: none;
}
a:hover
{
color: red;
font-family: Arial, Helvetica, sans-serif;
text-decoration: none;
}[/codebox]
parte do código da página(código que imprime a tabela)
paginacao.php
[codebox]<? //IMPRIME OS RESULTADOS
if ($_REQUEST['pagina'] > $n_pags) {
$pagina= $n_pags;
$limite_inf = ($pagina - 1) * $n_pag; }
if ($_REQUEST['pagina'] < 1) {
$pagina=1;
$limite_inf = 0; }
$consulta_exec = $consulta . " limit $limite_inf, $n_pag";
$resposta = mysql_query($consulta_exec);
$n_reg = mysql_num_rows($resposta);
for($x=0;$x<$n_reg;$x++)
{
if ($x % 2 != 0) {
$dif = $linhaAlternada; }
else {
$dif = ""; }
$campos = mysql_fetch_row($resposta);
$linha = "<TR>\n";
for($j=0;$j<5;$j++)
{
if ($j<4) {
$linha .= "<TD " . $linhas[$j] . " " . $dif . $linhasProp . ">" . $campos[$j] . "</TD>\n";}
else {
$linha .= "<TD " . $linhas[$j] . " " . $dif . $linhasProp . "><form id=\"myform\" method = \"POST\" action = \"ficha.php\"><input type = 'hidden' name = 'id' value = \" $campos[$j] \"><A href=\"java script: formSubmit() \">Abrir</A></form></TD>\n"; }}
$linha .= "</TR>\n";
echo $linha; }
?>
[/codebox]
parte do código index.php(onde a tabela vai ser exibida)
index.php[codebox]<?php include ("confere1.php") ;
include ("conecta_db.php");
include ("paginacao.php"); ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR...l1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<link rel="stylesheet" type="text/css" href="principal.css" />
<script LANGUAGE="JavaScript">
function formSubmit()
{
document.getElementById("myForm").submit()
}
</script>
</head>
<body>
<?
//PROPRIEDADES DAS LINHAS DE RESULTADOS
$linhasProp = "class=\"linha\"";
$linhaAlternada = "style=\"background:#E7FFE1;\" ";
//CHAMA A FUNÇÃO QUE GERA A PAGINAÇÃO
paginacao($consulta, $n_campos, $n_pag, $titulos, $titulosProp, $linhas, $linhasProp, $linhaAlternada, $tabelaProp, $linksProp, $rangePag);
?>
</body>
</html>
[/codebox]
Já tentei adicionar a funcao onmouseover no TR da tabela, mas não aconteceu nada, só muda quando eu tiro o valor do background da linha. Entao eu queria uma forma da linha mudar de cor na tabela com o passar do mouse , e se possivel quando eu clicasse na linha ela me remetesse a uma outra pagina com mais detalhes sobre a linha escolhida, que no caso dessa eu estou fazendo com um form e um submit com javascript de valor abrir.
Desde já grato!
Transferencia De Valores Entre Campos
28/03/2007, 22:24
Ai galera blz? Eu to fazendo um site com um lugar para pesquisa em um bd interno. Antes os campos de pesquisa eram separados:
<form method="POST" action="executa1.php">
<table width="100%" border="0">
<tr>
<td><div align="center"><strong>Pesquisar: </strong></div></td>
</tr>
</table>
<table width="100%" height="149" border="1px" cellpadding="5px" cellspacing="0" id="alter">
<tr>
<td> CPF:</td>
<td><input name="cpf" type="text" size="20" maxlength="11"></td>
</tr>
<tr class="dif">
<td>Nome :</td>
<td><input name="nome" type="text" size="20" maxlength="60"></td>
</tr>
<tr >
<td>Nome da mãe : </td>
<td><input name="nome_mae" type="text" size="20" maxlength="60"></td>
</tr>
<tr class="dif">
<td>Nascimento:</td>
<td><input name="nascimento" type="text" size="20" maxlength="20"></td>
<td> <input type = "submit" name = "pesquisar" value = "Pesquisar"></td>
</tr>
</table>
mas decidi colocar uma SELECT ficando assim :
<form method="POST" action="executa1.php">
<table width="100%" border="0">
<tr>
<td><div align="center"><strong>Pesquisar </strong></div></td>
</tr>
</table>
<table width="100%" height="149" border="1px" cellpadding="0px" cellspacing="0" id="alter">
<tr>
<td> <select name="pesquisa" >
<option value="cpf">Cpf</option>
<option value="nome">Nome</option>
<option value="nome_mae">Nome da mãe </option>
<option value="nascimento">Nascimento</option> </select>
</td>
<td> <input name=" ?" type="text" size="20" maxlength="11"> </td>
</tr>
<tr>
<td> </td>
<td> <input type = "submit" name = "pesquisar" value = "Pesquisar"></td>
</tr>
</table>
mas não sei como transferir o valor da opcao escolhida para o input name.
Desde já grato pela ajuda!!!
<form method="POST" action="executa1.php">
<table width="100%" border="0">
<tr>
<td><div align="center"><strong>Pesquisar: </strong></div></td>
</tr>
</table>
<table width="100%" height="149" border="1px" cellpadding="5px" cellspacing="0" id="alter">
<tr>
<td> CPF:</td>
<td><input name="cpf" type="text" size="20" maxlength="11"></td>
</tr>
<tr class="dif">
<td>Nome :</td>
<td><input name="nome" type="text" size="20" maxlength="60"></td>
</tr>
<tr >
<td>Nome da mãe : </td>
<td><input name="nome_mae" type="text" size="20" maxlength="60"></td>
</tr>
<tr class="dif">
<td>Nascimento:</td>
<td><input name="nascimento" type="text" size="20" maxlength="20"></td>
<td> <input type = "submit" name = "pesquisar" value = "Pesquisar"></td>
</tr>
</table>
mas decidi colocar uma SELECT ficando assim :
<form method="POST" action="executa1.php">
<table width="100%" border="0">
<tr>
<td><div align="center"><strong>Pesquisar </strong></div></td>
</tr>
</table>
<table width="100%" height="149" border="1px" cellpadding="0px" cellspacing="0" id="alter">
<tr>
<td> <select name="pesquisa" >
<option value="cpf">Cpf</option>
<option value="nome">Nome</option>
<option value="nome_mae">Nome da mãe </option>
<option value="nascimento">Nascimento</option> </select>
</td>
<td> <input name=" ?" type="text" size="20" maxlength="11"> </td>
</tr>
<tr>
<td> </td>
<td> <input type = "submit" name = "pesquisar" value = "Pesquisar"></td>
</tr>
</table>
mas não sei como transferir o valor da opcao escolhida para o input name.
Desde já grato pela ajuda!!!
- Fórum WMO
- → Viewing Profile: Tópicos: Macfall
- Privacy Policy
- Regras ·



Postagens