NetTalk Central

Author Topic: Conditional disabling button in form  (Read 4869 times)

Koen Tjoa

  • Jr. Member
  • **
  • Posts: 68
    • View Profile
    • Email
Conditional disabling button in form
« on: November 04, 2011, 07:57:10 AM »
I have a NetWebForm with a BrowseControl and several buttons. I would like to enable/disable a button based on the condition if records are tagged or not in the browse. In the browse procedure a SessionVariable is set with the number of tagged records.

In the NetWebForm on the Fields tab I made two settings:
1.   For the button --> the entry ‘Disabled If’ reads that SessionVariable.
2.   BrowseControl --> Client-Side tab --> resets the button value.

Unfortunate this isn’t working. First the Value::MyButton routine is done, then the EIP embed where the actual tagging is handled. That is the wrong order for what I want. Although the SessionVariable is updated, the button reads the old value first and is not set to state to be expected.

How can I make that the Value::MyButton routine is called after the user has tagged a record in the browse? Or maybe better said after the update of the browse control is done.

Thanks,
Koen

kevin plummer

  • Hero Member
  • *****
  • Posts: 1195
    • View Profile
    • Production Accounting and Software Payroll
Re: Conditional disabling button in form
« Reply #1 on: November 04, 2011, 01:31:11 PM »
Hi Koen,

I have the same problem with trying to display the number of records tagged - the number displayed is always 1 behind for the same reason you are having problems disabling the button.

I haven't been able to find a way around it.

cheers,

kevin

Koen Tjoa

  • Jr. Member
  • **
  • Posts: 68
    • View Profile
    • Email
Re: Conditional disabling button in form
« Reply #2 on: November 04, 2011, 03:34:44 PM »
Yep, I did a search on this forum first and I saw and old topic of you. In fact I was hoping you had solved it meanwhile.

I did some tracing to figure out what is actually happening. The browse is called several times on different threads. Mostly the Value::MyButton routine is called first and for some reason the embed where the tagging is done always “loses. I didn’t found out yet where the calling of the browse is done. That can be the key of calling the Value::MyButton routine again.

Cheers,
Koen

Stu

  • Hero Member
  • *****
  • Posts: 510
    • View Profile
    • Email
Re: Conditional disabling button in form
« Reply #3 on: November 06, 2011, 11:27:12 PM »
Could you put a "unique for this purpose" Class on the buttons and then have a jquery script run when a record is tagged?
Cheers,

Stu Andrews

Koen Tjoa

  • Jr. Member
  • **
  • Posts: 68
    • View Profile
    • Email
Re: Conditional disabling button in form
« Reply #4 on: November 07, 2011, 05:51:31 AM »
You got me..   ???
What is a "unique for this purpose" class? I guess it must be possible to run a jquery script, although I must figure out how. But won’t it end with the same problem with running the value routine and the tagging asynchronic?
« Last Edit: November 07, 2011, 05:55:05 AM by KoenT »

Stu

  • Hero Member
  • *****
  • Posts: 510
    • View Profile
    • Email
Re: Conditional disabling button in form
« Reply #5 on: November 07, 2011, 10:54:50 PM »
Koen,

What I meant by "unique for this purpose" was using the form name plus something else, eg an ID of "<formname>_TagButton".

You then use this as the jQuery selector.

With jQuery you would run code similar to here (http://jetlogs.org/2007/12/16/jquery-disabled-and-readonly-inputs/). The code is being used for an Input tag, but I'm pretty sure it works for buttons as well (http://jquery-howto.blogspot.com/2009/05/disable-submit-button-on-form-submit.html).
Cheers,

Stu Andrews

Koen Tjoa

  • Jr. Member
  • **
  • Posts: 68
    • View Profile
    • Email
Re: Conditional disabling button in form
« Reply #6 on: November 08, 2011, 05:52:22 AM »
Hi Stu,

Thanks, I understand it. It must be possible to but call this JavaScript from my browse after the tagging is done. But unfortunate I cannot get it working yet here.

For trying this out I have two buttons in my form. Button ‘bTest2’ should disable ‘bTest1’. The name of the form in the IDE is ‘wF_TerugmeldingUit’, but in the browser if I got it right the name is ‘wF_TerugmeldingUit_frm’.

I tried all kind off combinations like:
'$(''wF_TerugmeldingUit_frm_bTest1'').attr(''disabled'', ''disabled'')'
'$(''.bTest1'').attr(''disabled'',  true)'

But nothing works so far. So either I didn’t get the form name plus something else right in the way you meant or my JavaScript syntax is wrong.

For being sure I tried
'alert$(''Hello'')'
which is working, indicating that at least simple JavaScript works from that particular button.

What am I missing?
Thanks, again,
Koen
« Last Edit: November 08, 2011, 05:53:53 AM by KoenT »

Stu

  • Hero Member
  • *****
  • Posts: 510
    • View Profile
    • Email
Re: Conditional disabling button in form
« Reply #7 on: November 08, 2011, 04:29:22 PM »
Koen,

In that first line of code, you need either a # or a .

And a semicolon at the end

Also, using double quotes helps me to see things better (but that's just my personal preference)

ie,

$("#wF_TerugmeldingUit_frm_bTest1").attr("disabled","disabled");
Cheers,

Stu Andrews

Koen Tjoa

  • Jr. Member
  • **
  • Posts: 68
    • View Profile
    • Email
Re: Conditional disabling button in form
« Reply #8 on: November 14, 2011, 09:59:23 AM »
Hi Stu,

I was a long weekend off so I couldn’t respond earlier. I tried what you suggested but unfortunate it I cannot get it working.  :-[
At this moment I give up, it is just a small thing to make things look nicer.

However it is much appreciated that you tried to help me to figure it out. Thank you very much.

Regards,
Koen