Export to Email popup: dynamically set "To" field

This public forum is for user-to-user discussions of PHPMaker. Note that this is not support forum.
Post Reply
Satrapo
User
Posts: 41

Export to Email popup: dynamically set "To" field

Post by Satrapo »

Hello,

I have a table with 3 fields (name - email - personalcode)

When I click to EXPORT-TO-EMAIL I need to fill the TO field with the email value.

I Know I can edit the ewemail10.php (setting recipient value to <?php echo CurrentPage()->email->CurrentValue; ?>

But how can I do it from phpmaker without edit php files?

I'm using v 10.0.4

Thanks!


danielc
User
Posts: 1601

Post by danielc »

You may consider to use jQuery("#ewEmailForm input[name=recipient]").val("setyourvalue") (see api.jquery.com/val/) to add your recipient email address. Use Startup script to add your JavaScript, see Server Events and Client Scripts in the help file.


Satrapo
User
Posts: 41

Post by Satrapo »

This works:

$("#sender").val("SetMyValue");

But only if I put it in: Client Scripts - GLOBAL - Startup Script

In table specific Startup Scripts it doesn't works because is fired before the email form is rendered.


danielc
User
Posts: 1601

Post by danielc »

You have to wait until DOM fully loaded to execute your code:
$(function() {
//your script
});


Satrapo
User
Posts: 41

Post by Satrapo »

Thanks!


marisoft
User
Posts: 209

Post by marisoft »

Hi,

In the Client script > Table specific > View page > Startup script I have:

$(function() {
jQuery("#ewEmailForm input[name=message]").val("Hermed fremsendes oplysninger fra brugerregistreringen i intranettet. - Med venlig hilsen - Administratoren")
jQuery("#ewEmailForm input[name=subject]").val("Brugerregistrering")
jQuery("#ewEmailForm input[name=sender]").val("admin@sdomaine.org")

jQuery("#ewEmailForm input[name=recipient]").val("What to put here ?")
})

But how to fil the recipient email from the databaserecord I am viewing ?

The viewpage has this for the field in question:
<tr id="remail">
<td><span id="elh_mols_brugere
email">Email</span></td>
<td>
<span id="el_mols_brugere__email" class="form-group">
<span>
username@userdomain.com</span>
</span>
</td>
</tr>

Hope I can fill this dynamically.

TIA
/Poul


danielc
User
Posts: 1601

Post by danielc »

Use jQuery .text to get the text content (see api.jquery.com/text/):
$toemail = $("#el_mols_brugere__email").text();


marisoft
User
Posts: 209

Post by marisoft »

Thanks danielc.

Works great.


Post Reply