skip to Main Content

I have a mysql table with the following data

id Type Note
1 Technical technical issue
2 Memory memory issue
3 Part part number

I get the details from ajax, and want to display the type in a dropdown and the corresponding Note in a text area. Can you advice how I can do that? I am able to display it as a loop of type and note but I want the note to display as the user changes the type from the dropdown.

Below is my current code on ajax success:

success: function (data) 
    {
        if( data )
        {
            var obj = JSON.parse(JSON.stringify(data));

             if( obj.length )
            {

                for(var i=0; i < obj.length; i++)
                {

                    tmp7 += " <div class='box' style='border:1px solid ;padding: 5px; margin: 5px'>";

                    tmp7 += "<br/><br/><b>Note Type: <select name='dpnotetype' id='dpnotetype"+ obj[i]['consultid']+"' disabled> <option value= '"+ notetype +"'>" + notetype + "</option>";
                    tmp7 += " <option value='Technical'>Technical</option><option value='Nursing'>Nursing</option><option value='Memory'>Memory</option>";
                    tmp7 += " <option value='Part'>Part</option><option value='Other'>Other</option>";
                    tmp7 += "</select>" ;
                    tmp7 += "<br/> <br/><b>Note:</b><br/> <br/><textarea id='notetext"+ obj[i]['cusid']+"' row='5' style='height:150px; width: 450px' font color='green' disabled>" + notetext + "</textarea><br/><br/>";
                    tmp7 += " <input type='hidden' id='custid' name='custid' value='" + obj[i]['custid'] + "'>";                                           
                    tmp7 += "</div>";
                    }

2

Answers


  1. Chosen as BEST ANSWER

    to resolve this issue, I decided to use a on change event for each item in the dropdown menu to pull the notes corresponding for each. Didnt require to load all the data at once.


  2. You are writting notetype in both option
    ” + notetype + “”;

    Change notetype to note

    ” + note + “”;

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search