Question

I am not even sure if this is even possible or how easy it is, but what I am trying to work out is how to, if it is possible, to use jquery or javascript to insert an alias for a form field / curly brackets where the cursor currently is selected on the page.

Let me try and explain it a bit better.......

So I go to the email template form, on the right of the form I have 3 buttons,

NAME , REP , DATE
Name = {leadname}
Business Name = {businessname}
Date = {datesent}

These are all form fields being posted into the $form->data array when it loads.

I start writing out my template so.......Dear {leadname} etc etc when the template is sent, it loads the clients name etc into the curly brackets and sends it in an email.

What I am trying to do is make this so that someone doesnt write leadname for the persons name but presses the button to the right of the form marked 'Name' , this then inserts [Name] or maybe Name in bold into the form, but this is actually an alias of {leadname} , so im not sure if I have to change my language file too to get this to work ?, im also not sure how to actually insert these fields into my template form field.

Was it helpful?

Solution

Is this kind of what you're talking about doing? http://alexking.org/projects/js-quicktags/demo/index.html

If so, I think this guys implementation of JavaScript quick tags will get you going: http://alexking.org/blog/2004/06/03/js-quicktags-under-lgpl/

Otherwise, this post may help you out: Inserting a text where cursor is using Javascript/jquery

-

Edit

Here's the code you need, using Alex King's plugin to create a button that doesn't get closed:

edButtons.push(
    new edButton(
        'leader_name'
        ,'LEADER'
        ,'{leadname}'
        ,-1
        ,-1
    )
);
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top