Highlight certain words with JavaScript

  •  06-03-2009, 12:04 PM

    Highlight certain words with JavaScript

    Hi,
     
    I hope there is a solution to my problem.
    One of the major uses of CuteEditor for me is a "Data Aware" email template editor. The "data aware fields" are defined by {field_name}.
     
    I would like for the editor to behavior similar to Crystal Reports in that when a field is clicked, the entire field is highlighted, which prevents the user from directly editing the field's text. (The fields are added by clicking anywhere in the body then selecting the appropriate field from a listbox).
     
    I need to be able to 
     
    1. Get the line text of the selected line, and carat position
    2. Determine if the click was inside a field (I should be able to do this using regex once I get the line text, and carat position)
    3. If so, highlight the entire field
     
    I would like to do all of this in JavaScript
     
    Sample text
    ______________________________________
    Dear {Recipient_Name}:

    Receipt of this letter confirms your registration for the upcoming {company} dinner meeting: “{Meeting_Title}” and “{Meeting_Description}”. Details as follows:

    {start_date_Long}
     
    {venue_name}
    {venue_address1}
    {venue_city}, {venue_state} {venue_zip}
    {venue_phone}

    Speaker: {Speaker_Name}, {Speaker_Credential}
    ...
    ______________________________________
     

     
     
View Complete Thread