[Web]JS表單篇
<a href="javascript:form1.submit();"> <img src="img.jpg"</a>
<a href="javascript:form1.reset();"> <img src="img.jpg"</a>
document.form1.disabled = true / false;
form1.elements.lengthform1.elements[i].name
var num = "0123456789"var str = form.id.value;for(i=0;i<str.length;i++){ if(num.indexOf(str.charAt(i))== -1)}
<form> <label for="Namebox" accessKey="N"><u>N</u>ame:</label> <input type="text" id="Namebox"></form>
<input type="text" id="txID">form.txID.focus();
form.ID.focus();form.ID.select();
<input type="text" value="HERE" onMouseOver = "this.style.color = 'red' ">
<input type="text" value="HERE" onMouseOver = "this.style.background= 'red' ">
<input type="text" value="HERE" onMouseOver = "this.style.borderColor= 'red' ">
onKeyPress = "autoWidth()"str = form.ID.value;if(str.length !=0){ form.ID.size = str.length;}
form.Id.style.textAlign = left/center/right;
<form id="fm1_Id" action="http://www.google.com/search"> <input name="q" id="searchWord" > <br> <input type="submit" value="搜尋"></form>
<form id="form1"><input name="sex" type="radio" checked>男<input name="sex" type="radio" >女</form>
form1.sex[0].checked form1.sex[1].checked
form1.id[i].checked
<input type="checkbox" id="ch1"><label for="ch1" > 標籤 </label>
<form id="form1"><select id="sel1" onChange="get()"><option value="第一項">第一項</option><option value="第二項">第二項</option><option value="第三項">第三項</option></form>
form1.sel1.value
form1.sel1.selectedIndex
<select id="sel1" multiple>form.id[i].selected // 看看有沒有被選到form.id[i].value
open()取代window.loction()open(http://www.google.com);
<form id="form2" enctype="multipart/form-data" ><input type="file" id="file"> <input type="button" onClick="get()" value="FileName"></form>
form2.id.value
取得檔案路徑後,用split()將路徑以“\”切割,再存入陣列中,最後取出陣列的最後一項在JavaScript中插入一個反斜線必須用雙斜線表示。var fName = form2.id.value;var fileName = new Array();fileName = fName.split("\\");fileName[fileName.length-1]
取得檔案路徑後,用split()將路徑以“.”切割,再存入陣列中,最後取出陣列的最後一項
fileName = fName.split(".");
先判斷是不是圖檔
extname.toUpperCase() =="JPG"pic.src = fileName; //完整路徑
先建立圖片物件,並為圖片物件指定來源,再使用物件屬性取得size
img = new Image();
img.src = fileName;
size = img.fileSize / 1024 ; //將圖片大小轉成KB
img.widthimg.height
document.body.backgronund = imgURL;
沒有留言:
張貼留言