Error referencing id containing $

Forums General discussion Error referencing id containing $

Viewing 2 reply threads
  • Author
    • #22934
      Darin Davis

      BACKGROUND: I need to copy the value of one field to another if a condition is met. This is what I have so far (just for testing/learning):

      function copyOneTimeFactor(factor){
          if (factor === "oneTimeFactorAmt1") {
              alert("Called by " + factor + " rule. onetimeAmt1 = " + jQuery("#onetimeAmt1_cc2ba976-715e-44b1-a3e3-a2c6f5992382_$CurrencyField").val);

      I copied the input field id from Chrome Developer Tools (screen capture attached).

      In testing the custom JS, I’m getting the message:

      Syntax error, unrecognized expression: #onetimeAmt1_cc2ba976-715e-44b1-a3e3-a2c6f5992382_$CurrencyField

      (screen capture attached)

      If I remove the $, instead of an error message, I get 12 lines of unintelligible code as the (apparent) value of the input field (screen capture attached).

      QUESTION: What is wrong with the way I’m referencing the field ID so that it constitutes a syntax error? Is there a better way to accomplish my goal than using jQuery to get/set the values of input form fields?

      Thanks for any assistance!

    • #22945
      Alexander Bautz

      Addressing an item with id containing $ requires that you escape it like this:


      You can however use this approach instead:

      var value = getFieldValue("onetimeAmt1"); // Please verify the field name
      // Copy it to another field


    • #22947
      Darin Davis

      Thank you very much, Alexander!


Viewing 2 reply threads
  • You must be logged in to reply to this topic.