Población indirecta de Textarea en formulario HTML usando PHP
Frecuentes
Visto 63 equipos
0
I am working on an "Update User Data" form, which should reflect the initially entered information stored in the database into the textarea, and can be changed if the user wishes to. While I'm doing so, I have a concern - is directly writing value = <?php //some code ?>
the safest bet?
I was trying to invoke a function to place my PHP code in that instead, but apparently it's just displaying the function's name.
Aquí está mi fragmento de código:
<div>Date of Birth: </div>
<input id="dob" type="date" onFocus="emptyElement('status')" value="reflect_data('dob');">
where the function reflect_data is defined as -
function reflect_data(elem) {
//query and some code to access the data and store into $member
if (elem == "dob") {
echo $member['DOB'];
exit();
}
NOTE : A newbie to PHP, any advice would be welcome. Thanks. :)
1 Respuestas
0
You use php code in a JS function. That won't work that way and is impractical. Simple:
<input id="dob" type="date" onFocus="emptyElement('status')" value="<?php echo htmlspecialchars($member['DOB']); ?>">
es la mejor solución
Respondido el 12 de junio de 14 a las 10:06
No es la respuesta que estás buscando? Examinar otras preguntas etiquetadas javascript php html or haz tu propia pregunta.
Once the browser receives the web page, php has long forgotten about the page that you are seeing. value = <?php //some code ?> is about the only way to show data immediately unless you want to go the Ajax route. - user2417483
Oh, Okay. Thanks for the technical explanation, @jeff, makes sense now. :) - VGupta