2015-06-10 37 views
1

您好,並提前感謝您的任何幫助 在我的商店頁面,我有一個複選框,當用戶同意條款時進行檢查。當他檢查複選框時,提交按鈕被禁用(false)。我的問題是,這個解決方案不適用於iPhone和其他移動設備。複選框與JS和移動

下面的代碼:

function terms() { 
 
    if (document.getElementById("cbTerms").checked) 
 
    document.getElementById("submit").disabled = false; 
 
    else 
 
    document.getElementById("submit").disabled = true; 
 
} 
 

 
function cbc() { 
 
    if (document.getElementById("cbc").checked) 
 
    document.getElementById("cbc") = ("הריני מאשר קבלת מבצעים והטבות אל הדואר האלקטרוני מפראיה"); 
 
    else 
 
    document.getElementById("cbc").value = "."; 
 
}
<input class="btn btn-toranj alt" name="submit" type="submit" id="submit" value="לרכישה" disabled="true"> 
 
<br> 
 
<br> 
 
<input type="checkbox-0" id="cbTerms" name="cbTerms" onclick="terms();" style="width:15px; height:15px;"> 
 
<p style="margin-bottom:0px; font-size:14px; display: -webkit-inline-box;">הריני מאשר כי קראתי את <a href="regulations.html" style="color:#E49D1F;">התקנון</a> 
 
</p> 
 
<br> 
 
<input type="checkbox" id="cbc" name="os3" oninput="cbc()" style="width:15px; height:15px;"> 
 
<p style="margin-bottom:0px; font-size:14px; display: -webkit-inline-box;">הריני מאשר קבלת מבצעים והטבות אל דואר האלקטרוני</p> 
 
<input type="hidden" value="הטבות ומבצעים" id="on3" name="on3">

回答

1

乍一看,你的第一個複選框是不是一個真正的複選框。

<input type="checkbox-0" ...>應該更像:<input type="checkbox" ...>

隨着這一變化,將工作。

P.S:

考慮使用括號爲您if() {} else {}語句,你會propably碰到一些邏輯錯誤,如果你在未來改變的東西(例如添加一行代碼),卻忘了添加。

0

更改事件優於點擊。而除此之外,你通過點擊當前複選框上飛如下

<input class="btn btn-toranj alt" name="submit" type="submit" id="submit" value="לרכישה" disabled="true"> 
<br><br> 
<input type="checkbox" id="cbTerms" name="cbTerms" onchange="terms(this);" style="..."> 
<p style="...">הריני מאשר כי קראתי את 
<a href="regulations.html" style="...">התקנון</a> 
</p> 
<br>  
<input type="checkbox" id="cbc" name="os3" onchange="cbc(this)" style="..."> 
<p style="...">הריני מאשר קבלת מבצעים והטבות אל דואר האלקטרוני</p> 
<input type="hidden" value="הטבות ומבצעים" id="on3" name="on3"> 

<script type="text/javascript"> 
function terms(me) 
{ 
    document.getElementById("submit").disabled = !me.checked; 
} 
    function cbc(me){ 
    var val=document.getElementById("cbc").checked? 
     "הריני מאשר קבלת מבצעים והטבות אל הדואר האלקטרוני מפראיה":"."; 
    document.getElementById("cbc").value = val; 
} 
</script> 
+0

DKSan複選框爲的複選框-0是一些答案,我覺得在「移動複選框」的網頁。 Bellash我將代碼替換爲您提供的代碼並且沒有任何更改,但它仍然可以在網絡上使用,但歡迎您查看:www.praia.co.il/praiamoro.html,但通過移動設備無法使用。 –