Yii Framework Forum: Onload Function Error - Yii Framework Forum

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

Onload Function Error need help! Rate Topic: -----

#1 User is offline   lvsan 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 6
  • Joined: 03-September 12

Posted 08 October 2012 - 11:04 PM

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("hello");

var newRecord=<?php echo $model->isNewRecord; ?>;

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';

$.ajax({
url: urlPath,
type: "GET",
cache: false,
success: function (content) {
var ItemDetail = jQuery.parseJSON(content);
var table = document.getElementById('Discount_Details');
for(a=0;a<ItemDetail.length;a++)
{
var row = table.insertRow(table.rows.length);

var cell1 = row.insertCell(0);
cell1.innerHTML = a+1;
cell1.style.fontWeight="bold";

var cell2 = row.insertCell(1);
cell2.innerHTML=ItemDetail[a].LevelName;
cell2.style.width="200px";
cell2.style.fontWeight="bold";

var cell13 = row.insertCell(2);
cell13.innerHTML="<input size='5' maxlength='14' name='discounttypedetails[DiscMargin]' id='discounttypedetails_DiscMargin' type='text' value='" + ItemDetail[a].Discountvalue + "' />";

var cell14 = row.insertCell(3);
cell14.innerHTML="<input size='1' maxlength='1' name='discounttypedetails[Display]' id='discounttypedetails_Display' type='checkbox' value='" + ItemDetail[a].Display + "' checked=" + (ItemDetail[a].Display==1?true:false) + " />";

var cell15 = row.insertCell(4);
cell15.innerHTML="<input size='50' maxlength='100' name='discounttypedetails[Remarks]' id='discounttypedetails_Remarks' type='text' value='" + ItemDetail[a].Remarks + "' />";

var cell16 = row.insertCell(5);
cell16.innerHTML="<input hidden size='5' maxlength='11' name='discounttypedetails[DiscLevelID]' id='discounttypedetails_DiscLevelID' type='text' disabled='disabled' value='" + ItemDetail[a].LevelID + "' />";

var cell17 = row.insertCell(6);
cell17.innerHTML="<input hidden size='5' maxlength='11' name='discounttypedetails[ID]' id='discounttypedetails_ID' type='text' disabled='disabled' value='" + ItemDetail[a].DiscLevelID + "' />";
}
}
});
}

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

alert(urlPath);

$.ajax({
url: urlPath,
type: "GET",
cache: false,
success: function (content) {
var ItemDetail = jQuery.parseJSON(content);
var table = document.getElementById('Discount_Details');
for(a=0;a<ItemDetail.length;a++)
{
var row = table.insertRow(table.rows.length);

var cell1 = row.insertCell(0);
cell1.innerHTML = a+1;
cell1.style.fontWeight="bold";

var cell2 = row.insertCell(1);
cell2.innerHTML=ItemDetail[a].LevelName;
cell2.style.width="200px";
cell2.style.fontWeight="bold";

var cell13 = row.insertCell(2);
cell13.innerHTML="<input size='5' maxlength='14' name='discounttypedetails[DiscMargin]' id='discounttypedetails_DiscMargin' type='text' value='" + ItemDetail[a].Discountvalue + "' />";

var cell14 = row.insertCell(3);
cell14.innerHTML="<input size='1' maxlength='1' name='discounttypedetails[Display]' id='discounttypedetails_Display' type='checkbox' value='" + ItemDetail[a].Display + "' checked=" + (ItemDetail[a].Display==1?true:false) + " />";

var cell15 = row.insertCell(4);
cell15.innerHTML="<input size='50' maxlength='100' name='discounttypedetails[Remarks]' id='discounttypedetails_Remarks' type='text' value='" + ItemDetail[a].Remarks + "' />";

var cell16 = row.insertCell(5);
cell16.innerHTML="<input hidden size='5' maxlength='11' name='discounttypedetails[DiscLevelID]' id='discounttypedetails_DiscLevelID' type='text' disabled='disabled' value='" + ItemDetail[a].LevelID + "' />";

var cell17 = row.insertCell(6);
cell17.innerHTML="<input hidden size='5' maxlength='11' name='discounttypedetails[ID]' id='discounttypedetails_ID' type='text' disabled='disabled' value='" + ItemDetail[a].DiscLevelID + "' />";
}
}
});
}
0

#2 User is offline   parkerfrank 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 23
  • Joined: 02-October 12

Posted 07 November 2012 - 12:11 AM

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.
0

#3 User is offline   Maurizio Domba Cerin 

  • Yii - Yesss It Is !!!
  • Yii
  • Group: Yii Dev Team
  • Posts: 4,340
  • Joined: 12-October 09
  • Location:Croatia

Posted 07 November 2012 - 04:42 AM

NOTE: moved to proper section (Miscellaneous instead of Tips, Snippets and Tutorials)


To get proper help, please check the Guidelines for posting on this forum - http://www.yiiframew...hp/topic/19451-
Find more about me.... btw. Do you know your WAN IP?
0

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users