Javascript para alteração de máscara de I.E. Olá, Sou novo com javascript, procurei aqui mesmo no fórum sobre o assunto para a implementação de código dentro de um formulário, mas não consegui nenhum resultado que explique com mais detalhes sobre o assunto. Normalmente tem somente o trecho de código referente a tal função. Por isso venho por meio deste tirar algumas dúvidas de como escrever o código e onde escrever. Primeiro...
IU
Javascript para alteração de máscara de I.E.  
Olá,
Sou novo com javascript, procurei aqui mesmo no fórum sobre o assunto para a implementação de código dentro de um formulário, mas não consegui nenhum resultado que explique com mais detalhes sobre o assunto.
Normalmente tem somente o trecho de código referente a tal função. Por isso venho por meio deste tirar algumas dúvidas de como escrever o código e onde escrever.

Primeiro, segue abaixo um formulário de cadastro de cliente, onde estou tendo dificuldade de alterar a máscara do campo I.E. conforme o Estado em que a pessoa se encontra:

 
  1. <?php
  2. class ClienteForm extends TPage
  3. {
  4. protected $form; // form
  5. public function __construct( $param )
  6. {
  7. parent::__construct();
  8. try
  9. {
  10. TTransaction::open('itisu420_sistema2');
  11. // CRIAÇÃO DO FORMULÁRIO
  12. $this->form = new TForm('form_Cliente');
  13. $page = new TTable;
  14. //$page->border = '1';
  15. $this->form->add($page);
  16. // CRIAÇÃO DOS CAMPOS DO FORMULÁRIO
  17. $id = new TEntry('id');
  18. $dt_abertura = new TDate('dt_abertura');
  19. $nome_fantasia = new TEntry('nome_fantasia');
  20. $razao_social = new TEntry('razao_social');
  21. $cnpj = new TEntry('cnpj');
  22. $cpf = new TEntry('cpf');
  23. $estado = new TCombo('estado');
  24. $uf = array('AC'=>'ACRE', 'AL'=>'ALAGOAS', 'AP'=>'AMAPÁ', 'AM'=>'AMAZONAS', 'BA'=>'BAHIA', 'CE'=>'CEARÁ', 'DF'=>'DISTRITO FEDERAL', 'ES'=>'ESPÍRITO SANTO',
  25. 'GO'=>'GOIÁS', 'MA'=>'MARANHÃO', 'MT'=>'MATO GROSSO', 'MS'=>'MATO GROSSO DO SUL', 'MG'=>'MINAS GERAIS', 'PA'=>'PARÁ', 'PB'=>'PARAÍBA', 'PR'=>'PARANÁ',
  26. 'PE'=>'PERNAMBUCO', 'PI'=>'PIAUÍ', 'RJ'=>'RIO DE JANEIRO', 'RN'=>'RIO GRNADE DO NORTE', 'RS'=>'RIO GRANDE DO SUL', 'RO'=>'RONDÔNIA', 'RR'=>'RORAIMA',
  27. 'SC'=>'SANTA CATARINA', 'SP'=>'SÃO PAULO', 'SE'=>'SERGIPE', 'TO'=>'TOCANTINS');
  28. $estado->addItems($uf);
  29. $ie = new TEntry('ie');
  30. $ra = new TEntry('ra');
  31. $margem = new TEntry('margem');
  32. $cep = new TEntry('cep');
  33. $endereco = new TEntry('endereco');
  34. $numero = new TEntry('numero');
  35. $complemento = new TEntry('complemento');
  36. $bairro = new TEntry('bairro');
  37. $cidade = new TEntry('cidade');
  38. $telf = new TEntry('telf');
  39. $telm = new TEntry('telm');
  40. $email = new TEntry('email');
  41. $siteweb = new TEntry('siteweb');
  42. $estrangeiro = new TRadioGroup('estrangeiro');
  43. $opcoes_estrangeiro = array('s' => 'SIM', 'n' => 'NÃO');
  44. $estrangeiro->addItems($opcoes_estrangeiro);
  45. $estrangeiro->setLayout('horizontal');
  46. $suframa = new TEntry('suframa');
  47. // HABILITA/DESABILITA CAMPOS PARA EDIÇÃO
  48. $id->setEditable(FALSE);
  49. // MÁSCARAS
  50. $dt_abertura->setMask('dd/mm/yyyy');
  51. $cnpj->setMask('99.999.999/9999-99');
  52. $cpf->setMask('999.999.999-99');
  53. $telf->setMask('(99)9999-9999');
  54. $telm->setMask('(99)99999-9999');
  55. $suframa->setMask('999999999');
  56. $nome_fantasia->setMaxLength(60);
  57. $razao_social->setMaxLength(100);
  58. $email->setMaxLength(50);
  59. $siteweb->setMaxLength(60);
  60. $cep->setMask('99999-999');
  61. $numero->setMaxLength(10);
  62. $complemento->setMaxLength(30);
  63. $endereco->setMaxLength(60);
  64. $cidade->setMaxLength(40);
  65. $ra->setMaxLength(10);
  66. $margem->setMaxLength(10);
  67. $bairro->setMaxLength(20);
  68. $ie->setMaxLength(17);
  69. // TÍTULO DA TABELA
  70. $title1 = new TLabel('CADASTRO DE CLIENTES');
  71. $title1->setFontColor('#3b8b8b');
  72. $title1->setFontSize('18');
  73. $row = $page->addRow();
  74. $title1 = $row->addCell($title1);
  75. $title1->colspan = 6;
  76. // ADIÇÃO DOS CAMPOS ID E DATA DE ABERTURA NA TABELA PRINCIPAL (PAGE)
  77. $row = $page->addRow();
  78. $cell = $row->addCell(new TLabel('ID'));
  79. $cell->colspan = 3;
  80. $cell = $row->addCell(new TLabel('DATA ABERTURA'));
  81. $cell->colspan = 3;
  82. $row = $page->addRow();
  83. $cell = $row->addCell($id);
  84. $cell->colspan = 3;
  85. $cell = $row->addCell($dt_abertura);
  86. $cell->colspan = 3;
  87. // FRAME 1
  88. $frame1 = new TFrame;
  89. $frame1->setLegend('Dados do Cliente');
  90. $frame1->oid = 'frame1-dados';
  91. $botao1 = new TButton('show hide');
  92. $botao1->class = 'btn btn-info';
  93. $botao1->setLabel('M/O - Dados');
  94. $botao1->addFunction("\$('[oid=frame1-dados]').slideToggle(); $(this).toggleClass( 'active' )");
  95. // ADIÇÃO DOS BOTÕES MOSTRAR/OCULTAR
  96. $row = $page->addRow();
  97. $botao1 = $row->addCell($botao1);
  98. $botao1->colspan = 6;
  99. // ADIÇÃO DO FRAME 1
  100. $row = $page->addRow();
  101. $cell = $row->addCell($frame1);
  102. $cell->colspan = 6;
  103. $page1 = new TTable;
  104. $frame1->add($page1);
  105. $row = $page1->addRow();
  106. $cell = $row->addCell(new TLabel('Nome Fantasia'));
  107. $cell->colspan = 6;
  108. $row = $page1->addRow();
  109. $cell = $row->addCell($nome_fantasia);
  110. $cell->colspan = 6;
  111. $row = $page1->addRow();
  112. $cell = $row->addCell(new TLabel('Razão Social'));
  113. $cell->colspan = 6;
  114. $row = $page1->addRow();
  115. $cell = $row->addCell($razao_social);
  116. $cell->colspan = 6;
  117. $row = $page1->addRow();
  118. $cell = $row->addCell(new TLabel('CNPJ'));
  119. $cell->colspan = 2;
  120. $cell = $row->addCell(new TLabel('CPF'));
  121. $cell->colspan = 2;
  122. $cell = $row->addCell(new TLabel('ESTRANGEIRO'));
  123. $cell->colspan = 2;
  124. $row = $page1->addRow();
  125. $cell = $row->addCell($cnpj);
  126. $cell->colspan = 2;
  127. $cell = $row->addCell($cpf);
  128. $cell->colspan = 2;
  129. $cell = $row->addCell($estrangeiro);
  130. $cell->colspan = 2;
  131. $row = $page1->addRow();
  132. $row->addCell(new TLabel('Estado'));
  133. $row->addCell(new TLabel('I.E.'));
  134. $row->addCell(new TLabel('RA'));
  135. $row->addCell(new TLabel('Margem'));
  136. $row = $page1->addRow();
  137. $row->addCell($estado);
  138. $row->addCell($ie);
  139. $row->addCell($ra);
  140. $row->addCell($margem);
  141. // ADIÇÃO DOS BOTÕES MOSTRAR/OCULTAR
  142. $frame2 = new TFrame;
  143. $frame2->setLegend('Endereço do Cliente');
  144. $frame2->oid = 'frame2-endereco';
  145. $botao2 = new TButton('show hide');
  146. $botao2->class = 'btn btn-info';
  147. $botao2->setLabel('M/O - Endereço');
  148. $botao2->addFunction("\$('[oid=frame2-endereco]').slideToggle(); $(this).toggleClass( 'active' )");
  149. // ADIÇÃO DOS BOTÕES MOSTRAR/OCULTAR
  150. $row = $page->addRow();
  151. $botao2 = $row->addCell($botao2);
  152. $botao2->colspan = 6;
  153. // ADIÇÃO DO FRAME 2
  154. $row = $page->addRow();
  155. $cell = $row->addCell($frame2);
  156. $cell->colspan = 6;
  157. $page2 = new TTable;
  158. $frame2->add($page2);
  159. $row = $page2->addRow();
  160. $cell = $row->addCell(new TLabel('CEP'));
  161. $cell->colspan = 2;
  162. $cell = $row->addCell(new TLabel('Endereço'));
  163. $cell->colspan = 2;
  164. $cell = $row->addCell(new TLabel('Número'));
  165. $cell->colspan = 2;
  166. $row = $page2->addRow();
  167. $cell = $row->addCell($cep);
  168. $cell->colspan = 2;
  169. $cell = $row->addCell($endereco);
  170. $cell->colspan = 2;
  171. $cell = $row->addCell($numero);
  172. $cell->colspan = 2;
  173. $row = $page2->addRow();
  174. $cell = $row->addCell(new TLabel('Complemento'));
  175. $cell->colspan = 2;
  176. $cell = $row->addCell(new TLabel('Bairro'));
  177. $cell->colspan = 2;
  178. $cell = $row->addCell(new TLabel('Cidade'));
  179. $cell->colspan = 2;
  180. $row = $page2->addRow();
  181. $cell = $row->addCell($complemento);
  182. $cell->colspan = 2;
  183. $cell = $row->addCell($bairro);
  184. $cell->colspan = 2;
  185. $cell = $row->addCell($cidade);
  186. $cell->colspan = 2;
  187. $row = $page2->addRow();
  188. $cell = $row->addCell(new TLabel('Tel.Fixo'));
  189. $cell->colspan = 2;
  190. $cell = $row->addCell(new TLabel('Tel.Móvel'));
  191. $cell->colspan = 2;
  192. $cell = $row->addCell(new TLabel('Email'));
  193. $cell->colspan = 2;
  194. $row = $page2->addRow();
  195. $cell = $row->addCell($telf);
  196. $cell->colspan = 2;
  197. $cell = $row->addCell($telm);
  198. $cell->colspan = 2;
  199. $cell = $row->addCell($email);
  200. $cell->colspan = 2;
  201. $row = $page2->addRow();
  202. $cell = $row->addCell(new TLabel('Website'));
  203. $cell->colspan = 6;
  204. $row = $page2->addRow();
  205. $cell = $row->addCell($siteweb);
  206. $cell->colspan = 6;
  207. $row = $page2->addRow();
  208. $cell = $row->addCell(new TLabel('SUFRAMA'));
  209. $cell->colspan = 6;
  210. $row = $page2->addRow();
  211. $cell = $row->addCell($suframa);
  212. $cell->colspan = 2;
  213. // CRIACAO DOS BOTÕES
  214. $botao4 = new TButton('save');
  215. $botao4->setAction( new TAction(array($this,'onSave')), _t('Save'));
  216. $botao4->setImage('fa:floppy-o');
  217. $row = $page->addRow();
  218. $cell = $row->addCell($botao4);
  219. $cell->colspan = 1;
  220. $botao5 = new TButton('new');
  221. $botao5->setAction( new TAction(array($this, 'onClear')), _t('New'));
  222. $botao5->setImage('bs:plus-sign green');
  223. $cell = $row->addCell($botao5);
  224. $cell->colspan = 1;
  225. $botao6 = new TButton('Voltar');
  226. $botao6->setAction( new TAction(array('ClienteList', 'onReload')), 'Voltar');
  227. $botao6->setImage('fa:mail-reply blue');
  228. $cell = $row->addCell($botao6);
  229. $cell->colspan = 1;
  230. //---------------------------------------------------------------------------------------
  231. // ------------- FIM FORMULARIO --------------
  232. //---------------------------------------------------------------------------------------
  233. $this->form->setFields( array($id, $dt_abertura, $nome_fantasia, $razao_social, $cnpj, $cpf, $estado, $ie, $ra, $margem, $cep, $endereco,
  234. $numero, $complemento, $bairro, $cidade, $telf, $telm, $email, $siteweb, $estrangeiro, $suframa,
  235. $botao4, $botao5, $botao6));
  236. $script = new TElement('script');
  237. $script->type = 'text/javascript';   
  238.         $javascript = "
  239.         // personaliza os campos de acordo com o ESTADO 
  240.         $( 'select[name="estado"]' ).change( function( event ){ var tipoEstado $( 'select[name="estado"] > option:selected' ).each( function(){ tipoEstado = $(this).text(); }); 
  241.         if(tipoEstado == 'AC') { $('input[name="ie"]').val(''); $('input[name="ie"]').attr( {onkeypress:'return tentry_mask(this,event,"99.999.999/999-99")'} ); } 
  242.         if(tipoEstado == 'AL') { $('input[name="ie"]').val(''); $('input[name="ie"]').attr( {onkeypress:'return tentry_mask(this,event,"999999999")'} ); }
  243.         if(tipoEstado == 'AP') { $('input[name="ie"]').val(''); $('input[name="ie"]').attr( {onkeypress:'return tentry_mask(this,event,"9999999999")'} ); }
  244.         if(tipoEstado == 'AM') { $('input[name="ie"]').val(''); $('input[name="ie"]').attr( {onkeypress:'return tentry_mask(this,event,"99.999.999-9")'} ); }
  245.         if(tipoEstado == 'BH') { $('input[name="ie"]').val(''); $('input[name="ie"]').attr( {onkeypress:'return tentry_mask(this,event,"999999-99")'} ); }
  246.         if(tipoEstado == 'CE') { $('input[name="ie"]').val(''); $('input[name="ie"]').attr( {onkeypress:'return tentry_mask(this,event,"99999999-9")'} ); }
  247.         if(tipoEstado == 'DF') { $('input[name="ie"]').val(''); $('input[name="ie"]').attr( {onkeypress:'return tentry_mask(this,event,"99999999999-99")'} ); }
  248.         if(tipoEstado == 'ES') { $('input[name="ie"]').val(''); $('input[name="ie"]').attr( {onkeypress:'return tentry_mask(this,event,"99999999-9")'} ); }
  249.         if(tipoEstado == 'GO') { $('input[name="ie"]').val(''); $('input[name="ie"]').attr( {onkeypress:'return tentry_mask(this,event,"99.999.999-9")'} ); }
  250.         if(tipoEstado == 'MA') { $('input[name="ie"]').val(''); $('input[name="ie"]').attr( {onkeypress:'return tentry_mask(this,event,"99999999-9")'} ); }
  251.         if(tipoEstado == 'MT') { $('input[name="ie"]').val(''); $('input[name="ie"]').attr( {onkeypress:'return tentry_mask(this,event,"9999999999-9")'} ); }
  252.         if(tipoEstado == 'MS') { $('input[name="ie"]').val(''); $('input[name="ie"]').attr( {onkeypress:'return tentry_mask(this,event,"99999999-9")'} ); }
  253.         if(tipoEstado == 'MG') { $('input[name="ie"]').val(''); $('input[name="ie"]').attr( {onkeypress:'return tentry_mask(this,event,"999.999.999/9999")'} ); }
  254.         if(tipoEstado == 'PA') { $('input[name="ie"]').val(''); $('input[name="ie"]').attr( {onkeypress:'return tentry_mask(this,event,"99-999999-9")'} ); }
  255.         if(tipoEstado == 'PB') { $('input[name="ie"]').val(''); $('input[name="ie"]').attr( {onkeypress:'return tentry_mask(this,event,"99999999-9")'} ); }
  256.         if(tipoEstado == 'PR') { $('input[name="ie"]').val(''); $('input[name="ie"]').attr( {onkeypress:'return tentry_mask(this,event,"999.99999-99")'} ); }
  257.         if(tipoEstado == 'PE') { $('input[name="ie"]').val(''); $('input[name="ie"]').attr( {onkeypress:'return tentry_mask(this,event,"9999999-99")'} ); }
  258.         if(tipoEstado == 'PI') { $('input[name="ie"]').val(''); $('input[name="ie"]').attr( {onkeypress:'return tentry_mask(this,event,"99999999-9")'} ); }
  259.         if(tipoEstado == 'RJ') { $('input[name="ie"]').val(''); $('input[name="ie"]').attr( {onkeypress:'return tentry_mask(this,event,"99.999.99-9")'} ); }
  260.         if(tipoEstado == 'RN') { $('input[name="ie"]').val(''); $('input[name="ie"]').attr( {onkeypress:'return tentry_mask(this,event,"99.999.999-9")'} ); }
  261.         if(tipoEstado == 'RS') { $('input[name="ie"]').val(''); $('input[name="ie"]').attr( {onkeypress:'return tentry_mask(this,event,"999/9999999")'}); }
  262.         if(tipoEstado == 'RO') { $('input[name="ie"]').val(''); $('input[name="ie"]').attr( {onkeypress:'return tentry_mask(this,event,"9999999999999-9")'} ); }
  263.         if(tipoEstado == 'RR') { $('input[name="ie"]').val(''); $('input[name="ie"]').attr( {onkeypress:'return tentry_mask(this,event,"99999999-9")'} ); }
  264.         if(tipoEstado == 'SC') { $('input[name="ie"]').val(''); $('input[name="ie"]').attr( {onkeypress:'return tentry_mask(this,event,"999.999.999")'} ); }
  265.         if(tipoEstado == 'SP') { $('input[name="ie"]').val(''); $('input[name="ie"]').attr( {onkeypress:'return tentry_mask(this,event,"999.999.999.999")'} ); }
  266. if(tipoEstado == 'SE') { $('input[name="ie"]').val(''); $('input[name="ie"]').attr( {onkeypress:'return tentry_mask(this,event,"99999999-9")'} ); }
  267.         if(tipoEstado == 'TO') { $('input[name="ie"]').val(''); $('input[name="ie"]').attr( {onkeypress:'return tentry_mask(this,event,"9999999999-9")'} ); }
  268. ";
  269. $script->add($javascript);
  270. parent::add($script);
  271. if (!empty($id))
  272. {
  273. $id->setEditable(FALSE);
  274. }
  275. // vertical box container
  276. $conteiner = new TVBox;
  277. $conteiner->style = 'width: 100%';
  278. $conteiner->add($this->form);
  279. TTransaction::close();
  280. }
  281. catch (Exception $e)
  282. {
  283. new TMessage('error', $e->getMessage());
  284. }
  285. parent::add($conteiner);
  286. }
  287. public function onSave( $param )
  288. {
  289. try
  290. {
  291. TTransaction::open('itisu420_sistema2'); // open a transaction
  292. $this->form->validate(); // validate form data
  293. $object = new Cliente; // create an empty object
  294. $data = $this->form->getData(); // get form data as array
  295. $object->fromArray( (array) $data); // load the object with data
  296. $object->dt_abertura = TDate::date2us($object->dt_abertura);
  297. $object->store(); // save the object
  298. // get the generated id
  299. $data->id = $object->id;
  300. $object->dt_abertura = TDate::date2br($object->dt_abertura);
  301. $this->form->setData($data); // fill form data
  302. TTransaction::close(); // close the transaction
  303. new TMessage('info', TAdiantiCoreTranslator::translate('Record saved'));
  304. }
  305. catch (Exception $e) // in case of exception
  306. {
  307. new TMessage('error', $e->getMessage()); // shows the exception error message
  308. $this->form->setData( $this->form->getData() ); // keep form data
  309. TTransaction::rollback(); // undo all pending operations
  310. }
  311. }
  312. public function onClear( $param )
  313. {
  314. $this->form->clear();
  315. }
  316. public function onEdit( $param )
  317. {
  318. try
  319. {
  320. if (isset($param['key']))
  321. {
  322. $key = $param['key']; // get the parameter $key
  323. TTransaction::open('itisu420_sistema2'); // open a transaction
  324. $object = new Cliente($key); // instantiates the Active Record
  325. $object->dt_abertura = TDate::date2br($object->dt_abertura);
  326. $this->form->setData($object); // fill the form
  327. TTransaction::close(); // close the transaction
  328. }
  329. else
  330. {
  331. $this->form->clear();
  332. }
  333. }
  334. catch (Exception $e) // in case of exception
  335. {
  336. new TMessage('error', $e->getMessage()); // shows the exception error message
  337. TTransaction::rollback(); // undo all pending operations
  338. }
  339. }
  340. public function formatDate($date, $object)
  341. {
  342. $dt = new DateTime($date);
  343. return $dt->format('d/m/y');
  344. }
  345. }
  346. ?>


Porém não funciona ao executar a página, na verdade ele gera um erro de sintaxe na linha
$script = new TElement('script');

Como eu faço pra funcionar isso ?

Curso Dominando o Adianti Framework

O material mais completo de treinamento do Framework.
Curso em vídeo aulas + Livro completo + Códigos fontes do projeto ERPHouse.
Conteúdo Atualizado!


Dominando o Adianti Framework Quero me inscrever agora!

Comentários (20)


NR

Está dando erro por causa das aspas duplas. Por exemplo, no começo da string você abriu aspas duplas e depois do 'name=' adicionou novamente as aspas:
 
  1. <?php
  2. $javascript = "
  3. $( 'select[name="estado"]' ).change( function( event )
  4. // as aspas nao sao necessarias nesse caso
  5. $( 'select[name=estado]' ).change( function( event )
  6. ...
  7. ?>

Outra coisa que percebi, se sua intenção é buscar o valor selecionado na combo, pode fazer o seguinte:
 
  1. <?php
  2. var tipoEstado = $('select[name=estado]').val();
  3. ?>

E em cada if dos estados precisa ajustar:
 
  1. <?php
  2. if(tipoEstado == 'AC') { $('input[name=ie]').val(''); $('input[name=ie]').attr( {onkeypress:'return tentry_mask(this,event,\'99.999.999/999-99\')'} ); }
  3. ?>

NR

Ao postar sumiram as barras. Seria:
tentry_mask(this,event,contra-barra + aspa simples + mascara + contra-barra + aspa_simples)
IU

Ok, entendido e corrigido, porém ele ainda gera um erro na linha 274: $script->type = 'text/javascript';

-> "Parse error: parse error in C:wamp64wwwitisu420sistema2appcontrolClienteClienteForm.class.php on line 274
Errors parsing C:wamp64wwwitisu420sistema2appcontrolClient".

Se eu retiro esta linha ele gera outro erro: $javascript = "
-> "Parse error: parse error in C:wamp64wwwitisu420sistema2appcontrolClienteClienteForm.class.php on line 275
Errors parsing C:wamp64wwwitisu420sistema2appcontrolClienteClienteForm.class.php"

Como eu corrigo isto ?
IU

Na linha 274 eu reescrevi o código:
 
  1. <?php
  2. $script->type('text/javascript');
  3. ?>

e não deu mais o erro.
Porém ainda continua o erro na linha 275.
IU

Na linha 274 eu reescrevi o código:
 
  1. <?php
  2. $script->type('text/javascript');
  3. ?>

e não deu mais o erro.
Porém ainda continua o erro na linha 275.
LC

Estou com um problema parecido mas no meu caso não dá erro mas também não executa o scrip

 
  1. <?php
  2. class ClientesCadFormList extends TPage
  3. {
  4. protected $form; // form
  5. protected $datagrid; // datagrid
  6. protected $pageNavigation;
  7. protected $loaded;
  8. /**
  9. * Form constructor
  10. * @param $param Request
  11. */
  12. public function __construct( $param )
  13. {
  14. parent::__construct();
  15. // creates the form
  16. $this->form = new TQuickForm('form_Clientes');
  17. $this->form->class = 'tform'; // change CSS class
  18. //$this->form = new BootstrapFormWrapper($this->form);
  19. $this->form->style = 'display: table;width:100%'; // change style
  20. $this->form->setFormTitle('Clientes');
  21. // create the form fields
  22. $id = new TEntry('id');
  23. $tpcliente = new TCombo('tpcliente');
  24. $CPFCNPJ = new TEntry('CPFCNPJ');
  25. $NomeRazao = new TEntry('NomeRazao');
  26. $Logradouro = new TEntry('Logradouro');
  27. $Bairro = new TEntry('Bairro');
  28. $Cidade = new TEntry('Cidade');
  29. $UF = new TCombo('UF');
  30. $CEP = new TEntry('CEP');
  31. $Telefone01 = new TEntry('Telefone01');
  32. $Telefone02 = new TEntry('Telefone02');
  33. $idtributacao = new TDBCombo('idtributacao','conexao','Tributacao','id','Tributacao');
  34. $CEP->setMask('99.999-999');
  35. $Telefone01->setMask ('(89)99999-9999');
  36. $Telefone02->setMask ('(89)99999-9999');
  37. $itensTipoPessoa = array ();
  38. $itensTipoPessoa['PF'] = 'Pessoa Física';
  39. $itensTipoPessoa['PJ'] = 'Pessoa Jurídica';
  40. $itensTipoPessoa['CEI'] = 'Matrícula CEI';
  41. $tpcliente->addItems($itensTipoPessoa);
  42. $itensUF = array ();
  43. $itensUF['AC'] = 'AC';
  44. $itensUF['AL'] = 'AL';
  45. $itensUF['AM'] = 'AM';
  46. $itensUF['AP'] = 'AP';
  47. $itensUF['BA'] = 'BA';
  48. $itensUF['CE'] = 'CE';
  49. $itensUF['DF'] = 'DF';
  50. $itensUF['ES'] = 'ES';
  51. $itensUF['GO'] = 'GO';
  52. $itensUF['MA'] = 'MA';
  53. $itensUF['MT'] = 'MT';
  54. $itensUF['MS'] = 'MS';
  55. $itensUF['PA'] = 'PA';
  56. $itensUF['PB'] = 'PB';
  57. $itensUF['PE'] = 'PE';
  58. $itensUF['PI'] = 'PI';
  59. $itensUF['PR'] = 'PR';
  60. $itensUF['RJ'] = 'RJ';
  61. $itensUF['RN'] = 'RN';
  62. $itensUF['RO'] = 'RO';
  63. $itensUF['RR'] = 'RR';
  64. $itensUF['RS'] = 'RS';
  65. $itensUF['SC'] = 'SC';
  66. $itensUF['SE'] = 'SE';
  67. $itensUF['SP'] = 'SP';
  68. $itensUF['TO'] = 'TO';
  69. $UF->addItems($itensUF);
  70. $buscacep = new TButton('find');
  71. $buscacep->setAction(new TAction(array($this,'onCep')),'Busca CEP');
  72. $buscacep->setImage('ico_find.png');
  73. $CEP->setSize(100);
  74. $buscacep->setSize(100);
  75. // add the fields
  76. $this->form->addQuickField('Código', $id, 100 );
  77. $this->form->addQuickField('Tipo de Cliente', $tpcliente, 150 , new TRequiredValidator);
  78. //$this->form->addQuickField('CPF/CNPJ', $CPFCNPJ, 150 , new TCNPJValidator);
  79. $this->form->addQuickField('CPF/CNPJ', $CPFCNPJ, 150 , new TRequiredValidator);
  80. $this->form->addQuickField('Nome/Razão', $NomeRazao, 400 , new TRequiredValidator);
  81. $this->form->addQuickFields('CEP', array($CEP, $buscacep));
  82. $this->form->addQuickField('Logradouro', $Logradouro, 400 );
  83. $this->form->addQuickField('Bairro', $Bairro, 200 );
  84. $this->form->addQuickField('Cidade', $Cidade, 300 );
  85. $this->form->addQuickField('UF', $UF, 50 );
  86. //$this->form->addQuickField('CEP', $CEP, 100 );
  87. $this->form->addQuickField('Telefone 01', $Telefone01, 100 );
  88. $this->form->addQuickField('Telefone 02', $Telefone02, 100 );
  89. $this->form->addQuickField('Tributação', $idtributacao, 200, new TRequiredValidator );
  90. //SCRIPT PARA VERIFICAR SE É CPF OU CNPJ
  91. $script = new TElement('script');
  92. $script->type = 'text/javascript';
  93. $javascript = "
  94. // personaliza os campos de acordo com o tipo de pessoa
  95. $( 'select[name=tpcliente]' ).change( function( event ){ var tipoPessoa $( 'select[name=tpcliente] > option:selected' ).each( function(){ tipoPessoa = $(this).text(); });
  96. if(tipoPessoa == 'PF') { $('input[name=CPFCNPJ]').val(''); $('input[name=CPFCNPJ]').attr( {onkeypress:'return tentry_mask(this,event,'999.999.999-99')'});}
  97. if(tipoPessoa == 'PJ') { $('input[name=CPFCNPJ]').val(''); $('input[name=CPFCNPJ]').attr( {onkeypress:'return tentry_mask(this,event,'99.999.999/9999-99')'});}
  98. }
  99. ";
  100. $script->add($javascript);
  101. parent::add($script);
  102. if (!empty($id))
  103. {
  104. $id->setEditable(FALSE);
  105. }
  106. // create the form actions
  107. $this->form->addQuickAction('Salvar', new TAction(array($this, 'onSave')), 'fa:floppy-o');
  108. $this->form->addQuickAction('Novo', new TAction(array($this, 'onClear')), 'bs:plus-sign green');
  109. $this->form->addQuickAction('Listagem', new TAction(array('ClientesList','onReload')), 'fa:table blue' );
  110. // creates a Datagrid
  111. $this->datagrid = new TDataGrid;
  112. ##LIST_DECORATOR##
  113. $this->datagrid->style = 'width: 100%';
  114. $this->datagrid->setHeight(320);
  115. // $this->datagrid->datatable = 'true';
  116. // $this->datagrid->enablePopover('Popover', 'Hi <b> {name} </b>');
  117. // creates the datagrid columns
  118. $column_id = new TDataGridColumn('id', 'Código', 'left');
  119. $column_tpcliente = new TDataGridColumn('tpcliente', 'PF/PJ', 'left');
  120. $column_CPFCNPJ = new TDataGridColumn('CPFCNPJ', 'CPF/CNPJ', 'left');
  121. $column_NomeRazao = new TDataGridColumn('NomeRazao', 'Nome/Razão', 'left');
  122. $column_Logradouro = new TDataGridColumn('Logradouro', 'Logradouro', 'left');
  123. $column_Bairro = new TDataGridColumn('Bairro', 'Bairro', 'left');
  124. $column_Cidade = new TDataGridColumn('Cidade', 'Cidade', 'left');
  125. $column_UF = new TDataGridColumn('UF', 'UF', 'left');
  126. $column_CEP = new TDataGridColumn('CEP', 'CEP', 'left');
  127. $column_Telefone01 = new TDataGridColumn('Telefone01', 'Telefone 01', 'left');
  128. $column_Telefone02 = new TDataGridColumn('Telefone02', 'Telefone 02', 'left');
  129. $column_idtributacao = new TDataGridColumn('tributacao->Tributacao', 'Tributação', 'left');
  130. // add the columns to the DataGrid
  131. $this->datagrid->addColumn($column_id);
  132. $this->datagrid->addColumn($column_tpcliente);
  133. $this->datagrid->addColumn($column_CPFCNPJ);
  134. $this->datagrid->addColumn($column_NomeRazao);
  135. $this->datagrid->addColumn($column_Logradouro);
  136. $this->datagrid->addColumn($column_Bairro);
  137. $this->datagrid->addColumn($column_Cidade);
  138. $this->datagrid->addColumn($column_UF);
  139. $this->datagrid->addColumn($column_CEP);
  140. $this->datagrid->addColumn($column_Telefone01);
  141. $this->datagrid->addColumn($column_Telefone02);
  142. $this->datagrid->addColumn($column_idtributacao);
  143. // creates two datagrid actions
  144. $action1 = new TDataGridAction(array($this, 'onEdit'));
  145. $action1->setUseButton(TRUE);
  146. //$action1->setButtonClass('btn btn-default');
  147. $action1->setLabel(_t('Edit'));
  148. $action1->setImage('fa:pencil-square-o blue fa-lg');
  149. $action1->setField('id');
  150. $action2 = new TDataGridAction(array($this, 'onDelete'));
  151. $action2->setUseButton(TRUE);
  152. //$action2->setButtonClass('btn btn-default');
  153. $action2->setLabel(_t('Delete'));
  154. $action2->setImage('fa:trash-o red fa-lg');
  155. $action2->setField('id');
  156. // add the actions to the datagrid
  157. /*
  158. $this->datagrid->addAction($action1);
  159. $this->datagrid->addAction($action2);
  160. */
  161. //Criação do grupo de ações
  162. $action_group = new TDataGridActionGroup('Ações','bs:th');
  163. $action_group->addHeader('Ações Disponíveis');
  164. $action_group->addAction($action1);
  165. $action_group->addAction($action2);
  166. $action_group->addSeparator();
  167. $action_group->addHeader('A desenvolver');
  168. //adicionando o action group no data grid
  169. $this->datagrid->addActionGroup($action_group);
  170. // create the datagrid model
  171. $this->datagrid->createModel();
  172. // creates the page navigation
  173. $this->pageNavigation = new TPageNavigation;
  174. $this->pageNavigation->setAction(new TAction(array($this, 'onReload')));
  175. $this->pageNavigation->setWidth($this->datagrid->getWidth());
  176. // vertical box container
  177. $container = new TVBox;
  178. $container->style = 'width: 90%';
  179. // $container->add(new TXMLBreadCrumb('menu.xml', __CLASS__));
  180. $container->add(TPanelGroup::pack('Title', $this->form));
  181. $container->add($this->datagrid);
  182. $container->add($this->pageNavigation);
  183. parent::add($container);
  184. }
  185. /**
  186. * Load the datagrid with data
  187. */
  188. public function onReload($param = NULL)
  189. {
  190. try
  191. {
  192. // open a transaction with database 'conexao'
  193. TTransaction::open('conexao');
  194. // creates a repository for Clientes
  195. $repository = new TRepository('Clientes');
  196. $limit = 10;
  197. // creates a criteria
  198. $criteria = new TCriteria;
  199. // default order
  200. if (empty($param['order']))
  201. {
  202. $param['order'] = 'id';
  203. $param['direction'] = 'asc';
  204. }
  205. $criteria->setProperties($param); // order, offset
  206. $criteria->setProperty('limit', $limit);
  207. if (TSession::getValue('Clientes_filter'))
  208. {
  209. // add the filter stored in the session to the criteria
  210. $criteria->add(TSession::getValue('Clientes_filter'));
  211. }
  212. // load the objects according to criteria
  213. $objects = $repository->load($criteria, FALSE);
  214. $this->datagrid->clear();
  215. if ($objects)
  216. {
  217. // iterate the collection of active records
  218. foreach ($objects as $object)
  219. {
  220. // add the object inside the datagrid
  221. $this->datagrid->addItem($object);
  222. }
  223. }
  224. // reset the criteria for record count
  225. $criteria->resetProperties();
  226. $count= $repository->count($criteria);
  227. $this->pageNavigation->setCount($count); // count of records
  228. $this->pageNavigation->setProperties($param); // order, page
  229. $this->pageNavigation->setLimit($limit); // limit
  230. // close the transaction
  231. TTransaction::close();
  232. $this->loaded = true;
  233. }
  234. catch (Exception $e) // in case of exception
  235. {
  236. // shows the exception error message
  237. new TMessage('error', '<b>Error</b> ' . $e->getMessage());
  238. // undo all pending operations
  239. TTransaction::rollback();
  240. }
  241. }
  242. /**
  243. * Ask before deletion
  244. */
  245. public function onDelete($param)
  246. {
  247. // define the delete action
  248. $action = new TAction(array($this, 'Delete'));
  249. $action->setParameters($param); // pass the key parameter ahead
  250. // shows a dialog to the user
  251. new TQuestion(TAdiantiCoreTranslator::translate('Do you really want to delete ?'), $action);
  252. }
  253. /**
  254. * Delete a record
  255. */
  256. public function Delete($param)
  257. {
  258. try
  259. {
  260. $key=$param['key']; // get the parameter $key
  261. TTransaction::open('conexao'); // open a transaction with database
  262. $object = new Clientes($key, FALSE); // instantiates the Active Record
  263. $object->delete(); // deletes the object from the database
  264. TTransaction::close(); // close the transaction
  265. $this->onReload( $param ); // reload the listing
  266. new TMessage('info', TAdiantiCoreTranslator::translate('Record deleted')); // success message
  267. }
  268. catch (Exception $e) // in case of exception
  269. {
  270. new TMessage('error', '<b>Error</b> ' . $e->getMessage()); // shows the exception error message
  271. TTransaction::rollback(); // undo all pending operations
  272. }
  273. }
  274. /**
  275. * Save form data
  276. * @param $param Request
  277. */
  278. public function onSave( $param )
  279. {
  280. try
  281. {
  282. TTransaction::open('conexao'); // open a transaction
  283. /**
  284. // Enable Debug logger for SQL operations inside the transaction
  285. TTransaction::setLogger(new TLoggerSTD); // standard output
  286. TTransaction::setLogger(new TLoggerTXT('log.txt')); // file
  287. **/
  288. $this->form->validate(); // validate form data
  289. $object = new Clientes; // create an empty object
  290. $data = $this->form->getData(); // get form data as array
  291. $object->fromArray( (array) $data); // load the object with data
  292. $object->store(); // save the object
  293. // get the generated id
  294. $data->id = $object->id;
  295. $this->form->setData($data); // fill form data
  296. TTransaction::close(); // close the transaction
  297. new TMessage('info', TAdiantiCoreTranslator::translate('Record saved')); // success message
  298. $this->onReload(); // reload the listing
  299. $this->form->clear();
  300. }
  301. catch (Exception $e) // in case of exception
  302. {
  303. new TMessage('error', $e->getMessage()); // shows the exception error message
  304. $this->form->setData( $this->form->getData() ); // keep form data
  305. TTransaction::rollback(); // undo all pending operations
  306. }
  307. }
  308. /**
  309. * Clear form data
  310. * @param $param Request
  311. */
  312. public function onClear( $param )
  313. {
  314. $this->form->clear(TRUE);
  315. }
  316. /**
  317. * Load object to form data
  318. * @param $param Request
  319. */
  320. public function onEdit( $param )
  321. {
  322. try
  323. {
  324. if (isset($param['key']))
  325. {
  326. $key = $param['key']; // get the parameter $key
  327. TTransaction::open('conexao'); // open a transaction
  328. $object = new Clientes($key); // instantiates the Active Record
  329. $this->form->setData($object); // fill the form
  330. TTransaction::close(); // close the transaction
  331. }
  332. else
  333. {
  334. $this->form->clear(TRUE);
  335. }
  336. }
  337. catch (Exception $e) // in case of exception
  338. {
  339. new TMessage('error', $e->getMessage()); // shows the exception error message
  340. TTransaction::rollback(); // undo all pending operations
  341. }
  342. }
  343. /**
  344. * method show()
  345. * Shows the page
  346. */
  347. public function show()
  348. {
  349. // check if the datagrid is already loaded
  350. if (!$this->loaded AND (!isset($_GET['method']) OR $_GET['method'] !== 'onReload') )
  351. {
  352. $this->onReload( func_get_arg(0) );
  353. }
  354. parent::show();
  355. }
  356. /*
  357. * Função de busca de Endereço pelo CEP
  358. * - Desenvolvido Felipe Olivaes para ajaxbox.com.br
  359. * - Utilizando WebService de CEP da republicavirtual.com.br
  360. */
  361. public function onCep($param)
  362. {
  363. $resultado = @file_get_contents('http://republicavirtual.com.br/web_cep.php?cep='.urlencode($param['CEP']).'&formato=query_string');
  364. if(!$resultado){
  365. //$resultado = "&resultado=0&resultado_txt=erro+ao+buscar+cep";
  366. new TMessage("error", "CEP - Em Branco ou Inválido");
  367. }
  368. parse_str($resultado, $retorno);
  369. $obj = new StdClass;
  370. $obj->CEP = $param['CEP'];
  371. $obj->Logradouro = strtoupper( $retorno['tipo_logradouro'].' '.$retorno['logradouro']);
  372. $obj->Bairro = strtoupper( $retorno['bairro']);
  373. $obj->Cidade = strtoupper( $retorno['cidade']);
  374. $obj->UF = strtoupper( $retorno['uf']);
  375. TForm::sendData('form_Clientes', $obj);
  376. }
  377. }
  378. ?>
NR

Igor, pela mensagem de erro parece ainda ser problema com as aspas.

Leildon, acho que faltou fechar um parêntese após o fechamento da última chave. E veja também minha resposta anterior sobre as contra-barras dentro de tentry_mask

Acrescente ");"

Na dúvida postem os códigos no pastebin
IU

Nataniel, eu já tirei as aspas duplas, mas nada ainda.
Eu preciso declarar esta variável em algum lugar antes de escrever o código ?
EU preciso escrever este código em algum arquivo separado, tipo .js e colocar um #include em no cabeçalho do classe ou no formulário ?


IU

Existe algo que é necessário fazer antes ou somente declarar a variável como está no código-fonte já era pra ter funcionado ?
Estou meio sem saída aqui.
Tentei várias formas:
 
  1. <?php
  2. $script = new TElement('script');
  3. $script->type('text/javascript');
  4.             $javascript =("
  5.             // personaliza a máscara da I.E. de acordo com o ESTADO  
  6.             $( 'select[name=estado]' ).change( function( event ){ var tipoEstado = $( 'select[name=estado]' ).val(); 
  7.             if(tipoEstado == 'AC') { $('input[name=ie]').val(''); $('input[name=ie]').attr( {onkeypress:'return tentry_mask(this,event,'99.999.999/999-99')'} ); }  
  8.           ......
  9.             if(tipoEstado == 'TO') { $('input[name=ie]').val(''); $('input[name=ie]').attr( {onkeypress:'return tentry_mask(this,event,'9999999999-9')'} ); }
  10.             ");
  11. ?>


Assim também não funcionou!
IU

 
  1. <?php
  2.   $javascript =
  3.             // personaliza a máscara da I.E. de acordo com o ESTADO  
  4.             $( 'select[name=estado]' ).change( function( event ){ var tipoEstado = $( 'select[name=estado]' ).val(); 
  5.             if(tipoEstado == 'AC') { $('input[name=ie]').val(''); $('input[name=ie]').attr( {onkeypress:'return tentry_mask(this,event,'99.999.999/999-99')'} ); }  
  6.             ....
  7.             if(tipoEstado == 'TO') { $('input[name=ie]').val(''); $('input[name=ie]').attr( {onkeypress:'return tentry_mask(this,event,'9999999999-9')'} ); }
  8.             ;
  9. ?>


Assim também não funcionou!
IU

Será que a versão do Adianti Studio 4.0 está com algum bug ?
NR

 
  1. <?php
  2. $script->type = "text/javascript";
  3. $javascript = "$( 'select[name=estado]' ).change( function( event )...";
  4. ?>

Ambos os códigos são strings, por isso precisam de aspas simples ou duplas no ínicio e no fim. Quando comentei que era pra tirar as aspas duplas estava me referindo as outras, presentes no meio da string.
IU

OK, alterado.
Ficou assim todo o código:

 
  1. <?php
  2. $script = new TElement('script');
  3. $script->type = "text/javascript";
  4. // personaliza a máscara da I.E. de acordo com o ESTADO
  5.             $javascript =
  6.             $( 'select[name=estado]' ).change( function( event ){ var tipoEstado = $( 'select[name=estado]' ).val(); 
  7.             if(tipoEstado == 'AC') { $('input[name=ie]').val(''); $('input[name=ie]').attr( {onkeypress:'return tentry_mask(this,event,'99.999.999/999-99')'} ); }  
  8.             if(tipoEstado == 'AL') { $('input[name=ie]').val(''); $('input[name=ie]').attr( {onkeypress:'return tentry_mask(this,event,'999999999')'} ); }
  9.             if(tipoEstado == 'AP') { $('input[name=ie]').val(''); $('input[name=ie]').attr( {onkeypress:'return tentry_mask(this,event,'9999999999')'} ); }
  10.             if(tipoEstado == 'AM') { $('input[name=ie]').val(''); $('input[name=ie]').attr( {onkeypress:'return tentry_mask(this,event,'99.999.999-9')'} ); }
  11.             if(tipoEstado == 'BH') { $('input[name=ie]').val(''); $('input[name=ie]').attr( {onkeypress:'return tentry_mask(this,event,'999999-99')'} ); }
  12.             if(tipoEstado == 'CE') { $('input[name=ie]').val(''); $('input[name=ie]').attr( {onkeypress:'return tentry_mask(this,event,'99999999-9')'} ); }
  13.             if(tipoEstado == 'DF') { $('input[name=ie]').val(''); $('input[name=ie]').attr( {onkeypress:'return tentry_mask(this,event,'99999999999-99')'} ); }
  14.             if(tipoEstado == 'ES') { $('input[name=ie]').val(''); $('input[name=ie]').attr( {onkeypress:'return tentry_mask(this,event,'99999999-9')'} ); }
  15.             if(tipoEstado == 'GO') { $('input[name=ie]').val(''); $('input[name=ie]').attr( {onkeypress:'return tentry_mask(this,event,'99.999.999-9')'} ); }
  16.             if(tipoEstado == 'MA') { $('input[name=ie]').val(''); $('input[name=ie]').attr( {onkeypress:'return tentry_mask(this,event,'99999999-9')'} ); }
  17.             if(tipoEstado == 'MT') { $('input[name=ie]').val(''); $('input[name=ie]').attr( {onkeypress:'return tentry_mask(this,event,'9999999999-9')'} ); }
  18.             if(tipoEstado == 'MS') { $('input[name=ie]').val(''); $('input[name=ie]').attr( {onkeypress:'return tentry_mask(this,event,'99999999-9')'} ); }
  19.             if(tipoEstado == 'MG') { $('input[name=ie]').val(''); $('input[name=ie]').attr( {onkeypress:'return tentry_mask(this,event,'999.999.999/9999')'} ); }
  20.             if(tipoEstado == 'PA') { $('input[name=ie]').val(''); $('input[name=ie]').attr( {onkeypress:'return tentry_mask(this,event,'99-999999-9')'} ); }
  21.             if(tipoEstado == 'PB') { $('input[name=ie]').val(''); $('input[name=ie]').attr( {onkeypress:'return tentry_mask(this,event,'99999999-9')'} ); }
  22.             if(tipoEstado == 'PR') { $('input[name=ie]').val(''); $('input[name=ie]').attr( {onkeypress:'return tentry_mask(this,event,'999.99999-99')'} ); }
  23.             if(tipoEstado == 'PE') { $('input[name=ie]').val(''); $('input[name=ie]').attr( {onkeypress:'return tentry_mask(this,event,'9999999-99')'} ); }
  24.             if(tipoEstado == 'PI') { $('input[name=ie]').val(''); $('input[name=ie]').attr( {onkeypress:'return tentry_mask(this,event,'99999999-9')'} ); }
  25.             if(tipoEstado == 'RJ') { $('input[name=ie]').val(''); $('input[name=ie]').attr( {onkeypress:'return tentry_mask(this,event,'99.999.99-9')'} ); }
  26.             if(tipoEstado == 'RN') { $('input[name=ie]').val(''); $('input[name=ie]').attr( {onkeypress:'return tentry_mask(this,event,'99.999.999-9')'} ); }
  27.             if(tipoEstado == 'RS') { $('input[name=ie]').val(''); $('input[name=ie]').attr( {onkeypress:'return tentry_mask(this,event,'999/9999999')'}); }
  28.             if(tipoEstado == 'RO') { $('input[name=ie]').val(''); $('input[name=ie]').attr( {onkeypress:'return tentry_mask(this,event,'9999999999999-9')'} ); }
  29.             if(tipoEstado == 'RR') { $('input[name=ie]').val(''); $('input[name=ie]').attr( {onkeypress:'return tentry_mask(this,event,'99999999-9')'} ); }
  30.             if(tipoEstado == 'SC') { $('input[name=ie]').val(''); $('input[name=ie]').attr( {onkeypress:'return tentry_mask(this,event,'999.999.999')'} ); }
  31.             if(tipoEstado == 'SP') { $('input[name=ie]').val(''); $('input[name=ie]').attr( {onkeypress:'return tentry_mask(this,event,'999.999.999.999')'} ); }
  32.             if(tipoEstado == 'SE') { $('input[name=ie]').val(''); $('input[name=ie]').attr( {onkeypress:'return tentry_mask(this,event,'99999999-9')'} ); }
  33.             if(tipoEstado == 'TO') { $('input[name=ie]').val(''); $('input[name=ie]').attr( {onkeypress:'return tentry_mask(this,event,'9999999999-9')'} ); }
  34.             ";
  35. ?>


Parse error: parse error in C:wamp64wwwitisu420sistema2appcontrolClienteClienteForm.class.php on line 40
Errors parsing C:wamp64wwwitisu420sistema2appcontrolClienteClienteForm.class.php
IU

Neste caso a linha 40 que ele se refere é essa:

 
  1. <?php
  2. $javascript =
  3. ?>
IU

Acredite, não mudou nada, tentei todas as formas, infelizmente.
NR

Executei o código que passou e funcionou. Às vezes pode ser cache do WAMP. Veja se consegue desabilitar o cache ou crie um novo arquivo para testar.
IU

Fatal error: Uncaught Error: Call to undefined function  new TElement() in C:wamp64wwwitisu420sistema2appcontrolClienteClienteForm.class.php
( ! ) Error: Call to undefined function  new TElement() in C:wamp64wwwitisu420sistema2appcontrolClienteClienteForm.class.php

Quando executei a página na web deu o erro acima. :/
IU

Limpei o cache e refiz novamente o código e desta vez não gerou erro de sintaxe. Porém ao executar o serviço na web ele gerou o erro:
"
Fatal error: Uncaught Error: Call to undefined function  new TElement() in C:wamp64wwwitisu420sistema2appcontrolClienteClienteForm.class.php
( ! ) Error: Call to undefined function  new TElement() in C:wamp64wwwitisu420sistema2appcontrolClienteClienteForm.class.php
"

IU

Agora refiz os códigos novamente e este erro sumiu, porém apareceu a pagina carregando (loop infinito) com o seguinte Aviso:

"Warning: create default object from empty value in C:...ClienteForm.php on line....
 
  1. <?php
  2. $javascript->type = "text/javascript";
  3. ?>

Mas neste caso estou vendo que seria o código de referência...porém como devo resolver isso. Criar um valor padrão para o campo ?
Se for como faço isso ?
IU

Agora refiz os códigos novamente e este erro sumiu, porém apareceu a pagina carregando (loop infinito) com o seguinte Aviso:

"Warning: create default object from empty value in C:...ClienteForm.php on line....
 
  1. <?php
  2. $javascript->type = "text/javascript";
  3. ?>

Mas neste caso estou vendo que seria o código de referência...porém como devo resolver isso. Criar um valor padrão para o campo ?
Se for como faço isso ?