This topic is locked
[SOLVED]

 enabling/disabling a standard button

12/2/2013 2:31:19 AM
PHPRunner General questions
K
kyrie76 author

I have the following question regarding enabling/disabling a standard button.
I have a custom button on a form that based on Route Date and Route fields gives me a number of available seats.

It works fine. Now, I want to enable/disable save button based on the number of available seats.
I found an article from PHPRunner manual how to enable/disable a button and it doesn't seems to work. The article http://xlinesoft.com...le_a_button.htm
Based on the article I have to do the following to get button id: build application, open it in the browser and view the properties of the button using Chrome Developer Tools or Firebug. (Button id below)

<a id="saveButton1" href="#" class="rnr-button disabled">Save</a>

Use only the initial part of the button id (without numbers) in the code, such as saveButton. (Based on the article)

Add the following code to any Javascript onload event or ClientAfter/ClientBefore event of other buttons.
To disable a button:

var id = "saveButton";

var button = $("[id^=" + id);

button.addClass('disabled');
To enable a button:

var id = "saveButton";

var button = $("[id^=" + id);

button.removeClass('disabled');
On my custom button ClientAfter event I have the following code:

OnClient After:

var message = result["txt"];

ctrl.setMessage(message);
if (result["txt"]!='No Available Seats')

var id = "saveButton";

var button = $("[id^=" + id);

button.removeClass('disabled');
Disable button above doesn't work
Below code is working fine, but that is not what I need. I want to disable the save button so that a user will not be able to save a record with no available seats.

if (result["txt"]=='No Available Seats')

location.href="http://...php?a=return";;
Thanks in advance

Admin 12/2/2013

The code for disabling/enabling button is correct but there might some sort of issue with the order code you adding.
See if your code produces any Javascript errors and fix them:

http://xlinesoft.com/blog/2012/05/22/how-to-troubleshoot-javascript-errors/

K
kyrie76 author 12/3/2013



The code for disabling/enabling button is correct but there might some sort of issue with the order code you adding.
See if your code produces any Javascript errors and fix them:

http://xlinesoft.com/blog/2012/05/22/how-to-troubleshoot-javascript-errors/


I did what you told me. It seems that on Chrome it works fine but on firefox no.

I do not know what to do
Thanks in advance

Admin 12/3/2013

I would say this is not possible. If Javascript code works it should work in all browsers. Try to update your Firefox just in case. Try to install Firebug for Firefox and check for Javascript errors in Firefox.

K
kyrie76 author 12/4/2013



I would say this is not possible. If Javascript code works it should work in all browsers. Try to update your Firefox just in case. Try to install Firebug for Firefox and check for Javascript errors in Firefox.


Firefox is up to date 25.0.1

I'm using firebug debugger and I do not get any errors.


Can I send you a link to check it out.
Thanks in advance

K
kyrie76 author 12/4/2013



Firefox is up to date 25.0.1

I'm using firebug debugger and I do not get any errors.


Can I send you a link to check it out.
Thanks in advance


I found only two warnings, no errors.