AnsweredAssumed Answered

JavaScript function help - copy and prepend text

Question asked by Grant Bruneau Champion on Jan 19, 2016
Latest reply on Jan 22, 2016 by birolturker.kara

Hi Community,

 

I've been dabbling in JavaScript recently and know enough to be dangerous.  I had a suggestion from a business owner who wants to be able to copy text from one textbox and prepend it to another textbox.  I've found several working examples of this from Google but I'm having trouble getting this to work, I'm not even sure it's possible.  Any input is appreciated.

 

I'm working on a customized detail_alg.htmpl form and have defined the following function in the script block.  I'm trying to take the contents of zCurrentStatus and prepend them to the zHistory textbox

function prependText() {
    var txt1 = "$args.zCurrentStatus";              // Create text with HTML
  var txt2 = "$args.zHistory";
    $("txt2").prepend(txt1);       // Prepend new elements
}

 

Next to my textbox I placed a checkbox with an event handler firing off the function.

<PDM_MACRO name=dtlCheckbox hdr="Copy to History" attr="" evt="onclick=prependText()">

 

After checking the Copy to History checkbox the console displays the following message.  It appears to not like the .prepend jQuery control.  Perhaps there's a different way to do this?/

Outcomes