loislane74
08-07-2008, 08:06 AM
im trying to incorporate javascript on the project im currently working im already loosing my mind and still cant figure this out: the problem is i have an array of checkboxes which has its corresponding textboxes what i want to do is when the form is loaded all the textboxes are disabled but once i clicked on one of the checkboxes it should enable the textbox that goes with it
here is my sample code:
<script language="javascript">
function myFunction()
{
document.myform.qty.disabled = false;
}
</script>
<style type="text/css">
<!--
.style4 {font-size: 36px}
.style5 {font-size: large}
-->
</style>
</head>
<form method="post" action="transaction_process_guest.php" name="myform">
Table Number: <input type="text" name="table_num" size=5><br>
<table border="0" cellspacing="3" cellpadding="3">
<th></th>
<th>Product Name</th>
<th>Product Price</th>
<th>Product Image</th>
<th>Quantity</th>
<?php
include "connection_dbase_settings.php";
$quer = mysql_query("select * from tbl_products order by product_id");
while($row = mysql_fetch_array($quer))
{
$prod_image = $row[image];
echo "<tr><td></td></tr>";
echo "<tr><td><center><input type=\"checkbox\" name=\"order[]\" value=\"$row[product_id]\" onclick=\"myFunction();\"></center></td>";
echo "<td><center>$row[product_name]</center></td>";
echo "<td><center>$row[price]</center></td>";
echo "<td><center><img src=\"http://localhost/CashRegisterPugo/$prod_image\" height=\"50\" width=\"60\"></center></td>";
echo "<td><center><input type=\"text\" name=\"qty[".$row['product_id']."]\" size=\"5\" disabled></center></td></tr>";
}
echo "<tr><td><input type=\"Submit\" value=\"SUBMIT\"></td>";
echo "<td><input type=\"reset\" value=\"CLEAR\"></td></tr>";
?>
here is my sample code:
<script language="javascript">
function myFunction()
{
document.myform.qty.disabled = false;
}
</script>
<style type="text/css">
<!--
.style4 {font-size: 36px}
.style5 {font-size: large}
-->
</style>
</head>
<form method="post" action="transaction_process_guest.php" name="myform">
Table Number: <input type="text" name="table_num" size=5><br>
<table border="0" cellspacing="3" cellpadding="3">
<th></th>
<th>Product Name</th>
<th>Product Price</th>
<th>Product Image</th>
<th>Quantity</th>
<?php
include "connection_dbase_settings.php";
$quer = mysql_query("select * from tbl_products order by product_id");
while($row = mysql_fetch_array($quer))
{
$prod_image = $row[image];
echo "<tr><td></td></tr>";
echo "<tr><td><center><input type=\"checkbox\" name=\"order[]\" value=\"$row[product_id]\" onclick=\"myFunction();\"></center></td>";
echo "<td><center>$row[product_name]</center></td>";
echo "<td><center>$row[price]</center></td>";
echo "<td><center><img src=\"http://localhost/CashRegisterPugo/$prod_image\" height=\"50\" width=\"60\"></center></td>";
echo "<td><center><input type=\"text\" name=\"qty[".$row['product_id']."]\" size=\"5\" disabled></center></td></tr>";
}
echo "<tr><td><input type=\"Submit\" value=\"SUBMIT\"></td>";
echo "<td><input type=\"reset\" value=\"CLEAR\"></td></tr>";
?>