PHP Dinamik Textbox Oluşturma ve Bilgi Alma

  • Konbuyu başlatan Eqe
  • Başlangıç tarihi
E

Eqe

Guest
PHP- Kodu:
// ***************************************

// index.php

// ***************************************

// yazan: saji nair

<script language="javascript" type="text/javascript">

function add(count){

var temp="";

temp=temp+"<table width='740' align='center' border=0>"

temp=temp+"<tr><td></td><td style='border-style:none' align='left'>"

temp=temp+"<input type='text' name=row1"+count+" size='20' maxlength='100'>"//row2

temp=temp+"</td>"

temp=temp+"<td style=border-style:none align='right'>"

temp=temp+"<input type=text name=row2"+count+" size='10' maxlength='10'>"//row12

temp=temp+"</td>"

temp=temp+"<td style=border-style:none align='right'>"

temp=temp+"<input type=text name=row3"+count+" size='10' maxlength='10'>"//row22

temp=temp+"</td><td style=border-style:none align='left'><a href='javascript:add("+(++count)+")'>+</a></td></tr>"

temp=temp+"</table>"

//alert(document.getElementById("divisions"));

document.all("divisions").innerHTML=document.all("divisions").innerHTML+temp;


}


</script>


<?php


print"<html><body>"; ////creating html and body tags

print "<form name='frm1' action='count.php' method='post'>"; ///creating form for posting

$count=1; //a counter to increment the rows

print "<div id='divisions'>"; ///creating division where the rows will be inserted

print "<table border=0 border-style='ridge' width=750 align='center'>"; /// first table

print "<tr><td></td></tr>";

print
"<tr><td></td><td style=border-style:none align='left'>";

print
"<input type='text' name=row1".$count." size='20' maxlength='100'>";//row11 creating first row with the names as row

print "</td>";

print
"<td style=border-style:none align='right'>";

print
"<input type=text name=row2".$count." size='10' maxlength='10'>";//row21

print "</td>";

print
"<td style=border-style:none align='right'>";

print
"<input type=text name=row3".$count." size='10' maxlength='10'>";//row31

print "</td><td style=border-style:none align='left'><a href='javascript:add(".++$count.")'>+</a></td></tr>"; /// hyperlink and counter to add rows using javascript

print "</table>"; ///end of first table

print "</div>"; //// division gets over

print "<table border=0 width=740 align='center'><tr><td colspan=5 align='center'><input type='submit'></td></tr></table>"; // table & submit buttonthird table end

print "</form>"; //end of form

print"</body></html>"; //end of html and body

?>


// ***************************************

// count.php

// ***************************************

<?php

foreach ($_POST as $key=>$value) {

print
"$key = $value<br>";

}

?>





 
Üst