Support

Home Forums Event Espresso Premium Changing form input values in Event Espresso (EE4)

Changing form input values in Event Espresso (EE4)

Posted: December 7, 2014 at 2:00 pm

Viewing 3 reply threads


David Cloutier

December 7, 2014 at 2:00 pm

Hi, new user of the plugin here. Hopefully Event Espresso can do what we’re looking to accomplish!

I’m attempting to pre-populate some form values using jquery. However, these scripts aren’t aren’t affecting the actual values in the checkout process with Event Espresso as expected.

So the code may be, for example:

<script type="text/javascript">
$('input[name=1-eb6066bfb62fa788537ebab6d09f1a7f-fname]').val('Hello');
</script>
[ESPRESSO_CHECKOUT]

(I found “1-eb6066bfb62fa788537ebab6d09f1a7f-fname” by examining the source HTML – it seems to be the same when the page is reloaded, but I imagine I’ll need to filter this down to the fname part at some point because I assume the first piece will change depending on the event)

Nothing happens to the first name field.

However, if I have:

<script type="text/javascript">
$('input[name=1-eb6066bfb62fa788537ebab6d09f1a7f-fname]').val('Hello');
</script>
<input name="1-eb6066bfb62fa788537ebab6d09f1a7f-fname" value="test">

(The value in the text box will successfully be replaced with “Hello”)

So I’m wondering if there’s something else that’s acting against what I’m trying to implement. Is there a better way to do this?

Cheers!


Dean

December 8, 2014 at 12:36 am

Hi,

Where and how are you adding the script? E.g. are you adding it directly to a template file (if so which one)? Or are you using a filter/action hook to inject the code?


David Cloutier

December 19, 2014 at 3:33 pm

Hi Dean,

Wow! Sorry I’m so late getting back to you.

I’ve tried inserting it in the template before and after the_content. I’ve also tried inserting it directly in the content, through WordPress (text/HTML editor).

Is there a template for a filter/action for accomplishing this particular action? That would actually be preferred.

Cheers!


Dean

December 22, 2014 at 12:12 am

Hi,

Personally I would hook into wp_footer like so:

function autofillstuff() {
	?>
<script type="text/javascript">
jQuery("#1-21496068d338af9e96294b0f0d52cde3-fname").val('Hello');
</script>

	<?php
}
add_action('wp_footer', 'autofillstuff', 10);

Also the issue you are having is you are using the input ID instead of the name, but they are different. Here is an example from my site:

ID = 1-21496068d338af9e96294b0f0d52cde3-fname
Name = qstn[1-21496068d338af9e96294b0f0d52cde3][fname]

Hope that helps!

Viewing 3 reply threads

The support post ‘Changing form input values in Event Espresso (EE4)’ is closed to new replies.

Have a question about this support post? Create a new support post in our support forums and include a link to this existing support post so we can help you.

Event Espresso