Click here to Skip to main content
15,886,362 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
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
Posted

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.
 
Share this answer
 
Comments
Member 11730000 6-Jun-15 9:25am    
I have copied this code from Paypal Developer Section..It is not fraud and it is running in Sandbox environment which has test Accounts,they are not real, i have tested this myself a several times

Please provide me a solution to my problem..please anyone help please...i have to submit my project in my college immediately
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>
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900