This topic is locked

collapse section in edit page

5/14/2026 02:37:48
PHPRunner General questions
ffrinai author

phprunner Enterprise 10.91 build 41974 x64

I would like to close the only section opening the edit page. I inserted the following code into the JavaScript OnLoad of Edit Page event:

var sec = pageObj.getSection(0);
sec.collapse();

but it doesn't work.
i try to verify with
var sections = pageObj.getSectionCount();
alert('sections number '+sections);

but the alert is not displayed.
where am I wrong?
thanks Fabio

ChatGPT 5/14/2026

It looks like you're attempting to collapse a section on the Edit Page of PHPRunner using JavaScript, but you're encountering issues. Here are a few things you can check to troubleshoot the problem:

  1. Check the Event Timing: The OnLoad event might be too early for the section to be accessed. You can try using OnPostLoad instead. This event occurs after the page has finished loading and may allow you to access the sections correctly.


  2. Verify Section Index: Ensure that the section index you're using (0 in your case) is indeed valid. If there are no sections or if the index is out of bounds, it could lead to issues. You can try logging the number of sections in the OnPostLoad event to confirm that the section exists.


  3. Check for Errors in the Console: Open the developer console in your web browser (usually by pressing F12) and check for any JavaScript errors. This may provide insight into what's going wrong.


  4. Use Correct API Methods: Make sure that the API methods you're using (getSection and collapse) are appropriate for your version of PHPRunner. Refer to the PHPRunner documentation to verify that these methods exist and are used correctly.



Here’s an updated version of your script, assuming you switch to OnPostLoad:

function OnPostLoad() {
var sections = pageObj.getSectionCount();
alert('sections number ' + sections);

if (sections > 0) {
var sec = pageObj.getSection(0);
if (sec) {
sec.collapse();
}
}
}

Try the code above and see if the alert displays the number of sections and if the section collapses as expected. If it still doesn't work, please check the console for errors and provide more details if possible.

ffrinai author 5/14/2026

there is no a function OnPostLoad