2015-12-11 33 views
-1

我想從數據庫中檢索記錄,並將適當的值放入textarea中,同時我選擇一個選項表單dropdownlist onselect event。如何從數據庫中檢索下拉列表中的值onselect in php mysql

在這裏,我附上我的表單屏幕截圖,image1

在這種形式下,當我選擇短信templete名字的意思是具體的詳細描述被放置到這樣的描述文本區域框。 (ONSELECT事件。)

我的表:sms_template 字段:ID,sms_template,說明

如何做到這一點在PHP,MySQL或任何腳本語言。 (Ajax,javascript)

+0

**你嘗試過這麼遠?** –

+0

我沒有這個想法,請幫助我 – Nisanth

+0

ATLEAST粘貼此模式窗體的代碼。 –

回答

1

由於數據輸入不正確。我從我身邊拿出並給出了一個基本的佈局。 我假設你正在查詢下拉菜單。只要你想改變它。但是,不要更改屬性名稱。

. 
//Your code 
. 
<input type='text' name='custPhone'> <br> 

<select class='smsTemplate' name='smsTemplateName'> 
    // Your value coming from database. Write your query here 
    <option data-description="Success Sms template description" value="Success Sms template"></option> 
    <option data-description="Failure Sms template description" value="Failure Sms template"></option> 
</select> <br> 

<textarea class='showDescription'></textarea> <br> 

. 
//Your code 
. 
. 



<script> 
    $(function(){ 
      $('.smsTemplate').change(function(){ 
       var smsDesc = $(this).find('option:selected').attr('data-description'); 
       $(".showDescription").val(smsDesc); 
      }); 
    }); 
</script> 
相關問題