Page 1 of 1

Show hidden field from dropdown blank

Posted: 2020-05-15 23:22
by Jay Webb
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.

Re: Show hidden field from dropdown blank

Posted: 2020-05-16 17:19
by pbottcher
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();
}
});

});

Re: Show hidden field from dropdown blank

Posted: 2020-05-16 21:52
by Jay Webb
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..

Re: Show hidden field from dropdown blank

Posted: 2020-05-17 09:35
by pbottcher
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
}

?>

Re: Show hidden field from dropdown blank

Posted: 2020-05-17 14:22
by Jay Webb
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.