Auto populate on page load

Permalink Browser Info Environment
Hi Team,

Love the add-on. Is there a way to populate a field on page load using html that I code into the "header extra content?"

For example, I want to use the same form on multiple pages, but I want one of the text boxes to populate with different informaiton based on code in the header extra content field.

Thanks for you quick response!

David

Type: Discussion
Status: New
davidjp2
View Replies:
jgarcia replied on at Permalink Reply
jgarcia
Yeah, you could do something like this:

On the Advanced Forms admin, edit the field and assign a unique value to Field CSS Class. Then on the page, add the following JavaScript (jQuery):

$(document).ready(function() {
    $('.the-new-class').val('The New Value)';
});


Where "the-new-class" is the class you specified and "The New Value" is the value you want to set.
davidjp2 replied on at Permalink Reply
davidjp2
Awesome. This works. Thanks for the fast response. Just as a head's up...there was a slight error in the code. I moved the " ' " into the " ) " after The New Value. Code below works.


<script>
$(document).ready(function() {
$('.the-new-class').val('The New Value');
});
</script>
FatTony1952 replied on at Permalink Reply
FatTony1952
I assume this solution also work in pulling page names into the .val as getCollectionName(). I need to populate a select box with page names from beneath a particular page. I'm thinking that I would need to use a helper as well, but I'm not sure.
FatTony1952 replied on at Permalink Reply
FatTony1952
Or, from reading through the How-To's, maybe this...?

filterByParentID(array(pageId)); if ($num > 0) { $cArray = $pl->getPage(); } else { $cArray = $pl->get(); } ?>

concrete5 Environment Information

Browser User-Agent String

Hide Post Content

This will replace the post content with the message: "Content has been removed by an Administrator"

Hide Content

Request Refund

You have not specified a license for this support ticket. You must have a valid license assigned to a support ticket to request a refund.