CA Service Management

  • 1.  JavaScript function help - copy and prepend text

    Posted Jan 19, 2016 04:06 PM

    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?/



  • 2.  Re: JavaScript function help - copy and prepend text

    Posted Jan 22, 2016 05:15 PM

    Hi Grant,

     

    If you use jquery() on htmpl files, "$"  sign use with ->"$$".

     

    when use " $$('txt2') " like, the web engine convert " $('txt2')  " when generate to html.

     

    if you use " $('txt2') ", convert to " ('txt2') " so gets javascript error.

     

    Because of web engine is recognize as "args" pre sign "$"

     

    I hope it's helpful for you

     

    Regards,

     

    Türker