×

Loading...
Ad by
  • 推荐 OXIO 加拿大高速网络,最低月费仅$40. 使用推荐码 RCR37MB 可获得一个月的免费服务
Ad by
  • 推荐 OXIO 加拿大高速网络,最低月费仅$40. 使用推荐码 RCR37MB 可获得一个月的免费服务

Try this code. I just made slight changes to your code. Hope it helps.

本文发表在 rolia.net 枫下论坛<html>
<head>
<script type="text/javascript">
var selectedButton;
function buildSelect(x,y,step,selButton) { //alert(x) ; //return
selectedButton = selButton;
count = 0;
for(i=y;i>x;i=i-step){
document.selectform.selectmenu.options[count] = new Option(i)
count++;
}
return;
}
function sentSelect(evalue) { //alert(x) ; //return
alert(selectedButton.value);
selectedButton.value = evalue;
return;
}
</script>
</HEAD>
<BODY>
<div align="center">
<form name="selectform">
<select name="selectmenu" size = "2">
<option size="2">
</select>
<input type=button value="Item Select Item" onClick="sentSelect(document.selectform.selectmenu.options[document.selectform.selectmenu.selectedIndex].text);">
<br>
</form>
</div>
<form name=targetform>
Item1: <input type=button name=choice1 onClick="buildSelect(1,10,2,this)" value=" >> Choose1 << "><br>
Item2: <input type=button name=choice2 onClick="buildSelect(1,20,1,this)" value=" >> Choose2 << "><br>
<p>
</form>
</body>
</html>更多精彩文章及讨论,请光临枫下论坛 rolia.net
Report

Replies, comments and Discussions:

  • 工作学习 / 专业技术讨论 / 哪位朋友帮我看一看有关java-script的问题。
    本文发表在 rolia.net 枫下论坛要实现的功能是

    摁一下choose1, 在selectitem的form里出现需要的options,然后选择一个值, 再摁一下itemslect button, 在choose1的value changed to the item selected。

    同样对button choose2也是一样的。两者的不同是option的不同。

    多谢




    <html>

    <head>
    <script type="text/javascript">

    function buildSelect(x,y,step) { //alert(x) ; //return
    count = 0;
    for(i=y;i>x;i=i-step){
    document.selectform.selectmenu.options[count] = new Option(i)
    count++;
    }
    return;
    }

    function sentSelect(target, value) { //alert(x) ; //return
    document.targetform.choice.value = 12;
    return;
    }



    </script>

    </HEAD>

    <BODY>

    <div align="center">
    <form name="selectform">
    <select name="selectmenu" size = "2">
    <option size="2">
    </select>
    <input type=button value="Item Select Item" onClick="sentSelect("targetform",this.form.selectmenu)">
    <br>
    </form>
    </div>

    <form name=targetform1>
    Item1: <input type=button name=choice1 onClick="buildSelect(1,10,2)" value=" >> Choose1 << "><br>
    Item2: <input type=button name=choice2 onClick="buildSelect(1,20,1)" value=" >> Choose2 << "><br>
    <p>

    </form>
    </body>

    </html>更多精彩文章及讨论,请光临枫下论坛 rolia.net
    • Try this code. I just made slight changes to your code. Hope it helps.
      本文发表在 rolia.net 枫下论坛<html>
      <head>
      <script type="text/javascript">
      var selectedButton;
      function buildSelect(x,y,step,selButton) { //alert(x) ; //return
      selectedButton = selButton;
      count = 0;
      for(i=y;i>x;i=i-step){
      document.selectform.selectmenu.options[count] = new Option(i)
      count++;
      }
      return;
      }
      function sentSelect(evalue) { //alert(x) ; //return
      alert(selectedButton.value);
      selectedButton.value = evalue;
      return;
      }
      </script>
      </HEAD>
      <BODY>
      <div align="center">
      <form name="selectform">
      <select name="selectmenu" size = "2">
      <option size="2">
      </select>
      <input type=button value="Item Select Item" onClick="sentSelect(document.selectform.selectmenu.options[document.selectform.selectmenu.selectedIndex].text);">
      <br>
      </form>
      </div>
      <form name=targetform>
      Item1: <input type=button name=choice1 onClick="buildSelect(1,10,2,this)" value=" >> Choose1 << "><br>
      Item2: <input type=button name=choice2 onClick="buildSelect(1,20,1,this)" value=" >> Choose2 << "><br>
      <p>
      </form>
      </body>
      </html>更多精彩文章及讨论,请光临枫下论坛 rolia.net
      • works great. Thank you very much. It solved alot of problem for me.
        • You are welcome. You'll get better idea if you use javascript DOM.