我们可以通过提交表单发布getelement.id('')。innerhtml吗?

时间:2019-02-08 17:40:29

标签: javascript php html mysql

我想从.innerhtml中获取价值,然后通过提交表单将其发布,但是它不起作用。与查询的帖子值不同,它可以很好地工作。我尝试过的代码。

<form enctype = "multipart/form-data" method="post" 
style="width:auto;" >
//i want post 3452 to other file2
<div class="box">
<span class='odometer' id="timespan">3452</span>
</div>

<input class="process"  name="submit" type="submit" value="Pemenang" 
onclick="location.href='file2.php?RWD_IMG=<?php echo 
$rwdimg?>&RWD_DET_NBR=<?php echo $rwdetz?>&RWD_HEADS_NBR=<?php echo 
$RwdNbr?>&RWD_DESC=<?php echo $DESC;?>&TOTALREWARD=<?php echo 
$totalreward;? 
>&POIN='+document.getElementById('timespan').innerHTML;">
</form>

1 个答案:

答案 0 :(得分:0)

您应该创建一个处理位置更改的函数:

<script>
  function changeLocation() {
    return location.href = <?php echo $rwdimg ?>&RWD_DET_NBR=<?php echo $rwdetz ?>&RWD_HEADS_NBR=<?php echo $RwdNbr ?>&RWD_DESC=<?php echo $DESC; ?>&TOTALREWARD=<?php echo $totalreward; ?> + document.getElementById('timespan').innerHTML
  }
</script>
<form enctype = "multipart/form-data" method="post" style="width:auto;" >
  <div class="box">
  <span class='odometer' id="timespan">3452</span>
</div>
<input class="process"  name="submit" type="submit" value="Pemenang" onclick="changeLocation" />
</form>