[英]Show the function text onclick
我正在嘗試使用Lightspeed / Twig / Rain,因此我真的需要一些幫助,我正在嘗試做些什么。
因此,頁面上有幾個字段的值為product_configure_custom_2459429和product_configure_custom_2459282。 人們可以填寫這些字段中的數字,我想要一個按鈕,他們點擊該按鈕查看總數是否為18。
所以我現在有這個:
<input style="width: 600px;" type="button" onclick="{% if 'product_configure_custom_2459282' + 'product_configure_custom_2459429' == '18' %}
{{ 'Je hebt 18 stuks' | t }}
{% else %}
{{ 'Zorg dat je 18 stuks hebt' | t }}
{% endif %}"></input>
這可以做它需要做的事情,但現在我希望onclick函數的結果可以作為按鈕上的文本顯示。 所以基本上我希望人們點擊按鈕然后他們看到按鈕'Je hebt 18 stuks'(=他們選擇了18件)或'Zorg dat je 18 stuks hebt'。 每次單擊,該功能都應重新加載,這就是我嘗試使用Onclick功能的原因。
但是現在按鈕顯示為空。 當我檢查它時,我看到onclick函數正常工作並加載,但我似乎無法使該函數的結果顯示為按鈕上的文本。
所以我真的希望有人可以幫助我。 我非常感激!
在這里,您可以看到它的實際效果: http : //testshop-generationshop.webshopapp.com/bslect.html
嘗試這個 :
onclick="this.value = +document.getElementById('product_configure_custom_2459429').value + +document.getElementById('product_configure_custom_2459282').value == 18 ? 'Je hebt 18 stuks' : 'Zorg dat je 18 stuks hebt'"
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.