javascript not showing properly in safari
I have a javascript code, that sets a maximum quantity that can be select, and a form in which I am using it.
The problem is that, in Safari browser, I actually cannot add开发者_JS百科 a product(the form cannot be submitted) Any idea why? Thank you ! I put the code below:
<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>
and i use it here:
<? 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>
New Errors:
Error: $(".social").jsocial is not a function
Source File: /sales
Line: 184
I do not have a number of items to add: Alege numarul de produse
so if the server needs an amount, it is not getting it, which is why I think you throw that horrible error
If you need addtobasket, you are not calling it correctly
<button ;="" onclick="addtobasket" name="submit" type="submit">Adauga in cos</button>
OLD ERRORS
Error: syntax error
Source File: /sales
Line: 194, Column: 4
Source Code:
});
You need to remove the above from just before the </script>
then when I click add to basket, I get the old error I have already posted for you:
Error: missing ) after argument list
Source File: /sale/1009/category/52/product/169
Line: 1, Column: 20
Source Code:
valbutton(addtobasket
which is the line
<button type="submit" name = "submit" onclick="valbutton(addtobasket");>Adauga in cos</button><br />
which needs to be
<button type="submit" name = "submit" onclick="valbutton(addtobasket)">Adauga in cos</button><br />
assuming you have a function valbutton()
anywhere
I also see you have scripts loaded more than once and different versions of the same script - you MUST fix that:
° 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
Here is my suggestions - not sure of the end result since I cannot test your code
<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>
精彩评论