Hide selected id with jQuery

Hide selected id with jQuery

Hello everyone, I am stuck at part where I click a button, next which id=getOffer it hides, the button id=gotOffer shows up. In this code I have 50 buttons as you can see.

If I delete these "+i" 's code works just for first button.

Can anyone help me please? Thanks
  1. <script type="text/javascript">

  2. if (window.XMLHttpRequest)
  3.   {// code for IE7+, Firefox, Chrome, Opera, Safari
  4.   xmlhttp=new XMLHttpRequest();
  5.   }
  6. else
  7.   {// code for IE6, IE5
  8.   xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
  9.   }
  10. xmlhttp.open("GET","xml/20121106.xml",false);
  11. xmlhttp.send();
  12. xmlDoc=xmlhttp.responseXML; 

  13. var x=xmlDoc.getElementsByTagName("promotion");

  14. for (i=1;i<(x.length=50);i++)
  15.   { 
  16.  

  17.   $("#getOffer"+"i").click(function () {
  18.  $("#getOffer"+"i").hide();
  19.  $("#gotOffer"+"i").show();
  20.   });
  21.   $("#gotOffer"+"i").click(function () {
  22.  $("#gotOffer"+"i").hide();
  23.  $("#getOffer"+"i").show();
  24.   });
  25.   
  26.   document.write("<div class='oneDeal'>");
  27.   document.write("<div class='imgDeal'>");
  28.   document.write(x[i].getElementsByTagName("PROGRAMURL")[0].childNodes[0].nodeValue);
  29.   document.write("</div><div class='nameDeal'>");
  30.   document.write(x[i].getElementsByTagName("DESCRIPTION")[0].childNodes[0].nodeValue);
  31.   document.write("</div><div class='linkDeal'>");
  32.   document.write("<input type='button' class='offer' id='getOffer"+i+"' value='Click for Code' onclick='click()'><input type='button' class='offer' id='gotOffer"+i+"' style='display:none' onclick='click()'>");
  33.   document.write("</div>");  
  34. document.write("</div>");


  35.   }  
  36. </script>