FM Javascript question
-
I am trying to change the value of a hidden form field using javascript. I set up the field with a nickname and I’m using a condition to hide it.
The value needs to come from a php variable on the page that the form is displayed on.
php:$tempDate = $event->get_timespan_html(); $tempDate = print_r($tempDate, true);Since I can’t seem use any php variables in my custom fm form template or in a FM note field for javascript, I’m trying to use some javascript before the form template loads:
javascript:window.onload=function(){ var eDate = fm_get_form_item('eventdate'); eDate.value = <?php echo $tempDate ?>; };This doesn’t work. Although I do get the correct value in the script, the “eventdate” form field does not populate. Upon submitting the form, the “eventdate” form field remains empty. And of course my e-mail template does not show the eventdate value.
Any ideas on how to get this to work?
The topic ‘FM Javascript question’ is closed to new replies.