Guest User

Soru Bankası

a guest
Aug 16th, 2012
127
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  2. <html xmlns="http://www.w3.org/1999/xhtml">
  3. <head>
  4. <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  5. <title>Untitled Document</title>
  6. <script language="javascript">
  7.     var a = 1;
  8.     function secenekEkle(n) {
  9.     var x= n.parentNode.name;
  10.     alert(x);
  11.     var secsayi = parseInt(n.name);
  12.     var yenisec = secsayi+1;
  13.     var scnk = document.createElement("input");
  14.     scnk.setAttribute("type", "text");
  15.     scnk.setAttribute("name", "soru"+x+"secenek"+yenisec);
  16.     scnk.setAttribute("value", "soru"+x+"secenek"+yenisec);
  17.     scnk.setAttribute("id", "soru"+x+"secenek"+yenisec);
  18.     scnk.setAttribute("size", "50");
  19.    
  20.     var satirAtla = document.createElement("div");
  21.     satirAtla.setAttribute("id", "divsecenek"+yenisec);
  22.    
  23.     var sorudivId =  document.getElementById("divsoru"+x);
  24.     sorudivId.appendChild(satirAtla);
  25.     var secenekdivId =  document.getElementById("divsecenek"+yenisec);
  26.     secenekdivId.innerHTML = '*';
  27.     secenekdivId.appendChild(scnk);
  28.     n.name = secsayi+1;
  29.    
  30.     }
  31.    
  32.     function soruEkle() {
  33.     var yeniSoru = document.getElementById('divsoru').cloneNode(true);
  34.     yeniSoru.id = 'divsoru'+a;
  35.     yeniSoru.name = a;
  36.     yeniSoru.style.display = 'block';
  37.     var yeniInput = yeniSoru.childNodes;
  38.     for (var i=0;i<yeniInput.length;i++) {
  39.         var theName = yeniInput[i].name
  40.         var theId = yeniInput[i].id
  41.         var theValue = yeniInput[i].value
  42.         if (theName=="secenek")
  43.              yeniInput[i].name = theName+ "s"+a ;
  44.         else
  45.             yeniInput[i].name = theName + a;
  46.         if (theId=="secenek")
  47.             yeniInput[i].id = theId+"s"+a ;
  48.         else if (theId=="secsayisi")
  49.             yeniInput[i].name = "2";
  50.         else if (theId=="soruid")
  51.             yeniInput[i].id = "soruid";
  52.         else
  53.             yeniInput[i].id = theId + a;
  54.         if (theValue=='Soru')
  55.             yeniInput[i].value = theValue+" "+ a;
  56.            
  57.     }
  58.     var insertHere = document.getElementById('soruyeri');
  59.     insertHere.parentNode.insertBefore(yeniSoru,insertHere);
  60.     a++;
  61.    
  62.     }
  63.    
  64.     function soruSil() {
  65.         b=a-1;
  66.         var olddiv = document.getElementById("divsoru"+b);
  67.             olddiv.parentNode.removeChild(olddiv);
  68.         a--;
  69.     }
  70.    
  71.    
  72.    
  73.     window.onload = soruEkle;
  74.    
  75. </script>
  76. </head>
  77.  
  78. <body>
  79. <form name="anketolustur" action="olustur.php" method="post">
  80. Başlık:<input type="text" name="baslik" size="70">(max. 70 karakter)<br />
  81. Kategori:<select>
  82. <option>1.Kategori</option>
  83. <option>2.Kategori</option>
  84. <option>3.Kategori</option>
  85. <option>4.Kategori</option>
  86. </select><br />
  87. <input type="button" value="Soru Ekle" onClick="soruEkle()" />
  88. <input type="button" value="Soru Sil" onClick="soruSil()" />
  89. <input type="submit" value="Kaydet" />
  90. <div id="divsoru" style="display:none">
  91. <input type="text" name="soru" id="soru" size="90" value="Soru"/><br />
  92. <input type="button" id="secsayisi" name="2" value="Secenek Ekle" onclick="secenekEkle(this)"/><br />
  93. *<input type="text" id="secenek1" name="secenek1" size="50"/><br />
  94. *<input type="text" id="secenek1" name="secenek2" size="50"/><br />
  95. </div>
  96. <span id='soruyeri'></span>
  97. </form>
  98. </body>
  99. </html>
Add Comment
Please, Sign In to add comment