0

Is there a way to prefill form fields in WordPress using Javascript? [closed]

I have a weird request, but it is probably a more common need now that I think about it. I want to use an ONTRAPORT Smart Form inside of WordPress and have the fields prefilled with the logged in user's information. How can I do that?

edit retag flag offensive reopen merge delete

Closed for the following reason the question is answered, right answer was accepted by Frank
close date 2016-08-30 07:40:32.071139

1 answer

Sort by » oldest newest most voted
0

Our QA developer Anthony Baldwin developed this code to do so. Note that we cannot train you on how to use Javascript, but your developer will know how this works:

<script type="text/javascript">

var count = $('input[name*="email"]').length;

var current = 0;

var contactfirst = "[pilotpress_field name='First Name']";

var contactlast = "[pilotpress_field name='Last Name']";

var contactemail = "[pilotpress_field name='Email']";

while (current<count) {

document.getElementsByName('firstname')[current].value = contactfirst;

document.getElementsByName('lastname')[current].value = contactlast;

document.getElementsByName('email')[current].value = contactemail;

current++;

}

</script>

edit flag offensive delete publish link more

Question Tools

1 follower

Stats

Asked: 2016-02-17 07:15:15 -0700

Seen: 61 times

Last updated: Feb 17 '16