Forums

Radio Button status from jscript

Bartjanszoon 01 Feb, 2015
Hello,
I'm trying to create a 'Presense' Form in which users can indicate that they will attend an event.
So my form is pretty trival with one RadioBox and some hidden fields to store the user and eventId.
I prefer not to have a submit button, as that just adds action to take. A change in Radio state should trigger the submit.

I've added events to the radiobox to trigger a jscript function from which I can call the submit.
However as I want the form to reload automatically with the chosen status, I would end up in an endless loop of submits because the events defined to the radiobox are state driven and not change driven.

To this means I added another hidden value to cache the value of the radiobutton, so that I can judge in jscript wether or not to submit.
Is there a jscript equivalent of $form->data['MyRadio'] in php?

Or any other pointers on how to approach this problem?
Thanx,
Bart
GreyHead 02 Feb, 2015
Hi Bart,

Can you unset the value of the radio box in the $from->data array so that it doesn't appear checked?

Or, change your script so that it is dependent on a change?

Or, add a 'subscribed' identifier in a hidden input and check that in your submit script?

Bob
Bartjanszoon 02 Feb, 2015
Hi Bob,
I finally managed myself.
First part of the solution is to add Extra Parameters to the radio group:
onChange=this.form.submit();

Then I need an exta hidden variable so that I can create an event switcher in the submit to either create a new record or update.
$form->data['IsSet'] = 1;

One thing which is strange to me is that a DBRead does not automatically initialise the form field with the same name. I had to do:
$form->data['IsPresent'] = $form->data['Data']['IsPresent'];

Regards,
Bart
This topic is locked and no more replies can be posted.