日期:2014-05-17  浏览次数:20381 次

动态行追加后的取值问题
各位高手,我想把location取得值,插入DB里。
想问的是,除了从text box表示的参数能插入DB,还有别的办法吗?

参考:
<script type="text/javascript">
  function getdata(){
  if(window.location.search){
  /* URLの「?」以降のパラメータを変数nに代入 */
  var n=window.location.search.substring(1,window.location.search.length);
  /* 在text box表示参数 */
  document.form3.elements["getpram"].value=n;
  }
  }
  /* 加载時実行 */
  window.onload=getdata;
</script>

<form name="form3" action="#">
  取得参数:<input type="text" name="getpram" size="50" />
</form>

------解决方案--------------------
你的那个 DB 是什么?
从字面理解应该是服务器端的数据库吧

那么 window.location 的值不是从服务器端返回的吗?
为什么不在服务器端直接处理呢?

------解决方案--------------------
具体代码太复杂没法给你写

基本思路可以是
js 动态的创建tr td 和input

然后php可以直接遍历
$_GET
或者$_POST
数组就能取得所有值