【发布时间】:2011-04-17 18:45:55
【问题描述】:
我有一个 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>
【问题讨论】:
-
valbutton 的代码在哪里,它不属于提交按钮,也从不将表单元素命名为“提交”
-
没有错误。我根本无法将对象添加到篮子中。当我按下提交按钮时它不会提交。
-
@Dana:请贴出相关代码。您发布的代码不会被表单代码调用 - 我猜您可能会尝试在提交事件中调用提交
-
在这个问题中也没有调用它stackoverflow.com/questions/5540658/…
-
在表单中调用。它是jQuery。查看表单的 ID
标签: javascript forms browser safari conflict