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">
                          <img src="image/logo3.png"/> <br/>
                          <!--- Text for Help. COOKIES </--->
                          <p align="left">
                         <!-- Product from database starts-->
                                        //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";    
                                         echo "<div id='tablerow'>";
                                                echo "<div>";
                                                echo "<div id='".$res['ID']."'>".$res['product_name']."</div>";
                                                echo "</div>";
                                        echo "</div>";

                         <!--Product from database ends -->
                              <div>Product  Data two </div>
                          <div> Product Data three</div>

                      <div id="fade" class="black_overlay"></div>
                      <!--DIV for Product lightbox ends-->
                      <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"/>

    <script language='javascript'>
         var xrow = document.getElementById("tablerow").rows.length;
        for (var i = 1; i < xrow+1; i++)
            document.getElementById(i).addEventListener('click', loadText);

        function loadText() {
            document.getElementById('inputboxID').value = this.innerHTML || this.innerText;


After displaying product in inputbox ,productid is needed to sent in an another page .

Thanks in advance,


There doesn't seem to be a question here. What works, what doesn't?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts learning and sharing knowledge.