Show hidden field from dropdown blank

The recommended method of customizing your AppGini-generated application is through hooks. But sometimes you might need to add functionality not accessible through hooks. You can discuss this here.
Post Reply
User avatar
Jay Webb
Veteran Member
Posts: 80
Joined: 2017-08-26 15:27
Contact:

Show hidden field from dropdown blank

Post by Jay Webb » 2020-05-15 23:22

I'm using appgini 5.82

I have a dropdown list that when any of the words is selected it hides a field, works great.
But what I haven't been able to figure out is how to show the hidden field on selecting the blank in the dropdown list.
I'm using this code,

Code: Select all

$j(document).ready(function()
{

$j("#color").change(function()
{

if($j("#color :selected").text()=="Red")
{
$j("#shade").parents(".form-group").hide();
}

if($j("#color :selected").text()=="Green")
{
$j("#shade").parents(".form-group").hide();
}
(there's more colors)
});

});
shade is a dropdown field, which when one of it's words are selected color dropdown is hidden.
Goal,
When selecting 'Color' the first line in the dropdown list is blank by default, is there a way to use this blank for 'on click' to show 'Shade' back again or do I need a word in the dropdown list to do this, like, 'Show shade list';;Red;;Green;;Blue;;Orange. I'm trying not to add a word that then gets added to table.
What we envision, we make happen.

pbottcher
AppGini Super Hero
AppGini Super Hero
Posts: 1635
Joined: 2018-04-01 10:12

Re: Show hidden field from dropdown blank

Post by pbottcher » 2020-05-16 17:19

Hi

you can try

$j(document).ready(function()
{

$j("#color").change(function(e)
{

if($j("#color :selected").text()=="Red")
{
$j("#shade").parents(".form-group").hide();
}

if($j("#color :selected").text()=="Green")
{
$j("#shade").parents(".form-group").hide();
}
// (there's more colors)
if(e.currentTarget.value=="")
{
$j("#shade").parents(".form-group").show();
}
});

});
Any help offered comes with the best of intentions. Use it at your own risk. In any case, please make a backup of your existing environment before applying any changes.

User avatar
Jay Webb
Veteran Member
Posts: 80
Joined: 2017-08-26 15:27
Contact:

Re: Show hidden field from dropdown blank

Post by Jay Webb » 2020-05-16 21:52

Thanks for the reply, It dawned on me last night without some external button or link what I'm asking for can't be done.
That the blank area I'm referring to is javascriptvoid (0) in first line that's blank, and the code,

So I added a little button just above each dropdown to un-hide the hidden field.
The only bummer is the file gets overwritten when changing or updating as it in MYPAGE_templateDV.html

On another note,
Is there a way to close all open Table Groups when another gets opened, so only one is open at a time. This would make it would make it easier
for phones and tablets not having to scroll through a bunch of table groups on home page..
What we envision, we make happen.

pbottcher
AppGini Super Hero
AppGini Super Hero
Posts: 1635
Joined: 2018-04-01 10:12

Re: Show hidden field from dropdown blank

Post by pbottcher » 2020-05-17 09:35

Hi,

you can try to add to the hooks/header-extras.php

Code: Select all

<?php
$filename=basename($_SERVER['PHP_SELF']);
if (basename($_SERVER['PHP_SELF']) == 'index.php') {
	?>
	<script>
	$j(function(){

		$j('.collapser').on('click',function() {
			var actual=this;
			$j('.btn[aria-expanded="true"]').each(function() {
				if (this!=actual) {
					$j(this).children('.glyphicon').toggleClass('glyphicon-chevron-right glyphicon-chevron-down');
					$j('div[aria-expanded="true"]').collapse('toggle');
				}
			})

		})
	})
	</script>
	<?php
}

?>
Any help offered comes with the best of intentions. Use it at your own risk. In any case, please make a backup of your existing environment before applying any changes.

User avatar
Jay Webb
Veteran Member
Posts: 80
Joined: 2017-08-26 15:27
Contact:

Re: Show hidden field from dropdown blank

Post by Jay Webb » 2020-05-17 14:22

Fantastic, your ingenious, works like a charm, I tried several things and all I could was close them all, but this is fantastic.
Thank you.
What we envision, we make happen.

Post Reply