How to change functionality of Ticket Purchase widget to act like radio button field

  • chrispp10
    Asked on February 8, 2016 at 3:23 PM
    s there a way when the max is 1 and the min is 1

    is there a way to make it auto deselect when you click on another choice instead of you having to deselect your previous choice and reselect the new one ?

  • chrispp10
    Replied on February 8, 2016 at 3:25 PM

    I thought this would work but it seems like it is not working 

     

    $(document).ready(function () {

            $("#checklist li").click(function () {

                $("#checklist li").removeClass('clicked');

                $(this).addClass('clicked');

     

            });

      });

     

  • BJoanna
    Replied on February 8, 2016 at 3:34 PM

    Unfortunately this is not possible to achieve. Functionality that you want is radio button functionality, and Ticket Purchases widget is check box field.

    I think this would be possible to achieve if you would embed your form to website using full source code and if you add additional JavaScript functions. If you are not able to to it your self, to would be the best to hire a developer to do it for you.

    Feel free to contact us if you have any other questions.

  • chrispp10
    Replied on February 8, 2016 at 3:50 PM

    There has to be a javascipt that allows for check boxes to be unselected 

  • Kevin Support Team Lead
    Replied on February 8, 2016 at 8:57 PM

    It would be better to use the radio buttons instead, you can not add custom Javascript codes because before it was allowed, but some users were using those script for other purposes rather than just collect data.

    If you would like to add Javascript codes you will need to get the Full Source Code as explained by my colleague above.

  • chrispp10
    Replied on February 11, 2016 at 3:24 PM

    Thanks for the response 

    I have the full source code but as of now I can not bypass the iframe for security reasons 

    is there a way around it that you know of ?

     

    I was trying to use this 

    var doc=document.getElementById("customFieldFrame_35").contentDocument;

     

  • Kevin Support Team Lead
    Replied on February 11, 2016 at 4:42 PM

    Please, allow me some time, I will test a Javascript code and will get back to you as soon as I have it working.

    Thank you.

  • Kevin Support Team Lead
    Replied on February 11, 2016 at 5:09 PM

    Take a look on this sample: http://pastebin.com/raw/kka2HFXg

    It should work as you need.

  • chrispp10
    Replied on February 11, 2016 at 5:21 PM

    Thanks for the response 

     

    where exactly am i inserting this and will it work for all checkboxes on my form ?

    i only want it to work if the min is 1 and the max is 1

     

    so if you can choose more than one choice i do not want this to apply 

  • Kevin Support Team Lead
    Replied on February 11, 2016 at 6:32 PM

    You will need to add one of this functions per check box in your form:

    function check1(box) {

            if (box.checked) {

                document.getElementById("checkbox2").checked=false

            }

    }

    Just replace the highlighted text with the ID of the check box that you want to apply the function.

    It will only work with one, as you requested, if you have checked an option and you try to check other option, then the previous checked option will be cleared, this basically will work the same as the radio buttons.

     

  • chrispp10
    Replied on February 11, 2016 at 6:49 PM

    does it matter where i apply the function?

    Can i put it anywhere in the source ?

     

    also the only think im changing is "checkbox2" i dont need to change check1 or box per different functions ?

  • chrispp10
    Replied on February 11, 2016 at 7:00 PM

    How to change functionality of Ticket Purchase widget to act like radio button field Image 1 Screenshot 20

     

    I was testing with inspect element and it seems as though it is not working ?

    I inserted the code into inspect element and it made no different ?

  • Kevin Support Team Lead
    Replied on February 11, 2016 at 8:11 PM

    Are you trying to use this with the widget shown in your image? 

    If yes, then I think that it's not possible, since you only get the iFrame code of the widget, you do not get the source code, and the Javascript provided above only works with the normal check boxes.

  • chrispp10
    Replied on February 11, 2016 at 8:21 PM

    Yes im trying to use it with that 

    no there is no way around it whatsoever ?

  • beril JotForm UI Developer
    Replied on February 12, 2016 at 4:27 AM

    As my colleague was mentioned before, the only way is adding the javaScript code to your source code. Otherwise, it will not work.

    I've also looked for a solution for behaving as radio button. It seems there is no way to change the functionality of widget without adding JavaScript code.

    Please, check the guide below for more information.

    http://www.jotform.com/help/104-How-to-get-the-Full-Source-Code-of-your-Form

     

  • chrispp10
    Replied on February 12, 2016 at 10:19 AM

    I understand how to get the source code already have it

    also i know i need to add javascript

     

    can you guys aid me in achieving this javascript that will work?

  • Ashwin JotForm Support
    Replied on February 12, 2016 at 12:55 PM

    Hello chrispp10,

    I went through the entire post and it seems you are already aware that widget code is loaded separately inside an iFrame within the form. That's really going to e challenge since widgets work separately from separate domain.

    I will take a look and try to figure out if there is any workaround possible. I do not think it is possible but I will get back to you if I figure out any workaround.

    Thank you!

  • chrispp10
    Replied on February 12, 2016 at 3:29 PM

    alright thanks I have been working with this to see if i can get a workaround 

    http://stackoverflow.com/questions/25098021/securityerror-blocked-a-frame-with-origin-from-accessing-a-cross-origin-frame/25098153#25098153

  • chrispp10
    Replied on February 12, 2016 at 3:36 PM

    Also I am going to make a thread but maybe you guys can help me here as well 

     

    is it possible to have the form, once the submit button is hit, to recheck the ticket purchases widget to make sure there spots are available before submitting 

     

    reason being because, lets say there is one spot left in a class, but two users open the form at the same time, if the first user complete the form and submits, it should make the spot unavailable for the second user but for some reason the user is still able to submit the form with the sold out spot because it only updates if the form us refreshed or the form is opened after the submission is sent

    so if you are on the form before it is submitted it acts as though there is still spots available which ends up over selling

    so i need another check while the for, is being submitted   

  • Kevin Support Team Lead
    Replied on February 12, 2016 at 4:56 PM

    I'm not sure if the workaround provided on the link you shared us will work, since as explained there, the code within an iFrame can not be modified with Javascript.

    In regards to the second question, I think that this link will help you: http://stackoverflow.com/questions/4249809/reload-an-iframe-with-jquery.

    Since the only way to refresh the options without refreshing the entire webpage, is loading only the iFrame.

    If you would like to discuss further this option, please open a new thread, we will be glad to assist you there.

  • chrispp10
    Replied on February 12, 2016 at 6:37 PM

    Here is a copy of my new thread 

    http://www.jotform.com/answers/771362-Recheck-users-ticket-purchases-before-submitting/?entrymessage=10732640770

  • Kevin Support Team Lead
    Replied on February 12, 2016 at 11:59 PM

    I can see there are multiple threads about the same question, so one of my colleagues will assist you soon in one of them.

  • chrispp10
    Replied on February 13, 2016 at 5:27 PM

    Kevin_G can you please assist me on getting this working please

  • Kevin Support Team Lead
    Replied on February 13, 2016 at 9:19 PM

    I will post my reply on this thread: http://www.jotform.com/answers/771368-Recheck-ticket-purchases-before-submitting#3.

    Please follow only that thread, and please avoid to post any replay in other threads, this will help us to get confused and we will be able to assist you better.