This topic is locked
[SOLVED]

 problem with onpageload fonction

7/4/2011 1:02:16 AM
PHPRunner General questions
R
rocknroll_france author

Hi,
Sorry to be such a newbie, but I tried to apply fonction in the OnPageLoad of the Add Page....

Clearly, I don't understand anything on it <img src='https://asprunner.com/forums/file.php?topicimage=1&fieldname=question&id=17286&image=1&table=forumtopics' class='bbc_emoticon' alt=':(' />
I started with the example done in Phprunner and try to apply it on my fields....
No way !
Here is the code....
If I understand well: This code is executed when the page is loaded and normally, when the control "cat" changes (dropdown control), the other control "doss" must be set to the required "if... else..." statements.
Do I miss something ?

One another thing must be done on one another event (button ?) ?

Do I call this fonction from the Add Page ? If so where ?
Sorry for these questions, but I try to learn and sometimes the posts and the tutorials forgot that we are newbies and that it is not easy to have informations
function OnPageLoad(pageid)

{

//<script>
var ctrlCategory = Runner.getControl(pageid, 'category');

var ctrlDoss = Runner.getControl(pageid, 'doss');

ctrlCategory.on('change', function(e){

if (this.getValue() == 'Product'){

ctrlDoss.setEnabled();

ctrlDoss.setValue("Positive_test");

ctrlDoss.addValidation("IsRequired");

}else{

ctrlDoss.setDisabled();

ctrlDoss.setValue("negative_test");

ctrlDoss.removeValidation("IsRequired");

}

});
//</script>
// Place event code here.

// Use "Add Action" button to add code snippets.

} // function OnPageLoad

R
rocknroll_france author 7/4/2011

Just to understand, I just try this other code, find in tutorial...

Doesn't work on my select control...

<img src='https://asprunner.com/forums/file.php?topicimage=1&fieldname=reply&id=59198&image=1&table=forumreplies' class='bbc_emoticon' alt=':angry:' /> <img src='https://asprunner.com/forums/file.php?topicimage=1&fieldname=reply&id=59198&image=2&table=forumreplies' class='bbc_emoticon' alt=':(' />
I tried with an without <script>....</script> No way !
function OnPageLoad(pageid)

{

//<script>

$.each($("select"),function(i,e){
$(this).css('fontSize', '120%');
});

//</script>

// Place event code here.

// Use "Add Action" button to add code snippets.

Sergey Kornilov admin 7/4/2011

Make sure you don't add <script> or function to your event code. Simply paste code to 'Javascript OnLoad' event on Events screen.
More info:

http://xlinesoft.com/phprunner/docs/how_to_change_font_in_edit_con.htm
If you need more help post your application to Demo Account and open a ticket at http://support.xlinesoft.com sending your Demo Account URL. 'Demo Account' button can be found on the last screen in the program.

R
rocknroll_france author 7/4/2011

Thanks for reply.
But now.... It works !!! Without any change !
I found explanation... but it seems to me really strange.... <img src='https://asprunner.com/forums/file.php?topicimage=1&fieldname=reply&id=59203&image=1&table=forumreplies' class='bbc_emoticon' alt=':angry:' />
If i make any change on the script:

1 - if I make a "build" : No change, doesn't work !

2 - if I make a "complete build" : No change, doesn't work !

3 - If I close PHPR session and reenter... : No change, doesn't work !
BUT !!!!!!
If I close IE, reopen it and go to PHPR project, changes made to script are applied !

Also for verify changes in OnPageLoad, I MUST close IE....
Is it normal ?
Does somebody have seen the same "problem" ?

C
cgphp 7/4/2011

Remove also the function declaration:

function OnPageLoad(pageid)

{



and the relative closing bracket

}



They are not necessary. They are added by PHPrunner. The only needed code is the following:

var ctrlCategory = Runner.getControl(pageid, 'category');

var ctrlDoss = Runner.getControl(pageid, 'doss');

ctrlCategory.on('change', function(e){

if (this.getValue() == 'Product'){

ctrlDoss.setEnabled();

ctrlDoss.setValue("Positive_test");

ctrlDoss.addValidation("IsRequired");

}else{

ctrlDoss.setDisabled();

ctrlDoss.setValue("negative_test");

ctrlDoss.removeValidation("IsRequired");

}

});
Sergey Kornilov admin 7/4/2011

I think you are dealing with cached pages in your browser. Simply hit CTRL+F5 to reload the page after the build.