0
I created a function (I’m doing some experiments) to generate input, textarea, select, etc, through Function. But the result is partial. There is no error in the function, but only what is text (without being in the input) appears and the input is shown in the source code, but in the same page, nothing comes.
Code:
// type (textarea ou o type do input) | name | id | required (required ou vazio) | placeholder | Titulo que vem antes do input | conteudo é o echo do BD (pode ser um array quando para select | onlyread (onlyread ou vazio) | checked ou selected ou vazio | options (array com opções para select ou opções para radio e check | primeira serve para primeira opção em selects
function geraInput($type, $name, $id, $required, $place, $titulo, $conteudo, $onlyread, $checked, $options, $primeira){
$inp = '<div class="env_inputs">
<span class="tit_inputs">'.$titulo.'</span>
<input type="'.$type.'" name="'.$name.'" id="'.$id.'" '.$required.' '.$place.' value="'.$conteudo.'" '.$onlyread.'></div>';
return $inp;
}
In the function call:
echo geraInput("text", "teste1", "teste", "", "", "Teste:", $resumo, "", "", "", "");
In the source code:
<div class="env_inputs">
<span class="tit_inputs">Teste:</span>
<input type="text" name="teste1" id="teste" value="<p>Casa nova, com 2 dormitorios, banheiro, sala de jantar e estar, 2 vagas de garagem, cozinha, área de serviço, churrasqueira. </p>
<p>Pronta para finaciar e morar !!</p>">
</div>
Onscreen:
Teste:
Its variable
$conteúdo
has html element<p><\p>
and so tah bugging his element<input>
– Jhonny Mesquita
So, thanks for the answer, first. I put a strip_tags on the variable that fills the value and did not change the result on the screen. In the source code the <p> disappeared, but did not change the result on screen.
– Vítor André
Tried different browsers? I tested here on Chrome 49 and functioned normal, including the html you posted.
– Jhonny Mesquita
Which browser are you using to test? Which
doctype
is defined in HTML? What is the content of cssenv_inputs
? There is some other css style for elements<input>
?– Daniel Omine
Putz! Cara, thanks. The problem was not in the code. It was a div with id test that was in another include and had a css with diplay None. It was my fault. Sorry and thanks for the help.
– Vítor André