开发者

Implement paypal add to cart button code in dotnetnuke Html module

开发者 https://www.devze.com 2023-02-09 08:15 出处:网络
Hi I Have a dotnetnuke site.In my web site i want to place two paypal add to cart button in an HTML module.it\'开发者_如何学JAVAs working for only one button. i have removed the form tag and form subm

Hi I Have a dotnetnuke site.In my web site i want to place two paypal add to cart button in an HTML module. it'开发者_如何学JAVAs working for only one button. i have removed the form tag and form submitted on Button click. but i need to place two button . does any one know this?

Thanks


It sounds like you already addressed this - but for proper context: here is the relevant text from Mitchel Sellers blog post on the subject:

To include an HTML form within DNN you will first need to note the "Action" property that is set in the tag. Once you know this action you will want to remove the opening and closing form tags. Now, in the HTML source location the submit button ( or similar) . Then add the following inside the tag declara tion.

onClick="this.form.action='YourUrlHere';this.form.submit();" Be sure to put your Action URL inplace of the "YourUrlHere" text. This tells the HTML form that if the submit button is clicked that it should change the form action, which will prevent ASP.NET postback and then it actually submits the form to the new URL.

This provides you a quick and reliable method to submit HTML forms to external sites. This isn't the best solution as other input items on the current page will be submitted to the action page, however, typically that is not too large of an issue.

And here is a more involved approach/example I came up with using jQuery that should address your question specifically:

<p class="item">
  Buy <span class="name">A Product</span> for $<span class="price">9.99</span>
  <input type="image" src="https://www.paypal.com/en_US/i/btn/btn_cart_SM.gif" style="border:solid 0px black;" name="submit" alt="click here to order">
</p>

$('p.item input[type=image]').click(function(){
  var $itemDetail = $this.parent('p.item');
  var name = $itemDetail.find('.name').val();
  var price = $itemDetail.find('.price').val();
  window.open('https://www.paypal.com/cgi-bin/webscr?cmd=_cart&business=youremail%40address.com&item_name=' + name  + '&amount=' + price + '&no_note=1&currency_code=USD&add=1', 'yourcartwindowname');
});

The important characteristics of this approach are to provide you with an html "template" that can be repeated and used generically for each item. It also opens the PayPal cart page in a new window - and if the person adds more than one item to their cart - it keeps the same window. Very simple but relatively quick and easy to implement if you can take a dependency on JavaScript for this functionality.

0

精彩评论

暂无评论...
验证码 换一张
取 消