Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
- <html xmlns="http://www.w3.org/1999/xhtml">
- <head>
- <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
- <title>Untitled Document</title>
- <script language="javascript">
- var a = 1;
- function secenekEkle(n) {
- var x= n.parentNode.name;
- alert(x);
- var secsayi = parseInt(n.name);
- var yenisec = secsayi+1;
- var scnk = document.createElement("input");
- scnk.setAttribute("type", "text");
- scnk.setAttribute("name", "soru"+x+"secenek"+yenisec);
- scnk.setAttribute("value", "soru"+x+"secenek"+yenisec);
- scnk.setAttribute("id", "soru"+x+"secenek"+yenisec);
- scnk.setAttribute("size", "50");
- var satirAtla = document.createElement("div");
- satirAtla.setAttribute("id", "divsecenek"+yenisec);
- var sorudivId = document.getElementById("divsoru"+x);
- sorudivId.appendChild(satirAtla);
- var secenekdivId = document.getElementById("divsecenek"+yenisec);
- secenekdivId.innerHTML = '*';
- secenekdivId.appendChild(scnk);
- n.name = secsayi+1;
- }
- function soruEkle() {
- var yeniSoru = document.getElementById('divsoru').cloneNode(true);
- yeniSoru.id = 'divsoru'+a;
- yeniSoru.name = a;
- yeniSoru.style.display = 'block';
- var yeniInput = yeniSoru.childNodes;
- for (var i=0;i<yeniInput.length;i++) {
- var theName = yeniInput[i].name
- var theId = yeniInput[i].id
- var theValue = yeniInput[i].value
- if (theName=="secenek")
- yeniInput[i].name = theName+ "s"+a ;
- else
- yeniInput[i].name = theName + a;
- if (theId=="secenek")
- yeniInput[i].id = theId+"s"+a ;
- else if (theId=="secsayisi")
- yeniInput[i].name = "2";
- else if (theId=="soruid")
- yeniInput[i].id = "soruid";
- else
- yeniInput[i].id = theId + a;
- if (theValue=='Soru')
- yeniInput[i].value = theValue+" "+ a;
- }
- var insertHere = document.getElementById('soruyeri');
- insertHere.parentNode.insertBefore(yeniSoru,insertHere);
- a++;
- }
- function soruSil() {
- b=a-1;
- var olddiv = document.getElementById("divsoru"+b);
- olddiv.parentNode.removeChild(olddiv);
- a--;
- }
- window.onload = soruEkle;
- </script>
- </head>
- <body>
- <form name="anketolustur" action="olustur.php" method="post">
- Başlık:<input type="text" name="baslik" size="70">(max. 70 karakter)<br />
- Kategori:<select>
- <option>1.Kategori</option>
- <option>2.Kategori</option>
- <option>3.Kategori</option>
- <option>4.Kategori</option>
- </select><br />
- <input type="button" value="Soru Ekle" onClick="soruEkle()" />
- <input type="button" value="Soru Sil" onClick="soruSil()" />
- <input type="submit" value="Kaydet" />
- <div id="divsoru" style="display:none">
- <input type="text" name="soru" id="soru" size="90" value="Soru"/><br />
- <input type="button" id="secsayisi" name="2" value="Secenek Ekle" onclick="secenekEkle(this)"/><br />
- *<input type="text" id="secenek1" name="secenek1" size="50"/><br />
- *<input type="text" id="secenek1" name="secenek2" size="50"/><br />
- </div>
- <span id='soruyeri'></span>
- </form>
- </body>
- </html>
Add Comment
Please, Sign In to add comment