[php]how to confirm deleting without using form.
<html>
<head>
<script type="text/javascript">
<!--
function confirmDelete()
{
return confirm("Are you sure you wish to delete this entry?");
}
//-->
</script>
</head>
<body>
<% $var1 = 2;%>
<a href="?action=delete&id=<?=$var1?>" onclick="return confirmDelete();">
Delete this entry
</a>
</body>
</html>
B
TW:
Line 14 is using PHP's short_open_tag which is not recommended, the formal tag should be <%php %>
Line 15 is using ASP-style <% %> tags.
Of couse you can use the PHP formal tag, the above code is simply to demostrate the other two tags.
To enable short_open_tag and "<?" support in php, you need to modify php.ini, make sure enable below two attributes.
; Default Value: On
; Development Value: Off
; Production Value: Off
; http://php.net/short-open-tag
short_open_tag = On
; Allow ASP-style <% %> tags.
; http://php.net/asp-tags
asp_tags = On
Ïà¹ØÎĵµ£º
mb_convert_encodingÕâ¸öº¯ÊýÊÇÓÃÀ´×ª»»±àÂëµÄ¡£ÔÀ´Ò»Ö±¶Ô³ÌÐò±àÂëÕâÒ»¸ÅÄî²»Àí½â£¬²»¹ýÏÖÔÚºÃÏñÓе㿪ÇÏÁË¡£
²»¹ýÓ¢ÎÄÒ»°ã²»»á´æÔÚ±àÂëÎÊÌ⣬ֻÓÐÖÐÎÄÊý¾Ý²Å»áÓÐÕâ¸öÎÊÌâ¡£±ÈÈçÄãÓÃZend Studio»òEditplusд³ÌÐòʱ£¬ÓõÄÊÇgbk±àÂ룬Èç¹ûÊý¾ÝÐèÒªÈëÊý¾Ý¿â£¬¶øÊý¾Ý¿âµÄ±àÂëΪutf8ʱ£¬Õâʱ¾ÍÒª°ÑÊý¾Ý½øÐбàÂëת»»£¬²»È»½øµ½Ê ......
<?php
$s = "new string";
//ÏÂÃæË«ÒýºÅ×Ö·û´®ÖеķûºÅ"$"δ×öתÒ壬Òò´Ë$s½«±»Ìæ»»³ÉÆä±äÁ¿µÄÖµ
$str_1 = "Ë«ÒýºÅÖ¸¶¨µÄ×Ö·û´®£¬$s";
//ÏÂÃæË«ÒýºÅ×Ö·û´®ÖеķûºÅ"$"×öÁËתÒ壬Òò´Ë$sÔ·â²»¶¯£¬²»»á±»Ì滻Ϊ±äÁ¿$sµÄÖµ
$str_2 = "Ë«ÒýºÅÖ¸¶¨µÄ×Ö·û´®£¬\$s";
//µ¥ÒýºÅ×Ö·û´®ÖеÄ"$"²»ÓÃ×öתÒå¼´¿ÉÔÑùÊä³ö
$str_3 ......
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>ÎÞ±êÌâÎĵµ</ ......
Ê×ÏÈ˵×î¸ù±¾µÄ½â¾ö·½·¨£º
ÊÖ »ú·ÃÎÊʱ£¬»á¸½´ø·¢ËÍuser-agentÐÅÏ¢£¬Õâ¸öÐÅÏ¢ÀïÃæ»áÓÐÊÖ»úºÅÂëÐÅÏ¢£¬ÄÇôÈç¹ûÄÜÈ¡µÃÊÖ»úºÅÂ룬Ôò¿ÉÒԿ϶¨ÊÇͨ¹ýÊÖ»úwap·ÃÎʵġ£µ«ÊÇÄ¿Ç°ÖÐ ¹úÒƶ¯ÒѾÆÁ±ÎÁËuser-agentÐÅÏ¢£¬ËùÒÔ»ñÈ¡²»µ½ÊÖ»úºÅÂë¡£ÓйØϵµÄÅóÓÑ¿ÉÒÔÁªÏµÒƶ¯¹«Ë¾£¬°ÑwapÍøÕ¾·þÎñÆ÷µÄipÌá½»¸øÖйúÒƶ¯£¬¼ÓÈë°×Ãûµ¥ ºó¼´¿ÉÈ¡µ ......