1

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.

Iain Simpson
  • 441
  • 4
  • 13
  • 29

1 Answers1

1

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
    )
);
Community
  • 1
  • 1
Jesse Bunch
  • 6,651
  • 4
  • 36
  • 59
  • Cool, I like the look of that, I will have a look and see if I can get it working, thanks :-) – Iain Simpson Jan 02 '12 at 23:57
  • It seems to work pretty well, one thing im not sure of though it says : – Iain Simpson Jan 03 '12 at 00:10
  • var edButtons = new Array(); var edLinks = new Array(); var edOpenTags = new Array(); function edButton(id, display, tagStart, tagEnd, access, open) { this.id = id; // used to name the toolbar button this.display = display; // label on button this.tagStart = tagStart; // open tag this.tagEnd = tagEnd; // close tag this.access = access; // set to -1 if tag does not need to be closed this.open = open; // set to -1 if tag does not need to be closed } edButtons.push( new edButton( 'ed_bold' ,'Name' ,'{leadname}' ,'{leadname}' ) ); – Iain Simpson Jan 03 '12 at 00:10
  • but I am not sure where to add ------ this.open = open; // set to -1 if tag does not need to be closed – Iain Simpson Jan 03 '12 at 00:10
  • } edButtons.push( new edButton ( 'access'='-1' ,'open'='-1' ,'ed_bold' ,'Name' ,'{leadname}' ,'{leadname}' ) – Iain Simpson Jan 03 '12 at 00:21