【发布时间】:2011-01-01 20:40:29
【问题描述】:
我正在尝试让网络表单使用 PayPal 现在购买。 The relevant page is here.
根据用户选择的单选按钮,取决于他们“重定向”到的贝宝按钮。 订阅很简单——它们只是一个简单的重定向。
最后一个选项,要求用户选择一个场地。 为此,我需要使用以下表格:
<form action="https://www.paypal.com/cgi-bin/webscr" method="post">
<input type="hidden" name="cmd" value="_s-xclick">
<input type="hidden" name="hosted_button_id" value="10956105">
<table>
<tr><td><input type="hidden" name="on0" value="Venue">Venue</td></tr><tr><td>
<input type="text" name="os0" maxlength="60"></td></tr>
</table>
<input type="image" src="https://www.paypal.com/en_US/GB/i/btn/btn_buynowCC_LG.gif" border="0" name="submit" alt="PayPal - The safer, easier way to pay online.">
<img alt="" border="0" src="https://www.paypal.com/en_GB/i/scr/pixel.gif" width="1" height="1">
</form>
当然,我想不使用那种形式。
到目前为止我所拥有的是:
if (singleOneOff.Checked)
{
paypalForm.Text = getPaypalForm(venueSelect.SelectedItem.Text);
var strJS = getPayPalPostJS("_xclick");
paypalJs.Text = strJS;
var xxx = "dd";
}
这决定了该特定单选按钮是否被勾选。
getPaypalForm
private String getPaypalForm(string venue)
{
StringBuilder strForm = new StringBuilder();
strForm.Append(@"<form action=""https://www.paypal.com/cgi-bin/webscr"" name=""_xclick"" method=""post"">");
strForm.Append(@"<input type=""hidden"" name=""cmd"" value=""_s-xclick"">");
strForm.Append(@"<input type=""hidden"" name=""hosted_button_id"" value=""10956105"">");
strForm.Append(@"<input type=""hidden"" name=""on0"" value=""Venue"">");
strForm.Append(@"<input type=""text"" name=""os0"" value=""{0}"" maxlength=""60"">");
strForm.Append("</form>");
return String.Format(strForm.ToString(), venue);
}
获取PayPalPostJS
private String getPayPalPostJS(string strFormId)
{
StringBuilder strScript = new StringBuilder();
strScript.Append("<script language='javascript'>");
strScript.Append("var paypalForm = document.forms.namedItem('{0}');");
strScript.Append("paypalForm.submit();");
strScript.Append("</script>");
return String.Format(strScript.ToString(), strFormId);
}
但是,如果我选择单选按钮和场地,然后按下按钮,什么也不会发生......
任何想法我哪里出错了?
我遵循了这个指南:http://www.netomatix.com/development/postrequestform.aspx
【问题讨论】:
-
您可以像我在问题中所写的那样创建动态表单并发布到贝宝网址-stackoverflow.com/questions/22025331/…