HOME BLOG PORTFOLIO PHOTO CONTACT Admin Login
array text box input

Hi This code showing how can you pass in array for the text boxes value.

<?php
$con=mysql_connect("localhost","root","");
$db=mysql_select_db('admin2',$con);
//print_r($_POST);
if(isset($_POST['xyz']))
{
foreach ($_POST['xyz'] as $temp=>$value)
{
echo "<br>db key=".$value.'array key='.$temp;
//echo $_POST[name.'_'.$value];
echo "and value=".$_POST['name'.'_'.$value];
}
}
?>
<script>
function java1()
{
//alert("Hi");//return false;
<?php

?>

<?php
foreach ($_POST[xyz] as $value)
{
?>
alert(document.form1.<?php echo 'name'.'_'.$value;?>.value);
<?php
//echo $value.'=>'.$temp;
//echo $_POST[name.'_'.$value];

}
?>

}
</script>
<form name="form1" method="POST" onsubmit="return java1();">
<?php

$qry="SELECT * FROM blog WHERE 1 LIMIT 2";
$result=mysql_query($qry);
while($row=mysql_fetch_array($result))
{
?>
<input type="text" name="name_<?php echo $row["id"]; ?>" value="<?php echo $row['name'];?>"/>
<input type="hidden" name="xyz[]" value="<?php echo $row["id"]; ?>" />
<?php
}
?>
<input type="submit" name="submit" value="submit" />
</form>
   Share on Facebook

Page views:1177