﻿<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/"><channel><title>BlogJava-Think in MyLife-文章分类-javascript</title><link>http://www.blogjava.net/zhangzhong1018/category/16388.html</link><description>study ruby on rails</description><language>zh-cn</language><lastBuildDate>Tue, 17 Jul 2007 04:45:17 GMT</lastBuildDate><pubDate>Tue, 17 Jul 2007 04:45:17 GMT</pubDate><ttl>60</ttl><item><title>javascript post mothed</title><link>http://www.blogjava.net/zhangzhong1018/articles/130729.html</link><dc:creator>天边一片伴月星</dc:creator><author>天边一片伴月星</author><pubDate>Tue, 17 Jul 2007 01:47:00 GMT</pubDate><guid>http://www.blogjava.net/zhangzhong1018/articles/130729.html</guid><wfw:comment>http://www.blogjava.net/zhangzhong1018/comments/130729.html</wfw:comment><comments>http://www.blogjava.net/zhangzhong1018/articles/130729.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/zhangzhong1018/comments/commentRss/130729.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/zhangzhong1018/services/trackbacks/130729.html</trackback:ping><description><![CDATA[Hi&nbsp;I&nbsp;am&nbsp;currently&nbsp;re<span style="COLOR: #000000">-</span><span style="COLOR: #000000">developing&nbsp;a&nbsp;web&nbsp;based&nbsp;front&nbsp;end&nbsp;</span><span style="COLOR: #0000ff">for</span><span style="COLOR: #000000">&nbsp;an&nbsp;estate&nbsp;agent&nbsp;to&nbsp;manage&nbsp;their&nbsp;propertys.&nbsp;I&nbsp;have&nbsp;decided&nbsp;to&nbsp;use&nbsp;a&nbsp;Microsoft.XMLHTTP&nbsp;object&nbsp;to&nbsp;communicate&nbsp;between&nbsp;the&nbsp;client&nbsp;and&nbsp;server.&nbsp;My&nbsp;problem&nbsp;is&nbsp;got&nbsp;to&nbsp;</span><span style="COLOR: #0000ff">do</span><span style="COLOR: #000000">&nbsp;</span><span style="COLOR: #0000ff">with</span><span style="COLOR: #000000">&nbsp;sending&nbsp;a&nbsp;file&nbsp;</span><span style="COLOR: #0000ff">with</span><span style="COLOR: #000000">&nbsp;</span><span style="COLOR: #0000ff">this</span><span style="COLOR: #000000">.&nbsp;The&nbsp;client&nbsp;is&nbsp;composed&nbsp;of&nbsp;the&nbsp;usual&nbsp;GUI&nbsp;components&nbsp;which&nbsp;the&nbsp;data&nbsp;can&nbsp;be&nbsp;easily&nbsp;retrieved&nbsp;from&nbsp;</span><span style="COLOR: #0000ff">for</span><span style="COLOR: #000000">&nbsp;sending&nbsp;to&nbsp;the&nbsp;server&nbsp;but&nbsp;it&nbsp;also&nbsp;contains&nbsp;a&nbsp;file&nbsp;element&nbsp;</span><span style="COLOR: #0000ff">for</span><span style="COLOR: #000000">&nbsp;selecting&nbsp;a&nbsp;picture&nbsp;of&nbsp;the&nbsp;property&nbsp;to&nbsp;be&nbsp;uploaded.&nbsp;How&nbsp;</span><span style="COLOR: #0000ff">do</span><span style="COLOR: #000000">&nbsp;I&nbsp;get&nbsp;the&nbsp;data&nbsp;from&nbsp;</span><span style="COLOR: #0000ff">this</span><span style="COLOR: #000000">&nbsp;so&nbsp;that&nbsp;it&nbsp;can&nbsp;be&nbsp;uploaded&nbsp;to&nbsp;the&nbsp;server&nbsp;using&nbsp;the&nbsp;Microsoft.XMLHTTP&nbsp;object.&nbsp;I&nbsp;have&nbsp;found&nbsp;a&nbsp;bit&nbsp;of&nbsp;code&nbsp;on&nbsp;the&nbsp;net&nbsp;but&nbsp;it&nbsp;is&nbsp;no&nbsp;use&nbsp;to&nbsp;me&nbsp;because&nbsp;it&nbsp;would&nbsp;involve&nbsp;changing&nbsp;the&nbsp;security&nbsp;</span><span style="COLOR: #0000ff">in</span><span style="COLOR: #000000">&nbsp;</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">Internet&nbsp;Options</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">&nbsp;which&nbsp;I&nbsp;have&nbsp;no&nbsp;control&nbsp;over. <br><br></span><span style="COLOR: #000000">&lt;</span><span style="COLOR: #000000">HTML</span><span style="COLOR: #000000">&gt;</span><span style="COLOR: #000000"> <br></span><span style="COLOR: #000000">&lt;</span><span style="COLOR: #000000">HEAD</span><span style="COLOR: #000000">&gt;&lt;</span><span style="COLOR: #000000">TITLE</span><span style="COLOR: #000000">&gt;</span><span style="COLOR: #000000">File&nbsp;Send</span><span style="COLOR: #000000">&lt;/</span><span style="COLOR: #000000">TITLE</span><span style="COLOR: #000000">&gt;&lt;/</span><span style="COLOR: #000000">HEAD</span><span style="COLOR: #000000">&gt;</span><span style="COLOR: #000000"> <br></span><span style="COLOR: #000000">&lt;</span><span style="COLOR: #000000">BODY</span><span style="COLOR: #000000">&gt;</span><span style="COLOR: #000000"> <br>&nbsp;&nbsp;&nbsp;</span><span style="COLOR: #000000">&lt;</span><span style="COLOR: #000000">INPUT&nbsp;id</span><span style="COLOR: #000000">=</span><span style="COLOR: #000000">btn_send&nbsp;name</span><span style="COLOR: #000000">=</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">btn_send</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">&nbsp;type</span><span style="COLOR: #000000">=</span><span style="COLOR: #000000">button&nbsp;value</span><span style="COLOR: #000000">=</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">FILE&nbsp;SEND</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">&gt;</span><span style="COLOR: #000000"> <br>&nbsp;&nbsp;&nbsp;</span><span style="COLOR: #000000">&lt;</span><span style="COLOR: #000000">DIV&nbsp;id</span><span style="COLOR: #000000">=</span><span style="COLOR: #000000">div_message</span><span style="COLOR: #000000">&gt;</span><span style="COLOR: #000000">Ready</span><span style="COLOR: #000000">&lt;/</span><span style="COLOR: #000000">DIV</span><span style="COLOR: #000000">&gt;</span><span style="COLOR: #000000"> <br></span><span style="COLOR: #000000">&lt;/</span><span style="COLOR: #000000">BODY</span><span style="COLOR: #000000">&gt;</span><span style="COLOR: #000000"> <br></span><span style="COLOR: #000000">&lt;/</span><span style="COLOR: #000000">HTML</span><span style="COLOR: #000000">&gt;</span><span style="COLOR: #000000"> <br><br></span><span style="COLOR: #000000">&lt;</span><span style="COLOR: #000000">SCRIPT&nbsp;LANGUAGE</span><span style="COLOR: #000000">=</span><span style="COLOR: #000000">JavaScript</span><span style="COLOR: #000000">&gt;</span><span style="COLOR: #000000"> <br><br></span><span style="COLOR: #008000">//</span><span style="COLOR: #008000">&nbsp;files&nbsp;upload&nbsp;function</span><span style="COLOR: #008000"> <br></span><span style="COLOR: #0000ff">function</span><span style="COLOR: #000000">&nbsp;btn_send.onclick() <br>{ <br>&nbsp;&nbsp;&nbsp;</span><span style="COLOR: #008000">//</span><span style="COLOR: #008000">&nbsp;create&nbsp;ADO-stream&nbsp;Object</span><span style="COLOR: #008000"> <br></span><span style="COLOR: #000000">&nbsp;&nbsp;&nbsp;</span><span style="COLOR: #0000ff">var</span><span style="COLOR: #000000">&nbsp;ado_stream&nbsp;</span><span style="COLOR: #000000">=</span><span style="COLOR: #000000">&nbsp;</span><span style="COLOR: #0000ff">new</span><span style="COLOR: #000000">&nbsp;ActiveXObject(</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">ADODB.Stream</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">); <br><br>&nbsp;&nbsp;&nbsp;</span><span style="COLOR: #008000">//</span><span style="COLOR: #008000">&nbsp;create&nbsp;XML&nbsp;document&nbsp;with&nbsp;default&nbsp;header&nbsp;and&nbsp;primary&nbsp;node</span><span style="COLOR: #008000"> <br></span><span style="COLOR: #000000">&nbsp;&nbsp;&nbsp;</span><span style="COLOR: #0000ff">var</span><span style="COLOR: #000000">&nbsp;xml_dom&nbsp;</span><span style="COLOR: #000000">=</span><span style="COLOR: #000000">&nbsp;</span><span style="COLOR: #0000ff">new</span><span style="COLOR: #000000">&nbsp;ActiveXObject(</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">MSXML2.DOMDocument</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">); <br>&nbsp;&nbsp;&nbsp;xml_dom.loadXML('</span><span style="COLOR: #000000">&lt;?</span><span style="COLOR: #000000">xml&nbsp;version</span><span style="COLOR: #000000">=</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">1.0</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">&nbsp;</span><span style="COLOR: #000000">?&gt;</span><span style="COLOR: #000000">&nbsp;</span><span style="COLOR: #000000">&lt;</span><span style="COLOR: #000000">root</span><span style="COLOR: #000000">/&gt;</span><span style="COLOR: #000000">'); <br>&nbsp;&nbsp;&nbsp;</span><span style="COLOR: #008000">//</span><span style="COLOR: #008000">&nbsp;specify&nbsp;namespaces&nbsp;datatypes</span><span style="COLOR: #008000"> <br></span><span style="COLOR: #000000">&nbsp;&nbsp;&nbsp;xml_dom.documentElement.setAttribute(</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">xmlns:dt</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">,&nbsp;</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">urn:schemas-microsoft-com:datatypes</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">); <br><br>&nbsp;&nbsp;&nbsp;</span><span style="COLOR: #008000">//</span><span style="COLOR: #008000">&nbsp;create&nbsp;a&nbsp;new&nbsp;node&nbsp;and&nbsp;set&nbsp;binary&nbsp;content</span><span style="COLOR: #008000"> <br></span><span style="COLOR: #000000">&nbsp;&nbsp;&nbsp;</span><span style="COLOR: #0000ff">var</span><span style="COLOR: #000000">&nbsp;l_node1&nbsp;</span><span style="COLOR: #000000">=</span><span style="COLOR: #000000">&nbsp;xml_dom.createElement(</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">file1</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">); <br>&nbsp;&nbsp;&nbsp;l_node1.dataType&nbsp;</span><span style="COLOR: #000000">=</span><span style="COLOR: #000000">&nbsp;</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">bin.base64</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">; <br>&nbsp;&nbsp;&nbsp;</span><span style="COLOR: #008000">//</span><span style="COLOR: #008000">&nbsp;open&nbsp;stream&nbsp;object&nbsp;and&nbsp;read&nbsp;source&nbsp;file</span><span style="COLOR: #008000"> <br></span><span style="COLOR: #000000">&nbsp;&nbsp;&nbsp;ado_stream.Type&nbsp;</span><span style="COLOR: #000000">=</span><span style="COLOR: #000000">&nbsp;</span><span style="COLOR: #000000">1</span><span style="COLOR: #000000">;&nbsp;&nbsp;</span><span style="COLOR: #008000">//</span><span style="COLOR: #008000">&nbsp;1=adTypeBinary&nbsp;</span><span style="COLOR: #008000"> <br></span><span style="COLOR: #000000">&nbsp;&nbsp;&nbsp;ado_stream.Open();&nbsp; <br>&nbsp;&nbsp;&nbsp;ado_stream.LoadFromFile(</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">c:\\sold.gif</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">); <br>&nbsp;&nbsp;&nbsp;</span><span style="COLOR: #008000">//</span><span style="COLOR: #008000">&nbsp;store&nbsp;file&nbsp;content&nbsp;into&nbsp;XML&nbsp;node</span><span style="COLOR: #008000"> <br></span><span style="COLOR: #000000">&nbsp;&nbsp;&nbsp;l_node1.nodeTypedValue&nbsp;</span><span style="COLOR: #000000">=</span><span style="COLOR: #000000">&nbsp;ado_stream.Read(</span><span style="COLOR: #000000">-</span><span style="COLOR: #000000">1</span><span style="COLOR: #000000">);&nbsp;</span><span style="COLOR: #008000">//</span><span style="COLOR: #008000">&nbsp;-1=adReadAll</span><span style="COLOR: #008000"> <br></span><span style="COLOR: #000000">&nbsp;&nbsp;&nbsp;ado_stream.Close(); <br>&nbsp;&nbsp;&nbsp;xml_dom.documentElement.appendChild(l_node1); <br><br>&nbsp;&nbsp;&nbsp;</span><span style="COLOR: #008000">//</span><span style="COLOR: #008000">&nbsp;we&nbsp;can&nbsp;create&nbsp;more&nbsp;XML&nbsp;nodes&nbsp;for&nbsp;multiple&nbsp;file&nbsp;upload</span><span style="COLOR: #008000"> <br></span><span style="COLOR: #000000"><br>&nbsp;&nbsp;&nbsp;</span><span style="COLOR: #008000">//</span><span style="COLOR: #008000">&nbsp;send&nbsp;XML&nbsp;documento&nbsp;to&nbsp;Web&nbsp;server</span><span style="COLOR: #008000"> <br></span><span style="COLOR: #000000">&nbsp;&nbsp;&nbsp;</span><span style="COLOR: #0000ff">var</span><span style="COLOR: #000000">&nbsp;xmlhttp&nbsp;</span><span style="COLOR: #000000">=</span><span style="COLOR: #000000">&nbsp;</span><span style="COLOR: #0000ff">new</span><span style="COLOR: #000000">&nbsp;ActiveXObject(</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">Microsoft.XMLHTTP</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">); <br>&nbsp;&nbsp;&nbsp;xmlhttp.open(</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">POST</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">,</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">http://www.google.com</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">,</span><span style="COLOR: #0000ff">false</span><span style="COLOR: #000000">); <br>&nbsp;&nbsp;&nbsp;xmlhttp.send(xml_dom); <br>&nbsp;&nbsp;&nbsp;</span><span style="COLOR: #008000">//</span><span style="COLOR: #008000">&nbsp;show&nbsp;server&nbsp;message&nbsp;in&nbsp;message-area</span><span style="COLOR: #008000"> <br></span><span style="COLOR: #000000">&nbsp;&nbsp;&nbsp;div_message.innerHTML&nbsp;</span><span style="COLOR: #000000">=</span><span style="COLOR: #000000">&nbsp;xmlhttp.ResponseText; <br>} <br></span><span style="COLOR: #000000">&lt;/</span><span style="COLOR: #000000">SCRIPT</span><span style="COLOR: #000000">&gt;</span><span style="COLOR: #000000"> <br></span>
<img src ="http://www.blogjava.net/zhangzhong1018/aggbug/130729.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/zhangzhong1018/" target="_blank">天边一片伴月星</a> 2007-07-17 09:47 <a href="http://www.blogjava.net/zhangzhong1018/articles/130729.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>多文件上传</title><link>http://www.blogjava.net/zhangzhong1018/articles/75825.html</link><dc:creator>天边一片伴月星</dc:creator><author>天边一片伴月星</author><pubDate>Wed, 18 Oct 2006 01:59:00 GMT</pubDate><guid>http://www.blogjava.net/zhangzhong1018/articles/75825.html</guid><wfw:comment>http://www.blogjava.net/zhangzhong1018/comments/75825.html</wfw:comment><comments>http://www.blogjava.net/zhangzhong1018/articles/75825.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/zhangzhong1018/comments/commentRss/75825.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/zhangzhong1018/services/trackbacks/75825.html</trackback:ping><description><![CDATA[
		<p>javascript 代码<br />&lt;script language="JavaScript"&gt;<br />var num = 0;<br />//insert a row <br />function addRow()<br />{<br />var dataBox = document.getElementById("dataBox");<br />var otr = dataBox.insertRow(dataBox.rows.length);<br />var otd = otr.insertCell();<br />otd.height = "25";<br />num = num + 1<br />var sHTML = "&lt;input type='file' name='file"+num+"' SIZE='50'&gt;"<br />otd.innerHTML = sHTML; </p>
		<p>}<br />//delete a row<br />function delrow()<br />{<br />var i = 0,otr;<br />var dataBox = document.getElementById("databox");<br />  i=num;<br /> if(num!=0){<br />  otr = dataBox.deleteRow(i);<br />     num--;<br />  }<br />}<br />&lt;/script&gt; <br /><br />html 代码<br /><br />&lt;table width="80%" id="dataBox" class="tblBillDetail" cellspacing="0" cellpadding="0" height="0" border="0"&gt;<br />&lt;tr&gt;&lt;td&gt;&lt;input type='file' name='file0' SIZE='50'&gt;&lt;/td&gt;&lt;/tr&gt;<br />&lt;/table&gt;</p>
<img src ="http://www.blogjava.net/zhangzhong1018/aggbug/75825.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/zhangzhong1018/" target="_blank">天边一片伴月星</a> 2006-10-18 09:59 <a href="http://www.blogjava.net/zhangzhong1018/articles/75825.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item></channel></rss>