Use jQuery to insert multiple data into the modal box. jquery Mode

Source: Internet
Author: User

Use jQuery to insert multiple data into the modal box. jquery Mode

Copy codeThe Code is as follows:
// Bootstrap modal box (partial)
<Div class = "modal fade" id = "orderDetail">
<Div class = "modal-dialog">
<Div class = "modal-content">
<Div class = "modal-header">
</Div>

<Div class = "modal-body">
<Table class = "table">
<Tr>
<Td> name </td>
<Td> original price </td>
</Tr>
</Table>
</Div>

<Div class = "modal-footer">
</Div>
</Div>
</Div>

Copy codeThe Code is as follows:
/**
* View data details
* @ Blackeye poet <www. chenwei. ws>
*/
Function orderDetail (order_no)
{
// 1. Clear the modal box data first
$ ('# OrderDetail'). find ('tr '). first (). nextAll (). remove ();

// 2. Insert externally
Var order_no = order_no;

$. Post (base_url + '? D = admin & c = orders & m = ajax_order_detail ', {order_no: order_no}, function (data ){

// Data format: [{no: 123, old: abc}, {no: 234, old: def}, {no: 345, old: ghi}]
Var obj = eval ('+ data + ')');

$. Each (obj, function (I, n ){

Var tr = $ ('# orderDetail'). find ('tr '). last ();

Tr. after ("<tr> <td>" + n ['organize _ name'] + ": "+ n ['cate _ name'] +" -- "+ n ['course _ name'] +" </td> <td> "+ n ['old _ price '] + "</td> <td>" + n ['sale _ price'] + "</td> </tr> ");
});
});
}


I want to have a DIV layer that contains pre-configured text. After clicking it, it is automatically inserted into the text box. How can I use JQUERY to do this? I want all the code

<Script type = "text/javascript">
$ (Document). ready (function (){
$ ("# Div id"). click (function (){
Var val = require (this).html (); // obtain the text in the div
$ ("# Textarea"). val (); // put the text in the div into textarea
});
});
</Script>
// Textarea for displaying div text
<Textarea id = "textarea"> </textarea>

See if you want

Can jquery code be inserted in html to achieve the same work as jsp?

AJAX is only a function of JAVASCRIPT. JQUERY is a JAVASCRIPT encapsulation class with simplified AJAX operations.

AJAX uses the javascript dom tree to operate HTML documents by asynchronously interacting with the background and returning values in the background...

The interaction with the background is equivalent to the content displayed on the JSP page accessed by the URL of your browser, but JAVASCRIPT runs through asynchronous access.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.