我有一个javascript代码,用于设置可以选择的最大数量,以及我正在使用它的表单。
问题是,在Safari浏览器中,我实际上无法添加产品(表单无法提交) 知道为什么吗?谢谢 !我把代码放在下面:
<script type="text/javascript">
function selecteazaElement(id,stock)
{
document.addtobasket.idOfSelectedItem.value=id;
var number23=document.addtobasket.number;
number23.options.length=0;
if (stock>=6)
stock=6;
for (i=1;i<=stock;i++)
{
//alert ('id: '+id+'; stock: '+stock);
number23.options[number23.options.length]=new Option(i, i);
}
//window.status="my status";
}
</script>
我在这里使用它:
<? foreach ($types as $type):?>
<ul class = "product_types">
<? if ($type->stock_2 > 0):?>
<li id = 'product_types'><a href="#" onclick='selecteazaElement(<?= $type->id; ?>,<?= $type->stock_2; ?>);'><?= $type->label; ?></a></li>
<? else: ?>
<li id = 'product_unavailable_types'><label><?= $type->label; ?></label></li>
<? endif; ?>
</ul>
<? endforeach; ?>
<form id="addtobasket" name="addtobasket" method="POST" action="<?= Route::url('Add to Basket', array('sale_id' => $sale->id)); ?>">
<input type="hidden" name="idOfSelectedItem" id="idOfSelectedItem" value="-1">
<select name="number" id="number">
<option value=0>Alege numarul de produse</option> </select>
<button type="submit" name = "submit" onclick="addtobasket";>Adauga in cos</button><br />
</fieldset>
</form>
答案 0 :(得分:0)
以下是我的建议 - 不确定最终结果,因为我无法测试您的代码
<script type="text/javascript">
function selecteazaElement(id,stock) {
document.addtobasket.idOfSelectedItem.value=id;
var number23=document.addtobasket.number;
number23.options.length=0;
if (stock>6) stock=6;
for (i=1;i<=stock;i++) {
number23.options[number23.options.length]=new Option(i, i);
}
return false; // cancel the link
}
function valbutton(theForm) {
// I still do not know what this does
if (something wrong) return false; // cancel the form
.
.
return true; // allow form submission
}
</script>
<li id = 'product_types'><a href="#" onclick='return selecteazaElement(<?= $type->id; ?>,<?= $type->stock_2; ?>);'><?= $type->label; ?></a></li>
<form id="addtobasket" name="addtobasket" onSubmit="return valbutton(this)"
method="POST" action="<?= Route::url('Add to Basket', array('sale_id' => $sale->id)); ?>">
.
.
<input type="submit" value="Adauga in cos"/><br />
</form>
答案 1 :(得分:0)
Error: $(".social").jsocial is not a function
Source File: /sales
Line: 184
我没有要添加的项目数量: Alege numarul de produse
所以如果服务器需要一个金额,它就没有得到它,这就是为什么我认为你抛出那个可怕的错误
如果你需要addtobasket,你没有正确地调用它
<button ;="" onclick="addtobasket" name="submit" type="submit">Adauga in cos</button>
Error: syntax error
Source File: /sales
Line: 194, Column: 4
Source Code:
});
您需要在</script>
然后当我点击添加到购物篮时,我收到了我已经为您发布的旧错误:
Error: missing ) after argument list
Source File: /sale/1009/category/52/product/169
Line: 1, Column: 20
Source Code:
valbutton(addtobasket
这是
行 <button type="submit" name = "submit" onclick="valbutton(addtobasket");>Adauga in cos</button><br />
需要
<button type="submit" name = "submit" onclick="valbutton(addtobasket)">Adauga in cos</button><br />
假设您有function valbutton()
任何地方
我也看到你有不止一次加载的脚本和同一个脚本的不同版本 - 你必须修复它:
°jquery.easing-1.3.pack.js
°jquery.easing.1.2.js
°coin-slider.js
°coin-slider.min.js
°paginator.js
°paginator.js
°slides.min.jquery.js
°slides.min.jquery.js