We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 8921
    • 55 Posts
    Hi Bob and everyone else!

    I have a NewsPublisher form that is loading several select TV's that have strictly numerical options. Basically I want to take these and sum them up in to a "Total Amount" TV that is a standard numeric TV. I know I can do this easily with javascript, but can't get my head around the way NewsPublisher dynamically builds the form or where those templates even are. So a different and probably better approach would be in some way to use @eval as an input option on the total amount TV. This would have the added benefit of also working if I happen to edit the resource via the manager rather than NewsPublisher. Is this even possible? Am I off my rocker?

    PS. Thanks Bob for creating such an awesome add-on!

    K.
      • 3749
      • 24,544 Posts
      Using @eval in a front-end form is asking for trouble, security wise and it would be pretty involved @eval at that. I think your JavaScript idea is much better.

      Just do a "View Source" on the form and you'll see the IDs for the TVs, then put the JS to do what you want in a file and include in the Template used for the NewsPublisher resource (the one with the NewsPublisher snippet tag.
        Did I help you? Buy me a beer
        Get my Book: MODX:The Official Guide
        MODX info for everyone: http://bobsguides.com/modx.html
        My MODX Extras
        Bob's Guides is now hosted at A2 MODX Hosting
        • 8921
        • 55 Posts
        Thanks for your response. I went the Javascript route and it works a treat! For those that are interested in my solution, below is a link to a JSFiddle that has the javascript & html. Make sure you're loading jquery on the page. I placed the javascript right after the newspublisher call.

        http://jsfiddle.net/Za42G/56/

        Thanks again!
          • 3749
          • 24,544 Posts
          Very slick solution. smiley
            Did I help you? Buy me a beer
            Get my Book: MODX:The Official Guide
            MODX info for everyone: http://bobsguides.com/modx.html
            My MODX Extras
            Bob's Guides is now hosted at A2 MODX Hosting