×

Loading...
Ad by
  • 最优利率和cashback可以申请特批,好信用好收入offer更好。请点链接扫码加微信咨询,Scotiabank -- Nick Zhang 6478812600。
Ad by
  • 最优利率和cashback可以申请特批,好信用好收入offer更好。请点链接扫码加微信咨询,Scotiabank -- Nick Zhang 6478812600。

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.