Hi,
I am trying to achieve the following:
I calculate a price based on the input of some fields from a multipage form and want to transfer this price into the database table. The php code is like:
This results in an html page with the following source code:
So in the first echo the value of the variable $price is printed, but the second echo is not only not working, but the parameters of the hidden field get messed up somehow. I am not able to set the value with a php statement, and if I do not write the value parameter at all, still the parameter value appears in the html source and is set as empty.
However, I did see this form working some days ago, as I have values in the price field in my database. And nothing changed in the code since then.
This is weird and I have no clue whats going on. I feel as a complete idiot at the moment, maybe I overlook something too obvious?
Is there a more elegant method than the hidden field to put values into the database table?
Cheers, Stefan
I am trying to achieve the following:
I calculate a price based on the input of some fields from a multipage form and want to transfer this price into the database table. The php code is like:
<?php
if ( !$mainframe->isSite() ) { return; }
$session =& JFactory::getSession();
$posted = $session->get('chrono_formpages_data_online_anmeldung',
array(),
md5('chrono'));
...some php code here...
$price = calculated some value
echo "your price is ".$price." EUR."
?>
... some html code ...
<div class="form_item">
<div class="form_element cf_button"><input value="Send" name="button_3" type="submit"><input value="<?php echo $price; ?>" name="price" type="hidden" ></div>
<div class="cfclear"> </div>
</div>
This results in an html page with the following source code:
...
your price is 235 EUR.
<div class="form_item">
<div class="form_element cf_button"><input value="Send" name="button_3" type="submit"><input name="price" value="" type="hidden" ></div>
<div class="cfclear"> </div>
</div>
...
So in the first echo the value of the variable $price is printed, but the second echo is not only not working, but the parameters of the hidden field get messed up somehow. I am not able to set the value with a php statement, and if I do not write the value parameter at all, still the parameter value appears in the html source and is set as empty.
However, I did see this form working some days ago, as I have values in the price field in my database. And nothing changed in the code since then.
This is weird and I have no clue whats going on. I feel as a complete idiot at the moment, maybe I overlook something too obvious?
Is there a more elegant method than the hidden field to put values into the database table?
Cheers, Stefan
crazy... I tried this:
and it renders
as before, different quotes, and the value statement replaced by an empty value statement.
Seems like something is mangling the rendered html-code? WTF?
Confused, Stefan
<?php echo"<input type='hidden' name='price' value='".$price."' />"; ?>
and it renders
<input type='hidden' name="price" value="" />
as before, different quotes, and the value statement replaced by an empty value statement.
Seems like something is mangling the rendered html-code? WTF?
Confused, Stefan
Hi Stefan,
I've used code like this dozens of times, maybe hundreds and it all looks OK to me.
Posibly there is some other syntax error on the page that ripples through? If republish is enabled that might be having some effect but unlikely.
At the moment I'm baffled too.
Please post a link to the form so we can take a quick look.
Bob
I've used code like this dozens of times, maybe hundreds and it all looks OK to me.
Posibly there is some other syntax error on the page that ripples through? If republish is enabled that might be having some effect but unlikely.
At the moment I'm baffled too.
Please post a link to the form so we can take a quick look.
Bob
Hi,
in fact: if i turn off "try to republish", the value parameter is getting written correctly. I think, because this field is not defined anywhere prior, the republish mechanism sets it to an empty default, regardless, if this is a hidden field.
Thank you for mentioning this! Now I can go and think further how to solve my navigation problems with this form ;-)
Best regards, and do not drink all the beer at once,
Stefan
in fact: if i turn off "try to republish", the value parameter is getting written correctly. I think, because this field is not defined anywhere prior, the republish mechanism sets it to an empty default, regardless, if this is a hidden field.
Thank you for mentioning this! Now I can go and think further how to solve my navigation problems with this form ;-)
Best regards, and do not drink all the beer at once,
Stefan
This topic is locked and no more replies can be posted.