想要将asp.net Label值分配给html隐藏字段的值 [英] Want to assign asp.net Label value to html hidden field's value

查看:85
本文介绍了想要将asp.net Label值分配给html隐藏字段的值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想将asp.net Label Control值分配给html隐藏字段的值



实际上我想将Paypal BuyNow按钮集成到我的购物网站

i已复制代码BuyNow Button Code,我将其用于将Paypal集成到我的网站



< form id = form1runat =serveraction =https://www.sandbox.paypal.com/cgi-bin/webscrmethod =post>

< input type =隐藏name =cmdvalue =_ cart>

< input type =hiddenname =uploadvalue =1>

< input type =hiddenname =businessvalue =abc@gmail.com>

< input type =hiddenname =item_name_1value =汇总的商品>

< input type =hiddenname =amount_1id =amtvalue =>

< input type =submitvalue =PayPal>

< / form>



< asp:Label ID =Label1runat =serverText =Label>





i想要将Label1值分配给隐藏字段id =amt



我怎么能实现这一点请任何人帮助我,因为我是编程和网站开发的新手,我不知道根本不知道javascript

i want to assign asp.net Label Control value to html hidden field's value

actually i want to integrate Paypal BuyNow button into my Shopping Website
i have copied the code BuyNow Button Code below which i am using to integrate Paypal into my website

<form id="form1" runat="server" action="https://www.sandbox.paypal.com/cgi-bin/webscr" method="post">
<input type="hidden" name="cmd" value="_cart">
<input type="hidden" name="upload" value="1">
<input type="hidden" name="business" value="abc@gmail.com">
<input type="hidden" name="item_name_1" value="Aggregated items">
<input type="hidden" name="amount_1" id="amt" value="" >
<input type="submit" value="PayPal" >
</form>

<asp:Label ID="Label1" runat="server" Text="Label">


i want to assign Label1 value to hidden field id="amt"

how can i achieve that please anyone help me out as i am a novice to programming and website development and i don't know javascript at all

推荐答案

永远不要接受来自不安全网站的代码来处理任何与真钱有关的事情。

你不知道是谁给你代码,你不知道它做了什么,你不知道它将钱正确地放入适当的帐户,而不将细节传递给任何第三方。



只能从Paypal获取此类代码 - 否则欺诈范围太大。请记住,如果您的行为被视为疏忽,您个人可能会对丢失的任何款项承担责任 - 从公共论坛获取您的代码肯定会是!



说真的:这不是一个学习做基本的东西的地方,因为你一直都是个好主意。首先练习并熟练掌握网页设计和编码的所有其他方面(尤其是安全隐患)。如果你不专业地完成这项工作,你可能会在这里认真地自掏腰包,甚至在监狱里。
Never, ever, accept code from a insecure website to handle anything to do with real money.
You do not know who is giving you the code, you do not know what it does, you do not know that it places the monies correctly into the appropriate account, without passing the details to any third parties.

Only get such code from Paypal - the scope for fraud otherwise is far too large. And remember, you personally could be liable for any monies lost if your action is seen to be negligent - which getting your code from a public forum would most certainly be!

Seriously: this is not an area where learning to do basic stuff as you go along is a good idea. Practice and become proficient in all other aspects of web design and coding (especially the security implications) first. You could end up seriously out of pocket here, or even in jail if you don't do the job professionally.


我已经解决了我自己的问题



解决方案是添加一个javascript函数并调用它



这是修改后的代码



< script>

函数MyScript()

{

var x,y;

x = document.getElementById('<%= Label1.ClientID%>')。innerHTML;

y = document.getElementById(amt)。value = parseFloat(x).toFixed (2);

}

< / script>





< form id =form1runat =serveraction =https://www.sandbox.paypal.com/cgi-bin/webscrmethod =post>

< ; input type =hiddenname =cmdvalue =_ cart>

< input type =hiddenname =uploadvalue =1>

< input type =hiddenn ame =businessvalue =abc@gmail.com>

< input type =hiddenname =item_name_1value =聚合项目>

< input type =hiddenname =amount_1id =amt>

< input type =submitvalue =PayPalonclick =MyScript()>



< div runat = 服务器 >

< asp:Label ID =Label1runat =serverText =>< / asp:Label>

< / div>
i have solved my issue on my own

the solution is to add a javascript function and call it

Here is the modified code

<script>
function MyScript()
{
var x, y;
x = document.getElementById('<%=Label1.ClientID%>').innerHTML;
y = document.getElementById("amt").value = parseFloat(x).toFixed(2);
}
</script>


<form id="form1" runat="server" action="https://www.sandbox.paypal.com/cgi-bin/webscr" method="post">
<input type="hidden" name="cmd" value="_cart">
<input type="hidden" name="upload" value="1">
<input type="hidden" name="business" value="abc@gmail.com">
<input type="hidden" name="item_name_1" value="Aggregated items">
<input type="hidden" name="amount_1" id="amt" >
<input type="submit" value="PayPal" onclick="MyScript()" >

<div runat="server">
<asp:Label ID="Label1" runat="server" Text=""></asp:Label>
</div>


这篇关于想要将asp.net Label值分配给html隐藏字段的值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆