简体   繁体   中英

Selectbox option on click of image

I got a plugin that generates extra options for products (woocommerce).

  1. I create selectbox with few options like: blackky, whiteey, greyyy

  2. Then I create radio buttons with images: blackk, whitee, greyy

How can I 'connect it' so if someone clicks on 'blackk' it also select 'blackyy' option in selectbox.

Links how it looks:

https://dobrzekupuj.pl/product/woo-album-1/

https://dobrzekupuj.pl/product/woo-album-2/

Something like this. Your values are not easy to parse

$("[name=tmcp_radio_1]").on("click",function() {
  var val = this.value
  if (val) $("#tmcp_select_1").val(val.split("_")[0]+"ey_1")
})

$("#tmcp_select_1").on("change",function() {
  var val = this.value
  if (val) $("[name=tmcp_radio_1][value="+val.split("y_")[0]+"_1]").click()
})

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM