I had tried to enter the auto-add input regular, successful but I am confused because the system displays the new line comes from javascript. Can I mix with php and mysql?
sorry for my bad english, and i'm a new user stackoverflow :(
i was try this and work
<?php include 'load/masuk.php'; include 'load/anti_injection.php'; ?>
<html>
<head>
<title></title>
</head>
<body>
<form method="POST">
<div id="dynamicInput">
Entry 1
<br>
<input type="text" name="myInputs[]">
</div>
<input type="button" value="Add another text input" onClick="addInput('dynamicInput');">
</form>
</body>
<script type="text/javascript">
var counter = 1;
var limit = 3;
function addInput(divName) {
if (counter == limit) {
alert("You have reached the limit of adding " + counter + " inputs");
} else { <? php
$saring = mysql_query("SELECT * FROM perangkat");
?>
var newdiv = document.createElement('div');
newdiv.innerHTML = "Entry " + (counter + 1) + " <br><input type='text' name='myInputs[]'>";
counter++;
}
}
</script>
</html>
but when i try add new line for mix them with php and mysql like this
<?php
include 'load/masuk.php';
include 'load/anti_injection.php';
?>
<html>
<head>
<title></title>
</head>
<body>
<form method="POST">
<div id="dynamicInput">
Entry 1<br><input type="text" name="myInputs[]">
</div>
<input type="button" value="Add another text input" onClick="addInput('dynamicInput');">
</form>
</body>
<script type="text/javascript">
var counter = 1;
var limit = 3;
function addInput(divName){
if (counter == limit) {
alert("You have reached the limit of adding " + counter + " inputs");
}
else {
<?php
$saring=mysql_query("SELECT * FROM perangkat");
?>
var newdiv = document.createElement('div');
newdiv.innerHTML = "Entry " + (counter + 1) + " <br><input type='text' name='myInputs[]'>";
newdiv.innerHTML = <?php echo"<select>"; while ($data=mysql_fetch_array($saring)) {echo "<option value='$data[id_perangkat]'>$data[id_nama]</option>"; echo"</select>";}?>
document.getElementById(divName).appendChild(newdiv);
counter++;
}
}
</script>
</html>
that doesn't work :(
I am less familiar with javascript, but I understand php and mysql