Ir para conteúdo

POWERED BY:

Arquivado

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

jpetska

modificar valores de campos em formulários

Recommended Posts

olá

Estou tentando fazer um auto preenchimento de formulário, alterando valores de um <select> em um formulário php, mas não estou conseguindo.

 

Segue posicionamento do campo <select> no formuláio site.php?:

html>body.body_form>div#formulariosos>table>tbody>tr>td.aba_quadro>form#form_os>fieldset>span#select_cc[NATUREZA]>select_cc[NATUREZA].campo_select>option

 

Extraí parte do formulário, salvei em html e o código está em page.html. OBS: formulário original é (id="theIFrame" src="site.php?")

 

Fiz em html e usei javascript conforme abaixo e consegui fazer funcionar quando uso src="page.html", porém quando tento no site original src="site.php?" a função java não altera o campo.

Botão 'send' altera o valor do campo <select>.

 

Estou fazendo certo, mas esqueço de algo? ou é de outra forma por ser formulário php?

 

index.html

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"><html xmlns="http://www.w3.org/1999/xhtml">  <head>    <title>Teste</title>    <meta http-equiv="Content-type" content="text/html; charset=utf-8" />    <script type="text/javascript">      function sendDataToIFrame(){    document.getElementById('theIFrame').contentDocument.getElementById('cc[NATUREZA]').selectedIndex = '2';      }    </script>  </head>  <body>               <button type="text" name="butPageToIFrame" id="butPageToIFrame" onclick="sendDataToIFrame();">send</button>    <iframe id="theIFrame" src="page.html" style="width:500px; height:500px; border:#000000 3px double; margin:10px;"></iframe>  </body></html>

page.html

<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="pt-br"><head>     <meta http-equiv="pragma" content="no-cache">     <meta http-equiv="content-type" content="text/html; charset=iso-8859-1">    <title>Mmmm</title>    <link href="temas/padrao/estilo.css" rel="stylesheet" type="text/css" title="padrao">    <script type="text/javascript" src="lib/jquery/jquery-1.4.2.min.js"> </script>    </head>    <body class="body_form">    <div id="formularioos"><table border="0" cellpadding="0" cellspacing="0" width="100%"><tbody><tr><td class="aba_sel" onclick="Aba('aponta.php?id=1')">Info. Geral</td><td class="aba_entre"> </td><td class="aba" onclick="Aba('aponta.php?id=3')">Tempos/Recursos</td>    <td class="aba_entre"> </td><td class="aba" onclick="Aba('aponta.php?id=4')">Pendências</td>    <td class="aba_entre"> </td><td class="aba" onclick="Aba('aponta.php?id=5')">Opções</td>    <td class="aba_entre"> </td><td class="aba" onclick="Aba('aponta.php?id=6')">Fechar</td>    <td class="aba_entre"> </td><td class="aba_fim"> </td></tr><tr><td colspan="20" class="aba_quadro" valign="top"><form id="form_os" name="form" method="POST" action="aponta.php?">    <fieldset><legend>Informações Gerais</legend><br clear="all"><label class="campo_label" for="cc[NATUREZA]">Natureza do Serviço:</label><span id="select_cc[NATUREZA]"><select class="campo_select" name="cc[NATUREZA]" id="cc[NATUREZA]" onchange=""><option value="0"></option><option value="1" selected="selected" title="CIVIL">CIVIL</option><option value="2" title="ELÉTRICA">ELÉTRICA</option><option value="3" title="MECÂNICA">MECÂNICA</option></select></span><br clear="all">    </fieldset>            <br>    <div align="center">    <input class="botao" name="gravaos" id="gravaos_id" value="Salvar" type="submit">    </div><br> <br></form></td></tr></tbody></table></div></body></html>

obrigado

 

 

Alguém pode me ajudar?

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.