Click here to Skip to main content
15,896,557 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi all,
Recently my project manager asked me to build a small plug-in like thing which will boost the hits on our core website. It is something like a calculator of exports and imports and when user will download the app and start using it the final result will bring him to our website which will automatically inc the hits on our website. I suggested him that we will allow people to copy HTML mark up from our website and paste the same HTML mark up on their website and the result button will pick the input values of that HTML page and will bring it to us and we will calculate it. But I am confused how to do it ? I mean there will be three or four text boxes in which user will enter their parameters and then on one button click they will be redirected to my website with their values and I will calculate them accordingly. But how to do so ? and how to allow them to download the HTML markup ??? Is this possible even ??? I am too confused for it !
Please help me !
Posted

1 solution

To resolve this you should use javascript. With javascript it'll be easy for your affiliates to implement and it's easy to create.

The only thing you will have to do is to create a javascript which renders a form with a submit button and adds it to the html documents DOM. This submit button should take all 4 values from this form and send the data to your server (using get or post).

A really easy example:

Implementing:
1) Your affiliate should reference your script from your server:
HTML
<script type="text/javascript" src="http://yourserver.com/yourscript.js"></script>

2) And also add an empty div which you will add your form to:
HTML
<div id="formForYourWebsite"></div>


Your script:

JavaScript
function createMyForm(){
   var s = '';
   // Now you can build any html you like..
   s += '<form action="http://yourserver.com/script.aspx" method="get">';
   // and all your textboxes etc here..
   s += '</form>';
   var container = document.getElementById('formForYourWebsite');
   container.innerHTML = s;
}

// Adds event to window.onload without overwriting currently assigned onload functions.
// Function found at Simon Willison's weblog - http://simon.incutio.com/
function addLoadEvent(func)
{	
  var oldonload = window.onload;
  if (typeof window.onload != 'function'){
    window.onload = func;
  } else {
    window.onload = function(){
      oldonload();
      func();
    }
  }
}

// Do not create your form until document is loaded
addLoadEvent(createMyForm);
 
Share this answer
 
Comments
Taresh Uppal 20-Aug-12 8:07am    
thanx I tried something same and it worked but now I am able to fetch the values from my labels on page 2. Kindly check my this thread and please help
http://www.codeproject.com/Questions/441573/Unable-to-fetch-values-from-label-after-page-load

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