2013-11-14 18 views
0

我有下面的代碼行彈出DIV的形式:使用按鈕

<?php foreach($prescription as $process){?> 

     <button id="issue"> <?php echo $process['medname'];?> </button> 



     <?php }?> 

在按一下按鈕,下面的DIV形式應該彈出

<div id="dialog-form" title="Create new user"> 
    <p class="validateTips">All form fields are required.</p> 

    <form action="<?php echo base_url()?>phamarcy/issues" method="post"> 
    <fieldset> 
    <table> 
    <tr> 
    <th>Batch Number</th> 

       <th>Quantity Requested </th> 
       <th>Selling Price (Kshs:)</th> 
       <th>Patients Name</th> 
       <th>Requested By</th> 
    </tr> 
    <tr> 
    <td><select name="item_id" onChange="ChooseContact(this)"id="drug_id"> 
    <option value=""></option> 
    <?php foreach($prescription as $drugs){?>  
    <option value="<?php echo $drugs['medname']."|".$drugs['total_quantity']."|".$drugs['expiry_date']."|".$drugs['selling_mark_up_price']."|".$drugs['amount']."|".$drugs['Patients_Name']."|".$drugs['unit_cost']?>"><?php echo $drugs['batch_number']?></option> 

    <?php }?> 
    </select> 
    </td> 
    <input type="text" name="batch_number" id="batch_number" value="" size="1" /> 
    <input type="text" name="item_id" id="item_id" value="" size="1" /> 
    <input type="text" name="opening_bal" id="opening_bal" value=""> 
    <td><input type="text" name="batch_no" id="batch_no" value="" size="1" disabled="disabled"/></td> 
    <td><input type="text" name="exp_date" id="exp_date" value="" size="1" disabled="disabled"/></td> 
    <td><input type="text" name="opening" id="opening" value="" size="1" disabled="disabled" /></td> 
    <td><input type="text" name="issues" id="issues" value="" size="1" /></td> 
    <td><input type="text" name="closing_bal" id="closing_bal" value="" size="1"/></td> 
    <td><input type="text" name="service" id="service" value="" disabled="disabled"> 
    <input type="hidden" name="service_point" id="service_point" value=""/> 
    </td> 
    </tr> 
    <tr> 
    <td><input type="submit" value="Issue"> 
    </td> 
    </table> 
    </fieldset> 
    </form> 

</div> 

從下面的腳本這是應該從細節打開上面的div:

<script> 
    $(function() { 
    $("#dialog-form").dialog({ 
    autoOpen: false, 
    height: 300, 
    width: 1600, 
    modal: true, 
    buttons: { 
    Cancel: function() { 
    $(this).dialog("close"); 
    } 
    }, 
    close: function() { 
    //allFields.val("").removeClass("ui-state-error"); 
    } 
    }); 
    $(".issue") 
    .button() 
    .click(function() { 
    $("#dialog-form").dialog("open"); 
    }); 
    }); 
    </script> 

當我嘗試按一下按鈕,就沒有響應。有沒有一種方法,我怎麼可以讓一個按鈕彈出時,在它PHP數據點擊?

+0

你不能創建多個具有相同ID的按鈕。嘗試改變這種類=「問題」,並看看是否有幫助 –

回答

0

我不能看到帶有class =「問題」的任何元素 該類添加到你想火click事件的元素。 另外,我認爲你應該刪除.button()

$(".issue").click(function() { 
    $("#dialog-form").dialog("open"); 
});