web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Pages / Lookup OnChange Event
Power Pages
Answered

Lookup OnChange Event

(0) ShareShare
ReportReport
Posted on by 1,510

Hi,

 

I have two lookup fields on basic form. I need to clear second lookup field value when first lookup is changed(add/clear/remove).

hardikv_0-1643902197895.png

 

I have tried below code. It is working for first time, when I changed the contact lookup, the facility is removing. But from the second time, I change or remove the contact lookup, facility lookup is not removing.

 

$("#new_contactid").change(function(){
		$("#new_facility").val("");
		$("#new_facility_name").attr("value", "");
		$("#new_facility_entityname").attr("value", "");
	});

 

Categories:
  • Verified answer
    oliver.rodrigues Profile Picture
    9,482 Most Valuable Professional on at

    hi @hardikv I think the issue is when using the .attr property.. for some weird reason it works only the 1st time.. don't ask me why 🤣

     

    You can use .val directly.. this works perfectly, give it a go:

    $("#new_contactid").change(function(){
    		$("#new_facility").val("");
    		$("#new_facility_name").val("");
    		$("#new_facility_entityname").val("");
    	});

     

  • H V Profile Picture
    1,510 on at

    Thanks for your help @OliverRodrigues 

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Season of Sharing Community Challenge Winners!

Congratulations to our community stars!

Kudos to our 2025 Community Spotlight Honorees

Expanding mentorship, skilling, and AI innovation

Leaderboard > Power Pages

#1
Mohsin Ali Profile Picture

Mohsin Ali 18

#2
11manish Profile Picture

11manish 16 Super User 2026 Season 2

#3
Harshit Chaubisa Profile Picture

Harshit Chaubisa 4

Last 30 days Overall leaderboard