cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
MittalPatel
Frequent Visitor

Entity form - Liquid and JavaScript - issue with JS disabled on browser

Hello, 

 

I have implemented a web page with Entity form and it has a radio button field. 

 

When user clicks on 'Yes', I want to display a message in <span> tag just below the field.

I don't want to keep everything in Javascript, because if JS is disabled on user browser, then below logic is not going to work. 

 

I want to use liquid AND javascript for that reason. Below is my javascript function and I'm not sure how I can use Liquid here to set span tag. 

 

<script>
$(document).ready(function () {
 $("#cr157_language").val("{{ portallanguage }}");
 $("#cr157_allergy input[type=radio]").change(radiobuttonChange3a);
});
function radiobuttonChange3a()
        {
            var language = window.location.href;        
          if (document.getElementById("cr157_allergy_0").checked)
          {
              if(language.includes("en-US"))
				{
                    alert("English message");  // SET SPAN tag using liquid
                }
                else
                {
                    alert("Other message");  // SET SPAN tag using liquid
                }
          }
       }

</script>

 

2 REPLIES 2
Fubar
Solution Sage
Solution Sage

With javascript use jQuery to append the span and then to show/hide it inside your on change function

 

$( "#fieldschemaname" ).parent().append( "<span>Test</span>" );

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

$("#yourspanid").show();

 

 

Without JavaScript, you pretty much are limited e.g. you cannot pick up an onchange event.  And the Liquid doesn't have a redirect available from the template.  I can't think of a viable way to do what you want other than putting "You need to have JavaScript enabled to use this site" if it is not enabled.

 

Only way I could think of was if you had a standard submit button wrapped in html Form tag and in its 'action=' point to another page - but what you have is sitting on a standard Entity Form then this button would need to sit above or below the form details (as you don't have direct access inside the Entity form area without JavaScript - and the field is already inside a form submit).

 

OliverRodrigues
Super User
Super User

Hi @MittalPatel I am not sure what's the difference between this post and this?: https://powerusers.microsoft.com/t5/Power-Apps-Portals/Entity-Form-Advanced-Settings-Custom-javascri...

 




If you like this post, give a Thumbs up. Where it solved your request, Mark it as a Solution to enable other users find it.

Power Apps Portals Super User


Oliver Rodrigues


 

Helpful resources

Announcements
UG GA Amplification 768x460.png

Launching new user group features

Learn how to create your own user groups today!

Community Connections 768x460.jpg

Community & How To Videos

Check out the new Power Platform Community Connections gallery!

M365 768x460.jpg

Microsoft 365 Collaboration Conference | December 7–9, 2021

Join us, in-person, December 7–9 in Las Vegas, for the largest gathering of the Microsoft community in the world.

Users online (2,643)