Hide a Field when Add Record

This public forum is for user-to-user discussions of PHPMaker. Note that this is not support forum.
Post Reply
shahparzsoft
User
Posts: 361

Hide a Field when Add Record

Post by shahparzsoft »

I want to hide a field when Add Record, and Show with the following event.

Show event (mentioned below) works fine, but how to Hide when Add:

{ // keys = event types, values = handler functions
	"change": function(e) {
		// Your code
		var $row = $(this).fields();
		if (this.value == 8) {
			$row["amount_recvd"].visible(true);
		}
	}
}

Please help.


arbei
User
Posts: 9384

Post by arbei »

You may hide it with Startup Script, e.g.

$("#r_amount_recvd").hide(); // Select the row, assumed Add page

(Right click the row in Chrome and select "Inspect" to check the actual id.)


shahparzsoft
User
Posts: 361

Post by shahparzsoft »

  1. $("#x_amount_recvd").hide();
    this works like #x not #r.
  2. It only hides the field not the caption
  3. it didn't showing with the below function:
    { // keys = event types, values = handler functions
    "change": function(e) {
    // Your code
    var $row = $(this).fields();
    if (this.value == 8) {
    $row["amount_recvd"].visible(true);
    }
    }
    }

arbei
User
Posts: 9384

Post by arbei »

arbei wrote:

$("#r_amount_recvd").hide(); // Select the row, assumed Add page

  1. In Add/Edit, the row of each field is named by "r_<fieldname>". Right click the element and select "Inspect" in Chrome to check the id of HTML elements. If you use "#x_amount_recvd", you only hide the input, not the row (including caption).
  2. Startup Script and Client Side Script are independent, you need to use both.

shahparzsoft
User
Posts: 361

Post by shahparzsoft »

arbei wrote:

  1. Startup Script and Client Side Script are independent, you need to use both.

Cannot understand this line ? please elaborate ...


arbei
User
Posts: 9384

Post by arbei »

shahparzsoft wrote:

  1. it didn't showing with the below function:
    { // keys = event types, values = handler functions ...

That is Client Side Script for fields, it is generated in userevent.js. Client/Startup Scripts are generated in userfn.js. They are different.


shahparzsoft
User
Posts: 361

Post by shahparzsoft »

this works fine in simple add page (Client Script->Table Specific->Add/Copy Page->Startup Script:

$("#conditional").hide();

But not works in modal add page.

Please help.


arbei
User
Posts: 9384

Post by arbei »

What is "#conditional"?


mobhar
User
Posts: 11726

Post by mobhar »

shahparzsoft wrote:

But not works in modal add page.

Since the Modal dialog for Add page is displayed from List Page, then you may put also that code in Startup Script of List Page. In addition, make sure to include the Modal css selector/id to your css selector above


philmills
User
Posts: 555

Post by philmills »

I hit the same issue.
I have a field with "allow add" enabled, but in the modal dialogue for adding, there are fields showing that have actually been disabled generally for add.
Why doesn't allow add modal dialogue obey the field settings for the table I'm adding to?
How can i hide the fields?


mobhar
User
Posts: 11726

Post by mobhar »

If you meant it is Add Option Page (not normal Add Page), then in v2024 it has its own Server Events and its own Client Scripts. It is seperated between normal Add Page and Add Option Page.


philmills
User
Posts: 555

Post by philmills »

Got it, same in v2023


Post Reply