| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 405 人关注过本帖
标题:怎么添加,帮帮我(JAVASCRIPT)
只看楼主 加入收藏
andrew518
Rank: 1
等 级:新手上路
帖 子:144
专家分:0
注 册:2005-10-5
收藏
 问题点数:0 回复次数:0 
怎么添加,帮帮我(JAVASCRIPT)

<SCRIPT LANGUAGE="JavaScript"> function btn_img() { txt=prompt("图片的URL地址:","http://"); if(txt=null) { AddTxt="\r[img]"+txt; insertstr(AddTxt); } } </SCRIPT> 这是ASP JAVASRRIPT中的图像地址代玛,我新近做了一个留言本,想在发表留言中添加发表图片功能,请问我应该怎样添加代码? 以下是发表页面的代码,怎么添加? <%@LANGUAGE="JAVASCRIPT" CODEPAGE="936"%> <!--#include file="../Connections/liuyan2.asp" --> <% // *** Edit Operations: declare variables

// set the form action variable var MM_editAction = Request.ServerVariables("SCRIPT_NAME"); if (Request.QueryString) { MM_editAction += "?" + Server.HTMLEncode(Request.QueryString); }

// boolean to abort record edit var MM_abortEdit = false;

// query string to execute var MM_editQuery = ""; %> <% // *** Insert Record: set variables

if (String(Request("MM_insert")) == "form1") {

var MM_editConnection = MM_liuyan2_STRING; var MM_editTable = "liuyandata"; var MM_editRedirectUrl = "liuyan.asp"; var MM_fieldsStr = "email|value|homepage|value|title|value|content|value"; var MM_columnsStr = "email|',none,''|homepage|',none,''|title|',none,''|content|',none,''";

// create the MM_fields and MM_columns arrays var MM_fields = MM_fieldsStr.split("|"); var MM_columns = MM_columnsStr.split("|"); // set the form values for (var i=0; i+1 < MM_fields.length; i+=2) { MM_fields[i+1] = String(Request.Form(MM_fields[i])); }

// append the query string to the redirect URL if (MM_editRedirectUrl && Request.QueryString && Request.QueryString.Count > 0) { MM_editRedirectUrl += ((MM_editRedirectUrl.indexOf('?') == -1)?"?":"&") + Request.QueryString; } } %> <% // *** Insert Record: construct a sql insert statement and execute it

if (String(Request("MM_insert")) != "undefined") {

// create the sql insert statement var MM_tableValues = "", MM_dbValues = ""; for (var i=0; i+1 < MM_fields.length; i+=2) { var formVal = MM_fields[i+1]; var MM_typesArray = MM_columns[i+1].split(","); var delim = (MM_typesArray[0] != "none") ? MM_typesArray[0] : ""; var altVal = (MM_typesArray[1] != "none") ? MM_typesArray[1] : ""; var emptyVal = (MM_typesArray[2] != "none") ? MM_typesArray[2] : ""; if (formVal == "" || formVal == "undefined") { formVal = emptyVal; } else { if (altVal != "") { formVal = altVal; } else if (delim == "'") { // escape quotes formVal = "'" + formVal.replace(/'/g,"''") + "'"; } else { formVal = delim + formVal + delim; } } MM_tableValues += ((i != 0) ? "," : "") + MM_columns[i]; MM_dbValues += ((i != 0) ? "," : "") + formVal; } MM_editQuery = "insert into " + MM_editTable + " (" + MM_tableValues + ") values (" + MM_dbValues + ")";

if (!MM_abortEdit) { // execute the insert var MM_editCmd = Server.CreateObject('ADODB.Command'); MM_editCmd.ActiveConnection = MM_editConnection; MM_editCmd.CommandText = MM_editQuery; MM_editCmd.Execute(); MM_editCmd.ActiveConnection.Close();

if (MM_editRedirectUrl) { Response.Redirect(MM_editRedirectUrl); } }

} %> <!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>无标题文档</title> <script language="JavaScript" type="text/JavaScript"> <!-- function MM_findObj(n, d) { //v4.01 var p,i,x; if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) { d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);} if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n]; for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document); if(!x && d.getElementById) x=d.getElementById(n); return x; }

function MM_validateForm() { //v4.0 var i,p,q,nm,test,num,min,max,errors='',args=MM_validateForm.arguments; for (i=0; i<(args.length-2); i+=3) { test=args[i+2]; val=MM_findObj(args[i]); if (val) { nm=val.name; if ((val=val.value)!="") { if (test.indexOf('isEmail')!=-1) { p=val.indexOf('@'); if (p<1 || p==(val.length-1)) errors+='- '+nm+' must contain an e-mail address.\n'; } else if (test!='R') { num = parseFloat(val); if (isNaN(val)) errors+='- '+nm+' must contain a number.\n'; if (test.indexOf('inRange') != -1) { p=test.indexOf(':'); min=test.substring(8,p); max=test.substring(p+1); if (num<min || max<num) errors+='- '+nm+' must contain a number between '+min+' and '+max+'.\n'; } } } else if (test.charAt(0) == 'R') errors += '- '+nm+' is required.\n'; } } if (errors) alert('The following error(s) occurred:\n'+errors); document.MM_returnValue = (errors == ''); } //--> </script> </head>

<body> <form action="<%=MM_editAction%>" method="POST" name="form1" id="form1" onsubmit="MM_validateForm('name','','R','email','','RisEmail','content','','R');return document.MM_returnValue"> <table width="760" border="1"> <tr> <td width="102" height="24">您的大名</td> <td width="642"><input name="name" type="text" id="name" /></td> </tr> <tr> <td height="22">E_Mail</td> <td><input name="email" type="text" id="email" /></td> </tr> <tr> <td height="25">个人主页</td> <td><input name="homepage" type="text" id="homepage" /></td> </tr> <tr> <td height="27">留言主题</td> <td><input name="title" type="text" id="title" /></td> </tr> <tr> <td height="101">留言内容</td> <td><textarea name="content" cols="50" rows="10" id="content"></textarea></td> </tr> </table> <table width="760" border="1">

<tr> <td><input type="submit" name="Submit" value="提交" /></td> <td><input type="reset" name="Submit" value="重设" /></td> </tr> </table> <p>&nbsp;</p>

<input type="hidden" name="MM_insert" value="form1"> </form> </body> </html>

[此贴子已经被作者于2005-10-17 22:36:13编辑过]

搜索更多相关主题的帖子: 图片 function blank include 
2005-10-17 22:29
快速回复:怎么添加,帮帮我(JAVASCRIPT)
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.080752 second(s), 7 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved