Field Messages - showFieldMsg()
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-10-2012 01:01 PM
I need help embedding a link into a field message.
I have tried the following...
var str = "here";
if (g_form.getValue('service_type') == 'System Request') {
g_form.showFieldMsg('service_type', 'You are submitting a system request; please provide the following additional information regarding your request: \nCost/Benefit Analysis (Please complete the spreadsheet found ' + str.link('www.something_here.com') + ' and attach to this request using the paperclip icon)', 'info', false);
}
The result was...
You are submitting a system request; please provide the following additional information regarding your request: Cost/Benefit Analysis (Please complete the spreadsheet found a href="www.something_here.com">here a and attach to this request using the paperclip icon)
Any help on this would be great. Thanks!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-10-2012 04:04 PM
Here is a previous question with some information and a potential solution:
Generate link in client script gs.showFieldMsg
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-10-2012 05:02 PM
I replicated what you did and traced the JavaScript code (a great way to learn, by the way) and it appears that the developers used the DOM method createTextNode () to create the text in the message. Because they used that method call it does not "translate" the embedded HTML you have passed in.
var fieldmsgDiv = doc.createElement('DIV');
fieldmsgDiv.className = msgClass;
fieldmsgTd.appendChild(fieldmsgDiv);
var fieldmsgImg = doc.createElement('IMG');
fieldmsgImg.src = msgImage;
fieldmsgImg.alt = msgImageAlt;
fieldmsgDiv.appendChild(fieldmsgImg);
var fieldmsgMsg = doc.createTextNode(message); // <---- This is the method call.
fieldmsgDiv.appendChild(fieldmsgMsg);
So, there does not appear to be any way to inject HTML into the showFieldMsg method as they intend that parameter to be pure text.
That doesn't mean that you can't possibly grab the element after it is generated (by walking the DOM), parse out the text, and inject your own HTML, but: a) that obviously is not trivial, and b) you have no way of knowing if that will somehow upset the SN code as the
Interesting problem. Thanks for posting.
Dale Hurtt
http://dales-tech-notes.blogspot.com
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-03-2018 10:15 AM
Hi Dale,
This does not seem to work in Kingston version. Also, your blogs are no longer available. Please help.
Thanks
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-10-2012 07:25 PM
One thing I noted while sniffing around is that Prototype is automatically loaded to the client (probably with every page), so you can probably rely on that being there always. That was one question I asked in the Scripting class that wasn't answered.
Thanks for the link.
Dale