Title: FM Javascript question
Last modified: August 21, 2016

---

# FM Javascript question

 *  [Thorworx](https://wordpress.org/support/users/thorworx-1/)
 * (@thorworx-1)
 * [12 years, 5 months ago](https://wordpress.org/support/topic/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?
 * [http://wordpress.org/plugins/wordpress-form-manager/](http://wordpress.org/plugins/wordpress-form-manager/)

The topic ‘FM Javascript question’ is closed to new replies.

 * ![](https://s.w.org/plugins/geopattern-icon/wordpress-form-manager.svg)
 * [Form Manager](https://wordpress.org/plugins/wordpress-form-manager/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/wordpress-form-manager/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/wordpress-form-manager/)
 * [Active Topics](https://wordpress.org/support/plugin/wordpress-form-manager/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/wordpress-form-manager/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/wordpress-form-manager/reviews/)

 * 0 replies
 * 1 participant
 * Last reply from: [Thorworx](https://wordpress.org/support/users/thorworx-1/)
 * Last activity: [12 years, 5 months ago](https://wordpress.org/support/topic/fm-javascript-question/)
 * Status: not resolved