Kontrollkästchen mit Senden Button verknüpfen

Hallo,

Ich habe folgendes Problem:

Ich habe mehrere Kontrollkästchen mit unterschiedlichen Werten.
Nun möchte ich, dass wenn ein Kontrollkästchen angewählt wird, dass bei den Sende Button eine andere URL angewählt wird…

Z.b.
12 Monate angewählt = Button Senden von URL: https://www.test.de/12monate
24 Monate angewählt = Button Senden von URL: https://www.test.de/24monate

ist dies Realisierbar?

würde mich über eine Antwort freuen.

English Translate

Hello

I have the following problem:

I have several check boxes with different values.

Now I want a check box to be applied to the Send button with a different URL …

Zb 12 months selected = Button Send URL: https://www.test.de/12monate

24 months selected = Send URL button: https://www.test.de/24monate

is it possible to achieve?

would hear me about an answer.

Hi,
This forum is in English, please translate your question so we can assist you.

Hello

I have the following problem:

I have several check boxes with different values.

Now I want a check box to be applied to the Send button with a different URL …

Zb 12 months selected = Button Send URL: https://www.test.de/12monate

24 months selected = Send URL button: https://www.test.de/24monate

is it possible to achieve?

would hear me about an answer.

Hello edv,
add as value to your checkbox the needed string behind the https://www.test.de/ “your needed string”
so in the 2 cases you showed here
value of checkbox 12 months should be “12monate”
value of checkbox 24 months should be “24monate”

on the top of your page you add the line
import wixLocation from ‘wix-location’ ;
let link;
then for your checkboxes start a "onChange() function in the properties tab.
add this line to it :
link = $w(“#yourcheckbox”).value

then when you press the button add this to the onClick() function

wixLocation.to( “https://www.test.de/” +link) // this will add the string “link” to your location and will difference when changing your checkboxes

hope this helps

grtz
Kristof.

Thats Work… but only with one of link on a button … i Will 3 differents links in 1 of a Button… my Script:

import wixLocation from ‘wix-location’ ;
let link;
let link2;
let link3;

export function checkbox1_change(event) {
link=$w( “#checkbox1” ).value
}
export function checkbox2_change(event) {
link2=$w( “#checkbox2” ).value
}
export function checkbox3_change(event) {
link3=$w( “#checkbox3” ).value
}

export function button1_click(event) {
wixLocation.to( “https://elopage.com/” +link +link2 +link3)
}
$w.onReady( function () {

});

I Hope you can help me

My HOmepage: www.tankfuxx.de/Werbepakete

hi edv,
i think this should work

import wixLocation from ‘wix-location’ ; let link; let link2; let link3; export function checkbox1_change(event) {
link=$w( " #checkbox1 " ).value
}
export function checkbox2_change(event) {
link=$w( " #checkbox2 " ).value
}
export function checkbox3_change(event)
{
link=$w( " #checkbox3 " ).value
}
export function button1_click(event) {
wixLocation.to( “https://elopage.com/” +link)
}
$w.onReady( function () {

});

Doing it like this will always change the “let link” to the needed string.

if you do link + link2 + link 3
the first time you select a checkbox it will work.
the second time it will not work anymore since you place 2 string behind each other.

also instead of using checkboxes youcan use radio buttons.
if you use checkboxes you can select more then 1 at the same time.
if you use radio buttons you can only have 1 selected item.

kristof.

this are radio buttons

@volkaertskristof Yeah, its work with your Code… One question … I only want the button to be active when a box has been selected
is that possible?

@edv
sure thats possible

are you going to work with the checkboxes or radio buttons?
couse if you have a radiobutton its easy but you cannot “unscheck” it anymore once checked.

With checkboxes

import wixLocation from ‘wix-location’ ;
let link;

export function checkbox1_change(event) {
link=$w( “#checkbox1” ).value
}
export function checkbox2_change(event) {
link=$w( “#checkbox2” ).value
}
export function checkbox3_change(event) {
link=$w( “#checkbox3” ).value
}

export function button1_click(event) {
wixLocation.to( “https://www.elopage.com/” +link)
}
$w.onReady( function () {

});

make a function

function checkcheckboxes() {
// add an if statement
// .checked sees if its true or false.
//you can also do checkbox1.checked === true

if (checkbox1.checked || checkbox2.checked || checkbox3.checked {
//add what to do if 1 of those checkboxes is checked
button1.enable()
//you can also use .expand()
} else {
//add what to do if none is selected
button1.disable()
//you can also use .collapse()
}
}

add it to your checkboxes
exportfunction checkbox1_change(event) {
link=$w( “#checkbox1” ).value
checkcheckboxes()
}
.expand() and .collapse()
will show/hide the button.
and move evrything down the button up so you don’t have an empty space.

ps.
if since you said it works.
please do add it as best answer so other people can easly find it.
and they will also know it is answered.

kristof.

Hello… by Developer Console come a Error :

TypeError: button1_click.disable is not a function

import wixLocation from ‘wix-location’ ;
let link;

function checkcheckboxes() {
// add an if statement
// .checked sees if its true or false.
//you can also do checkbox1.checked === true

if (checkbox1_change.checked || checkbox2_change.checked || checkbox3_change.checked){
//add what to do if 1 of those checkboxes is checked
button1_click.enable()

//you can also use .expand()
} else {
//add what to do if none is selected
button1_click.disable()

//you can also use .collapse()
}
}

export function checkbox1_change(event) {
link=$w( “#checkbox1” ).value
checkcheckboxes()
}
export function checkbox2_change(event) {
link=$w( “#checkbox2” ).value
checkcheckboxes()
}
export function checkbox3_change(event) {
link=$w( “#checkbox3” ).value
checkcheckboxes()
}

export function button1_click(event) {
wixLocation.to( “https://www.elopage.com/” +link)
}

//

let link2;

export function checkbox4_change(event) {
link2=$w( “#checkbox4” ).value
}

export function checkbox5_change(event) {
link2=$w( “#checkbox5” ).value
}

export function checkbox6_change_1(event) {
link2=$w( “#checkbox6” ).value
}
export function button2_click(event) {
wixLocation.to( “https://www.elopage.com/” +link2)
}

//

let link3;

export function checkbox9_change(event) {
link3=$w( “#checkbox9” ).value
}

export function checkbox8_change(event) {
link3=$w( “#checkbox8” ).value
}

export function checkbox7_change(event) {
link3=$w( “#checkbox7” ).value
}

export function button3_click(event) {
wixLocation.to( “https://www.elopage.com/” +link3)
}

//

let link4;

export function checkbox10_change(event) {
link3=$w( “#checkbox10” ).value
}

export function checkbox11_change(event) {
link3=$w( “#checkbox11” ).value
}

export function checkbox12_change(event) {
link3=$w( “#checkbox12” ).value
}

export function button4_click(event) {
wixLocation.to( “https://www.elopage.com/” +link4)
}

$w.onReady( function () {

});

It has to be button1.enable() or button1.disable()
You have button1_click.enable()

Kristof.

he sad : ‘Button1’ is not defined

button with a small b
and did you rename your buttons?

ReferenceError: button1 is not defined

No my button name is
ID button1
#button1

haha sorry how could i mis that.
i sended it when i whas on the phone sorry.
you always have to refer to elements like this
$w(“#ElementName”)
so button1 has to be $w(“#button1”)
so it has to be
$w(“#button1”).enable()

kristof.

Hey …

Now I have the problem when I click www.tankfuxx.de/werbepakete for 24 months to check that the button will disable …
I would like it the other way around … No check selected, Butto disable, 1 check selected - button enable

I think I’m too stupid

// Für volle die API-Dokumentation, einschließlich Codebeispiele, besuchen Sie http://wix.to/94BuAAs
import wixLocation from 'wix-location';
let link; 

function checkcheckboxes() {
// add an if statement 
// .checked sees if its true or false.
//you can also do checkbox1.checked === true

if (checkbox1_change.checked || checkbox2_change.checked || checkbox3_change.checked){
//add what to do if 1 of those checkboxes is checked
$w("#button1").enable()

//you can also use .expand()
} else {
//add what to do if none is selected
$w("#button1").disable()

//you can also use .collapse()
}
}

export function checkbox1_change(event) {
    link=$w("#checkbox1").value
    checkcheckboxes()
}
export function checkbox2_change(event) {
    link=$w("#checkbox2").value 
    checkcheckboxes()
}
export function checkbox3_change(event) {
    link=$w("#checkbox3").value 
    checkcheckboxes()
}

export function button1_click(event) {
    wixLocation.to("https://www.elopage.com/" +link) 
}

//

let link2;


export function checkbox4_change(event) {
    link2=$w("#checkbox4").value 
}

export function checkbox5_change(event) {
    link2=$w("#checkbox5").value 
}

export function checkbox6_change_1(event) {
    link2=$w("#checkbox6").value 
}
export function button2_click(event) {
    wixLocation.to("https://www.elopage.com/" +link2) 
}

//



let link3;

export function checkbox9_change(event) {
    link3=$w("#checkbox9").value 
}

export function checkbox8_change(event) {
    link3=$w("#checkbox8").value 
}

export function checkbox7_change(event) {
    link3=$w("#checkbox7").value 
}

export function button3_click(event) {
    wixLocation.to("https://www.elopage.com/" +link3) 
}

//


let link4;

export function checkbox10_change(event) {
    link3=$w("#checkbox10").value 
}

export function checkbox11_change(event) {
    link3=$w("#checkbox11").value 
}

export function checkbox12_change(event) {
    link3=$w("#checkbox12").value 
}

export function button4_click(event) {
    wixLocation.to("https://www.elopage.com/" +link4)  
}


$w.onReady(function () {


});

Its the same problem as before but with a different element.

if ( checkbox1_change . checked || checkbox2_change . checked || checkbox3_change . checked ){
//add what to do if 1 of those checkboxes is checked
$w ( “#button1” ). enable ()

you added checkbox1_change.checked

it has to be checkbox1.checked

kristof.

When I type checkbox1.checked it says that it is not defined.

sorry that i have so many problems