【发布时间】:2018-05-18 09:36:05
【问题描述】:
我想更改输入的值并在单击后提交。 由于某种原因,它没有提交。
点击div时input里面的值增加或者减少,但是没有提交。
当我更改输入和焦点内的值时,它确实保存了。
我在这里错过了什么?
<div class="reduced items item-<?php echo $this->getQty() ?>" onclick="
var result_<?php echo $item->getId() ?> = document.getElementById('qty_<?php echo $item->getId() ?>');
var qty_<?php echo $item->getId() ?> = result_<?php echo $item->getId() ?>.value;
if( !isNaN( qty_<?php echo $item->getId() ?> ) && qty_<?php echo $item->getId() ?> > 1 ) result_<?php echo $item->getId() ?>.value--;
$(location.href='save').submit();
return false;">-</div>
<input type="text" name="quote_request[<?php echo $item->getId() ?>][qty][]" id="qty_<?php echo $item->getId() ?>" value="<?php echo $item->getQty()*1; ?>" size="4" title="<?php echo $this->__('Qty') ?>" onchange="location.href='save'" class="required-entry validate-zero-or-greater input-text" maxlength="12" />
<div class="increase items" onclick="
var result_<?php echo $item->getId() ?> = document.getElementById('qty_<?php echo $item->getId() ?>');
var qty_<?php echo $item->getId() ?> = result_<?php echo $item->getId() ?>.value;
if( !isNaN( qty_<?php echo $item->getId() ?> )) result_<?php echo $item->getId() ?>.value++;
$(location.href='save').submit();
return false;">+</div>
【问题讨论】:
-
我在这里缺少什么? - 一些格式化技巧...伙计 - 整理你的格式,你可能会让一些人能够真正看到你的代码... Oo
-
那段代码不可读。请向我们展示一个实际生成的 HTML 示例,最好是 minimal reproducible example 我也强烈怀疑
$(location.href='save').submit();不会做你认为的那样。
标签: javascript jquery html