You are viewing limited content. For full access, please sign in.

Discussion

Discussion

Form CSS - Read-only toggle feature

posted on August 30, 2017 Show version history

Hi,

I need some help with the below scenario. I have spent a couple of hours arriving at my outcome partially but if someone has attempted this before and have anything to share, please pass it along.

I have a table with 2 columns (2 number fields), lets call them A&B. Both fields are tied to a look-up and load with values from a DB table. A&B values are always 0&0 or 1&1 and rows in the table contain both combos.

When B is 0, A should be open for input and should contain a colour on it's border indicating it's accepting values. When B is 1, A should be read-only with background greyed out indicating it is not accepting vales.

0 0
replied on August 30, 2017

Ok, this should be pretty close to what you want.

function toggleFields()
{
  $('table tr').each(function() {
    var a = $(this).find('td[data-title="a"] input')
    var b = $(this).find('td[data-title="b"] input')
  	
    if(b.val() == 0)
    {
      a.prop('disabled', false);
    }
    else if(b.val() == 1)
    {
      a.prop('disabled', true);
    }
  });
  	
}

$( document ).ready(function() {  
	$(document).on('lookupcomplete', function(event){
    	toggleFields();
    });
});

You will need to tweak this. I have made it pretty generic just change the "a"/"b" in [data-title="a"] to what ever you named your column.

let me know how u go.

1 0
replied on August 31, 2017

Hi Aaron,

Thank you so much for the code, I will give it a go and let you know.

Thanks,

Adarsh

0 0
replied on September 3, 2017

Hi Aaron,

That worked beautifully! Thanks again for being so kind angel.

Regards,

Adarsh

0 0
replied on September 3, 2017

No worries mate,

Glad it helped :)

1 0
replied on August 30, 2017

Hi Aaron,

Thank you, I really appreciate if you can pass some code to work off of if it doesn't take up too much of your time. I'm learning JavaScripts and prone to errors.

Thanks,

Adarsh

0 0
replied on August 30, 2017

No worries mate.

Can you let me know what version of forms you are working with?

Thanks

0 0
replied on August 30, 2017

Forms Ver: 10.2.0

0 0
replied on August 30, 2017

Use JavaScript to cycle over the table after the lookup is completed. For each row check the values in the fields and enable/disable them accordingly.

If you would like me to throw together some JavaScript to use as a base i'm happy to do that.

0 0
You are not allowed to follow up in this post.

Sign in to reply to this post.