Onload Function Error

Hi,

i try to update the record and render the _form.php, but the onload function does not working while i click on the update button under the admin.php.

however, for the create form and render to _form.php. it is working fine. i doe snot know what is the problem that cause this error.

can someone help me on it?

below is my code:

<script type="text/javascript">

<!–

onload = function()


{	


	alert(&quot;hello&quot;);


	


	var newRecord=&lt;?php echo &#036;model-&gt;isNewRecord; ?&gt;;


	


	if(newRecord==1)


		fillDisclevel_DetailsNew();


	else


		fillDisclevel_Details();


}

//–>

</script>

<script type="text/javascript">

<!–

function fillDisclevel_DetailsNew()

{

var urlPath= 'http://'+ window.location.host+'/yii/systempos/ajax.php?CMD=getLevelDetails';		





&#036;.ajax({


    url: urlPath,


    type: &quot;GET&quot;,


    cache: false,


    success: function (content) { 


          var ItemDetail = jQuery.parseJSON(content);


		  var table = document.getElementById('Discount_Details');


          for(a=0;a&lt;ItemDetail.length;a++)


          {                   


                var row = table.insertRow(table.rows.length);	


					


	            var cell1 = row.insertCell(0);


	            cell1.innerHTML = a+1;


	            cell1.style.fontWeight=&quot;bold&quot;;


	


				var cell2 = row.insertCell(1);


	            cell2.innerHTML=ItemDetail[a].LevelName;


	            cell2.style.width=&quot;200px&quot;;


	            cell2.style.fontWeight=&quot;bold&quot;;


	                		          


				var cell13 = row.insertCell(2);


	            cell13.innerHTML=&quot;&lt;input size='5' maxlength='14' name='discounttypedetails[DiscMargin]' id='discounttypedetails_DiscMargin' type='text' value='&quot; + ItemDetail[a].Discountvalue + &quot;' /&gt;&quot;; 	     


	


				var cell14 = row.insertCell(3);


	            cell14.innerHTML=&quot;&lt;input size='1' maxlength='1' name='discounttypedetails[Display]' id='discounttypedetails_Display' type='checkbox' value='&quot; + ItemDetail[a].Display + &quot;' checked=&quot; + (ItemDetail[a].Display==1?true:false) + &quot; /&gt;&quot;;





				var cell15 = row.insertCell(4);


	            cell15.innerHTML=&quot;&lt;input size='50' maxlength='100' name='discounttypedetails[Remarks]' id='discounttypedetails_Remarks' type='text' value='&quot; + ItemDetail[a].Remarks + &quot;' /&gt;&quot;; 	     


	


				var cell16 = row.insertCell(5);


	            cell16.innerHTML=&quot;&lt;input hidden size='5' maxlength='11' name='discounttypedetails[DiscLevelID]' id='discounttypedetails_DiscLevelID' type='text' disabled='disabled' value='&quot; + ItemDetail[a].LevelID + &quot;' /&gt;&quot;;





	            var cell17 = row.insertCell(6);


	            cell17.innerHTML=&quot;&lt;input hidden size='5' maxlength='11' name='discounttypedetails[ID]' id='discounttypedetails_ID' type='text' disabled='disabled' value='&quot; + ItemDetail[a].DiscLevelID + &quot;' /&gt;&quot;;


          }                 


      }


   });   

}

function fillDisclevel_Details()

{

var urlPath= 'http://'+ window.location.host+'/yii/systempos/ajax.php?CMD=getDiscountDetails';		





alert(urlPath);





&#036;.ajax({


    url: urlPath,


    type: &quot;GET&quot;,


    cache: false,


    success: function (content) { 


          var ItemDetail = jQuery.parseJSON(content);


		  var table = document.getElementById('Discount_Details');


          for(a=0;a&lt;ItemDetail.length;a++)


          {                   


                var row = table.insertRow(table.rows.length);	


					


	            var cell1 = row.insertCell(0);


	            cell1.innerHTML = a+1;


	            cell1.style.fontWeight=&quot;bold&quot;;


	


				var cell2 = row.insertCell(1);


	            cell2.innerHTML=ItemDetail[a].LevelName;


	            cell2.style.width=&quot;200px&quot;;


	            cell2.style.fontWeight=&quot;bold&quot;;


	                		          


				var cell13 = row.insertCell(2);


	            cell13.innerHTML=&quot;&lt;input size='5' maxlength='14' name='discounttypedetails[DiscMargin]' id='discounttypedetails_DiscMargin' type='text' value='&quot; + ItemDetail[a].Discountvalue + &quot;' /&gt;&quot;; 	     


	


				var cell14 = row.insertCell(3);


	            cell14.innerHTML=&quot;&lt;input size='1' maxlength='1' name='discounttypedetails[Display]' id='discounttypedetails_Display' type='checkbox' value='&quot; + ItemDetail[a].Display + &quot;' checked=&quot; + (ItemDetail[a].Display==1?true:false) + &quot; /&gt;&quot;;





				var cell15 = row.insertCell(4);


	            cell15.innerHTML=&quot;&lt;input size='50' maxlength='100' name='discounttypedetails[Remarks]' id='discounttypedetails_Remarks' type='text' value='&quot; + ItemDetail[a].Remarks + &quot;' /&gt;&quot;; 	     


	


				var cell16 = row.insertCell(5);


	            cell16.innerHTML=&quot;&lt;input hidden size='5' maxlength='11' name='discounttypedetails[DiscLevelID]' id='discounttypedetails_DiscLevelID' type='text' disabled='disabled' value='&quot; + ItemDetail[a].LevelID + &quot;' /&gt;&quot;;





	            var cell17 = row.insertCell(6);


	            cell17.innerHTML=&quot;&lt;input hidden size='5' maxlength='11' name='discounttypedetails[ID]' id='discounttypedetails_ID' type='text' disabled='disabled' value='&quot; + ItemDetail[a].DiscLevelID + &quot;' /&gt;&quot;;


          }                 


      }


  });   

}

When you use jquery with ASP.NET you have to be careful about what the actual HTML name of the element ends up being

for me, this

$(‘ContentPlaceHolder1_butPrint’)

Ended up working because there’s a masterpage. ‘View Source’ on the actual page and see what the ID generated for that button is.

[color=#006400]NOTE: moved to proper section (Miscellaneous instead of Tips, Snippets and Tutorials)[/color]

[color=#006400]

[/color]

To get proper help, please check the Guidelines for posting on this forum - http://www.yiiframework.com/forum/index.php/topic/19451-