Welcome Guest, Not a member yet? Register   Sign In
how to add textbox every time click item in select box
#1

[eluser]C_Line[/eluser]
i have a code like this

Code:
<?php
foreach($query_add as $item) <-- retrive item from database
{
if($item->nama_barang == "Lainnya")
{
echo "<Tr><td>&lt;input type='text' nama='kod_b'&gt;&lt;/td>";
}else{
echo "<Tr><td>&lt;input type='text' nama='kod_b' value='$item-&gt;id_barang'&gt;&lt;/td>";
}
}
?&gt;

when i click select box , is the value == Lainnya
i wan to add new textbox
but when i click, it only display 1 textbox,
i wan every time i click it appear new textbox
ex. i click 3 times than appear 3 textbox

thx for help
#2

[eluser]InsiteFX[/eluser]
The only way you are going to do that is by using javascript.

Otherwise it will call for a page refresh everytime and then you would lose them.
#3

[eluser]C_Line[/eluser]
can you give example ?
i use it like this
Code:
&lt;?php
foreach($query_add as $item)
{
if($item->nama_barang == "Lainnya")
{
?&gt;
<Tr><td>
[removed]
document . write("&lt;input type='text' nama='kod_b'&gt;")
[removed]
</td>
&lt;?php
}else{
echo "<Tr><td>&lt;input type='text' nama='kod_b' value='$item-&gt;id_barang'&gt;&lt;/td>";
}
}
?&gt;
but it same like before, am i wrong ?




Theme © iAndrew 2016 - Forum software by © MyBB