D
D
Daniil Vershinin2019-03-17 13:48:10
OctoberCMS
Daniil Vershinin, 2019-03-17 13:48:10

October CMS AJAX pass radio, checkbox?

Following the example in this article https://mraak.ru/octobercms/october-cms-builder-pl...

<input type="checkbox" name="checkme" value="0">
<input type="checkbox" name="checkme" value="1">
<input type="checkbox" name="checkme" value="2">
<button ion="data=#fullpage input;ajax=/orderscooter;prepend=#SystemMessages;">Заказать</button>

Handler:
function onStart(){
$checkme= post('checkme');
....

The problem is that in $checkme there is an extreme value of checkboxes (in this example, whatever you choose, it turns out 2)
There is a suspicion that something is in POST beforehand, but does not want to change.
Maybe this somehow affects, but when I click on the input, I also have an onclick event handler .. It looks like

a curve developer plugin, because it probably processes the DOM by name, so it turns out that the variable is overwritten to the last value.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
D
Daniil Vershinin, 2019-03-17
@Titamik

Suspicions justified

dataParse: function (selector)
    {
        var inputs = $(selector).length;
        var data = {};
        for (var i = 0; i < inputs; i++)
        {
            var obj = $(selector).eq(i);
            var name = $(obj).attr('name');
            
            if(obj.val() !== ""){
                data[name] = obj.val();
            } else {
                
                if(obj.attr('value') === undefined){
                    data[name] = obj.text();
                } else {
                    data[name] = obj.attr('value');
                }
            }  
        }
        return data;
    }

N
Nikita Khaetsky, 2019-04-03
@ReaZzon

<input type="checkbox" name="checkme" value="0">
<input type="checkbox" name="checkme" value="1">
<input type="checkbox" name="checkme" value="2">

You are not using the Checkbox element correctly. In this case, you need a radio, not a checkbox.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question