How can I get an input text value before submitting a form?

vsbr 10 Mar, 2009
Hello!

The code below works perfectly, except it does not read the "inputText" field value in $query = "... LIKE ('inputText.value').
How can I get this value correctly in the same form?

…
div class="form_item"><div class="form_element cf_textbox">
<label class="cf_label" style="width: 0px;" ></label>
<input class="cf_inputbox" type="text" autocomplete="off" id="inputText" name="inputText">
<div class="clear"> </div></div>

<div class=form_item>
<div class="form_element cf_hidden" style="DISPLAY: none" >
<label class=cf_label>Hidden_field</label>
<?php
    $db =& JFactory::getDBO();
    $query = "select codigo_ProtGeral FROM #__protocolo_geral WHERE titulo LIKE ('inputText.value');";
    $db->setQuery($query);
    $result = $db->loadResult();
?>
<input type="hidden" name="codigo_ProtGeral" id="codigo_ProtGeral" value="<?php echo $result;?>" >
</div><div class=clear> </div></div>

<div class="form_item"><div class="form_element cf_button">
<input type="button" name="seguinte" onclick="goNext(codigo_ProtGeral.value);" value="Seguinte" >
<input value="Limpar" type="reset"></div>
<div class="clear"> </div></div>
…


Thanks.
GreyHead 10 Mar, 2009
Hi vsbr,

I think you have your PHP and JavaScript mixed up. All the PHP (and none of the JavaScript) will run before the page loads. So, there is no way to use a JavaScript value in a PHP command.

Bob
vsbr 10 Mar, 2009
Hi, Bob!

Exactly, I just could not read the value in the php code.
However, I managed to resolve this issue otherwise.

Thanks again.
This topic is locked and no more replies can be posted.