Some alternative php js Code

Source: Internet
Author: User

1. Batch selection and Deletion

Use this. Form

<script type="text/javascript">function CheckAll(form) { for (var i=0;i<form.elements.length;i++) { var e = form.elements[i]; if (e.name != 'chkall') e.checked = form.chkall.checked; } } </script>

Name is defined as check []
<Input type = "checkbox" name = "check []" value = <? PHP echo $ data [0];?>

Use in

$userId = implode(',',$_POST['check']);//alert(print_r($userId));mysql_query("DELETE FROM `user` WHERE `id` IN ($userId)");

2. Use the editor

<script charset="utf-8" src="../kindeditor/kindeditor.js"></script><script>KE.show({id : 'content',afterCreate : function(id) {KE.util.focus(id);}});</script>

3. Write special characters in the image database.

$ Info = addslashes ($ _ post ['info']);
$ Query = "insert into live values (null, '$ time',' $ info', 0 )";

Or use mysql_escape_string, which is not recommended for PHP.

4,

Prevent table content Overflow

     <td>           <div  style="width:100px;             overflow:hidden;             text-overflow:ellipsis;                 white-space:nowrap; height: 20px; ">         <?php echo $data[5];?>        </div>        </td>

5 IFRAME nesting at any position

<SCRIPT type = "text/JavaScript">
If (parent! = This)
Parent. Location. Reload ();
</SCRIPT>

<Div onclick = "alert ('A')" id = "logindiv" style = "position: fixed; left: 300; top: 200; width: 400; Height: 300; overflow: hidden; ">
<Div style = "width: pixel PX; Height: 300px; overflow: hidden;" onclick = "alert ('A')">
<IFRAME Style = "margin-top:-400px; margin-left:-2px; margin-Right:-5px; width: 400px; Height: 700px; "id =" datamain "src =" http: // localhost/joomla2.5/index. PHP/2012-11-15-10-25-42 "scrolling = NO> </iframe>
</Div>

5. Convert JS hexadecimal to hexadecimal

Function oxto (Num) {var result = 0; // output result var flg = false; var k = 1; // base for (VAR I = num. length; I> 0; I --) {Switch (Num [I-1]) {Case "1": Case "2": Case "3": Case "4 ": case "5": Case "6": Case "7": Case "8": Case "9": Result + = num [I-1] * k; break; case "A": Case "A": Result + = 10 * k; break; Case "B": Case "B": Result + = 11 * k; break; case "C": Case "C": Result + = 12 * k; break; Case "D": Case "D": Result + = 13 * k; break; case "E": Case "E": Result + = 14 * k; break; Case "F": Case "F": Result + = 15 * k; break; case "X": Case "X": Alert ("Result:" + result); break; default: flg = true; break;} k = K * 16; if (flg) {break;} return result ;}

6. Verify the form and obtain the focus:

function checksubmit(){var check = true;$("#requiredata input").each(function(){if($(this).val() == ""){$(this).focus();check = false;return false;}});}

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.