Dear All ,
In my website there is an inputbox . When I click on it ,light box will be opened where list of products and its product is will come from database . Now when I select any product ,this product come(ie visible ) in my inputbox. Here is my code:
<!-- DIV for Product lightbox starts-->
<div id="light" class="white_content">
<div class="white-header">
<!--- link to close </--->
<a class="close" href = "javascript:void(0)" onclick = "document.getElementById('light').style.display='none';document.getElementById('fade').style.display='none'">x</a> </div>
<div class="white-body">
<center>
<img src="image/logo3.png"/> <br/>
<!--- Text for Help. COOKIES </--->
<p align="left">
<!-- Product from database starts-->
<div>
<?php
//connecting to database
$db = mysql_connect("localhost","root","") or die(mysql_error());
//selecting my database
$db_select = mysql_select_db("csoftworld", $db) or die(mysql_error());
$sql="SELECT * FROM product";
$qry=mysql_query($sql);
echo "<div id='tablerow'>";
while($res=mysql_fetch_array($qry))
{
echo "<div>";
echo "<div id='".$res['ID']."'>".$res['product_name']."</div>";
echo "</div>";
}
echo "</div>";
?>
</div>
<!--Product from database ends -->
<div>
<div>Product Data two </div>
</div>
<div> Product Data three</div>
</div>
</div>
<div id="fade" class="black_overlay"></div>
<!--DIV for Product lightbox ends-->
<table>
<tr>
<td><a href = "javascript:void(0)" onclick = "document.getElementById('light').style.display='block';document.getElementById('fade').style.display='block'">
<!-- <input type="text" name="A1[]" class="maxWidthL" id="<?php// echo $id;?>" value="<?php //echo $productname;?>" readonly="readonly"/>-->
<input type="text" name="A1[]" class="maxWidthL" id="inputboxID" value="<?php echo $productname;?>" readonly="readonly"/>
</a></td>
</tr>
</table>
<script language='javascript'>
var xrow = document.getElementById("tablerow").rows.length;
alert(xrow);
for (var i = 1; i < xrow+1; i++)
{
document.getElementById(i).addEventListener('click', loadText);
}
function loadText() {
document.getElementById('inputboxID').value = this.innerHTML || this.innerText;
}
</script>
After displaying product in inputbox ,productid is needed to sent in an another page .
Thanks in advance,
Subrata