5 Replies Latest reply on Jul 17, 2012 10:09 AM by Jon Tara

    JavaScript used on a form - won't load automatically

    Jeffrey Cookle

      I have a form that I am working on that uses JavaScript to hide/show items based on what the user selects.    The JavaScript is in my new.erb at the top:



      function woTypeEmergency()



                  document.getElementById("woType").style.display = "block";

                  document.getElementById("woDesc").style.display = "block";

                  document.getElementById("woTypeModify").style.display = "none";

                  document.getElementById("createButton").style.display = "block";

                  document.getElementById("workorder[emergency]").value = "YES";

                  document.getElementById("workorder[priority]").value = "1";





      And is called when a button is pressed by the user to indicate a type of order they are creating:


      <input type="button" value="YES" onClick="javascript:woTypeEmergency()"/>


      When the new form loads, the javascript doesn't load and I get an error that it can't find woTypeEmergency, but if I right-click and do a reload, then the page works fine.


      Any ideas???   I have tried putting the .js in a file and that didn't seem to do it either.  If I remove the JQuery .js files from the layout.erb, then it works perfectly and loads when the form loads.


      I am seeing the behavior using both the RhoSimulator and when I deploy to an Android Device using MotorolaRhoMobileSuite2.0.5


      Thank you!