JS gets the value of table, JS gets the value of input in TD

Source: Internet
Author: User
Tags python list

1. If you want the table to have an editable function, you can embed the input tag in the table

The function of {{list_one[1] or '}} is that when the value of list_one[1] is none, the front-end Web interface does not display none, but is displayed as empty
<Tableclass= "Table table-bordered"ID= "Parameters">       <TR>            <thstyle= "width:5px">Variable name</th>            <th>Variable Value</th>       </TR>{% for list_one in info_list[8]%}<TR>             <TD>{{list_one[0]}}</TD>             <TD><inputclass= "Form-control"placeholder= "Required"value= "{{list_one[1] or '}}"></TD>       </TR>{% endfor%}</Table>

2, JS How to get these values, and to pass them to flask backstage?

The following methods can be used to obtain the values of columns for each row of the table.

json.stringify (Parameters) the parameter JSON session

$ ("#save_script"). Click (function () {        varParameters =NewArray (); Rows= document.getElementById ("Dubbo_parameters"). Rows;  for(varrow=1;row<rows.length;row++) {Parameters[row-1] =NewArray ();  for(varcol=0;col<rows[row].cells.length;col++){                if(col%2 = = 0) {Parameters[row-1][col] =rows[row].cells[col].innerhtml; }Else{Parameters[row-1][col] =rows[row].cells[col].childnodes[0 ].value;                gets the value of input in TD  }            }        }        $("#dubbo_para"). Val (json.stringify (parameters)); });

3, backstage how to get the value of the front end pass over

Using Flask's Json.load method, you can turn the string from the front end into a python list

Json.loads (Request.form.get ("Dubbo_para"))

4. jquery method

<table>   <tr>        <td><input type= "text" value= "Out of Office" ></td>   </tr></ Table>jquery:$ ("Table tr"). Children ("Td:eq (0)"). Find ("Input"). Val ();    

Reference:

1, 1190000007605055

2, 6932064




JS Gets the value of table, JS gets the value of input in TD

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.