简体   繁体   English

将html值从表单传递到JavaScript函数

[英]passing html value from a form to JavaScript function

I am trying to pass the value and text from a form to a JavaScript function using the onclick on a button but don't seem to be able to get it to work I want to keep this as generic as possible so I copy and paste the form 我正在尝试使用按钮上的onclick将值和文本从表单传递给JavaScript函数,但似乎无法使其正常工作,我想尽量保持通用,因此我将其复制并粘贴形成

    <form name='f1'>
    <form method="post" action="https://www.paypal.com/cgi-bin/webscr">
 <input type="hidden" name="item_name" value="Span>
 <input type="hidden" name="amount" value="68">


 <input type="hidden" name="cmd" value="_cart">
 <input type="hidden" name="add" value="1">
 <input type="hidden" name="business" value="test@hotmail.com">
 <select name="del">
 <option value="0">Delivery To</option>
 <option value="41">Uk</option>
 <option value="39">USA</option>
 <option value="20">World Wide</option>
</select>

      <input type="image" src="http://www.paypalobjects.com/en_US/i/btn/x-click-but22.gif"   
onClick="shipping1(this.options.selectedindex.value,this.options.selectedindex.text)" border="0" name="submit" width="87" height="23"        alt="Make payments with PayPal - it's fast, free and secure!">
   </form>
   </form>  

i think it may be the formating of this.options any help would be great 我认为这可能是this.options的格式,对您的帮助会很大

尝试这个。

onClick="shipping1(this.form.del[this.form.del.selectedIndex].value,this.form.del[this.form.del.selectedIndex].text)"

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM