+ Start a Discussion
lil_rangerlil_ranger 

Script to update value

<script>
   function defaultEmployeeTermForm(val) {
       var j$ = jQuery.noConflict();
   
       j$("input[id*='Status_Id']").attr("value", "Submitted By Manager");
   }
</script>

 Any ideas on what is wrong with this?  When the user saves the form I need the Status_Id to be updated to "Submitted By Manager".

 

 

ClintLeeClintLee

If you're using an apex component like apex:inputField for your input, then the id is dynamically generated so using just the id name to get the element won't work.  There are a number of blog posts out there discussing this issue, I know Wes Nolte has posted on this at his blog - http://th3silverlining.com

 

Try the following.  For example purposes, I'm assuming you have an apex:inputField with id of "Status_Id".

 

<script type="text/javascript">

 

   var j$ = jQuery.noConflict

 

   var statusid = {!$Component.Status_Id};

 

   function jq( myid ) { 

       return '#' + myid.replace(/(:|\.)/g,'\\\\$1');

   }

 

   function defaultEmployeeTermForm( val ) {

       j$( jq( statusid ) ).attr( "value", "Submitted By Manager" );

   }

 

</script>

 

 

<apex:inputField id="Status_Id" value="" />

 

Hope that helps!

 

~ Clint