Harshida Parmar

Harshida Parmar

  • NA
  • 36
  • 393

Dynamically Generate HTML Div’s and Insert Data into DB

Jan 22 2020 2:53 PM
I have image when i click on it the value is store in x and y variable using jquery also the image part name like x=120 y =230 Name=Tea Cup
  1. var x = event.pageX;  
  2. var y = event.pageY;  
I can click on the image any number of time and fill the X,y, and Name value
  1. $("#textboxX").append('<div><input type="text" value="' + x + '" id="txtX" name="txtX"/></div>');  
  2. $("#textboxY").append('<div><input type="text" value="' + y + '" id="txtY" name="txtY"/></div>');  
  3. $("#textboxBPart").append("<div><input type='text' id='txtName' name='txtName'/></div>");  
  4. var $r = $('<button />',  
  5. {  
  6. type: 'button', text: 'Add Data to Div', id: 'btn_addToDiv'  
  7. });  
  8. var $cancle = $('<button />',  
  9. {  
  10. type: 'button', text: 'Cancle', id: 'btn_cancle' });  
  11. var $DBInsert = $('<button />',  
  12. {  
  13. type: 'button', text: 'Add Data to Database', id: 'btn_addToDB' });  
  14. $("#divSaveDynamicDis").append($r);  
  15. $("#divSaveDynamicDis").append($cancle);  
Now this value get appended to div
  1. var NewData = '<div class="col-sm-12">' + x + ' ' + y + ' ' + txtName.value + '   <a href="javascript:void(0);" class="remCF" data-marker="m_' + x + '_' + y + '">Remove</a> </div>';  
  2. $("#<%= divdynamicData.ClientID %>").append(NewData);  
i want to insert this 5 10 15 50 DIV records to database using the button name btn_addToDB. What i suppose to do now need suggestion need help

Answers (2)