Solve | web | problems
You can only enter number regular
<input onkeyup= "Value=value.replace (/\d+/g, ')" >
You can only enter Zhong Wenjing
<input onkeyup= "Value=value.replace (/[-}]/g,") ">
Wrap the English string beyond the table width
Word-wrap:break-word; Word-break:break-all;
Submitting a form by carriage return
<body >
<form name= "Form" >
<input name= "txt" size= "value=" Mouse point I submit, press ENTER also submit ">
</form>
Confirm when deleting
<a href= ' Javascript:if ("Are you sure you want to delete it?") location= "boos.asp?&areyou= Delete &page=1" ' > Delete </a>
How to make a form feel no bump
<input type=text style= "border:1 solid #000000" >
Or
<input type=text style= "Border-left:none; Border-right:none; Border-top:none; Border-bottom:1 Solid #000000 "></textarea>
How to remove the picture link Click the dotted line around the picture
<a href= "#" >http://www.webjx.com/images/logoo.gif" border=0></a>
child window refreshes parent window
Window.opener.location.reload ()
Opens a new window, and the width and height of the window is the actual height and width of the picture
http://www.webjx.com/images/logoo.gif" >
The pop-up window is centered
<script>
Mywin=window.open ("About:blank", "" "," width=200,height=160 ");
Mywin.moveto (screen.width/2-100,screen.height/2-80);
</script>
Click a cell in the table to change the cell color
<script language= "JavaScript" >
function Test (t) {
for (var i=0; i<t.rows.length; i++)
for (var j=0; j<t.rows[i].cells.length; J + +)
T.rows[i].cells[j].bgcolor = t.rows[i].cells[j] = = event.srcelement? ' Red ': ';
}
</script>
<table width= "cellspacing=" "1" bgcolor= "BLACK" >
<tr bgcolor= "White" height= "><td> </td><td> </td><td> </td></tr>"
<tr bgcolor= "White" height= "><td> </td><td> </td><td> </td></tr>"
<tr bgcolor= "White" height= "><td> </td><td> </td><td> </td></tr>"
</table>
Radio Box Issue
There are three radio boxes,
<input Type=radio name=1>222
<input Type=radio name=2>222
<input Type=radio name=3>222
How to select one of the following two after selecting the first one.
<script>
function Change (radobj) {
var obj = document.getelementsbyname ("Radio2");
for (i=0;i<obj.length;i++) {
obj[i].disabled =!radobj.checked;
}
}
</script>
<input type=radio name= "Radio1" Onclick=change (This) >222
<input type=radio name= "Radio2" disabled>222
<input type=radio name= "Radio2" disabled>222
Tbody Area scroll bar
<HTML><HEAD><TITLE> Lock table Field example page </title>
<meta http-equiv=content-type content= " text/html; charset=gb2312 ""
<style type=text/css>body {
font:12px fine-ming body; Cursor:default
}
TD {
font:12px fine-ming body; Cursor:default
}
. title {
border-right: #555 1px solid; padding-right:4px; Border-top: #fff 1px solid; padding-left:4px; BACKGROUND: #ccc; padding-bottom:4px; Overflow:hidden; Border-left: #fff 1px solid; Cursor:hand; padding-top:4px; Border-bottom: #555 1px solid; White-space:nowrap
}
. CDATA {
border-right: #ddd 1px solid; padding-right:3px; Border-top: #fff 1px solid; padding-left:3px; BACKGROUND: #fff; padding-bottom:3px; Overflow:hidden; Border-left: #fff 1px solid; padding-top:3px; Border-bottom: #ddd 1px solid; White-space:nowrap
}
</style>
<script language=javascript >
Field title (Field name # field width # data alignment)
var datatitles=new Array (
"Singer/group #90 #left",
"Album name #130 #left",
"The issuing company #110 #left",
"This week's ranking #58 #center",
"Status #58 #center",
"Last week ranked #58 #center",
"Week of the list #58 #center",
"Highest ranking #58 #center",
"Percentage of sales #70 #center")
field data (two-dimensional array)
var datafields=new Array ()
Datafields[0] =new Array ("Elva Siu", "Love's main song-Kiss", "Virgin Virgin", "1", "Flat", "1", "2", "1", "2.9")
DATAFIELDS[1] =new Array ("Sherry", "Fever", "Warner Warner", "2", "Flat", "2", "2", "2", "2.1%")
DATAFIELDS[2] =new Array ("Taujigi", "Black Orange", "full Set Shock", "3", "Flat", "3", "5", "1", "1.8")
DATAFIELDS[3] =new Array ("S.H.E", "Beautiful New World", "Advantech HIM", "4", "Flat", "4", "6", "1", "1.2%")
DATAFIELDS[4] =new Array ("Avril Lavigne", "Fly", "Baird BMG", "5", "New List", "-", "1", "5", "1.1")
DATAFIELDS[5] =new Array ("Ren Xian qi", "One ren qi", "Rolling Stone Rock", "6", "New List", "-", "1", "6", "1.0")
DATAFIELDS[6] =new Array ("Van Yisen", "Van Yisen first album", "Fung Wah Forward", "7", "Flat", "7", "2", "7", "0.9")
DATAFIELDS[7] =new Array ("Tse-feng", "invisible to his full selection", "Sony", "8", "Down", "6", "4", "4", "0.9")
DATAFIELDS[8] =new Array ("Zhou Yi", "Lonely City", "Linfair Decca", "9", "Down", "5", "3", "5", "0.8")
DATAFIELDS[9] =new Array ("Jay Chou", "eight-degree space", "Baird BMG", "10", "Down", "8", "8", "1", "0.8")
Datafields[10]=new Array ("Cool Play Orchestra", "Overdo", "Ke yi emi", "11", "Up", "16", "2", "11", "0.7%")
Datafields[11]=new Array ("Zhang Zhenyue", "Wait for me one day", "Magic Rock Magicstone", "12", "New List", "-", "1", "12", "0.6")
Datafields[12]=new Array ("Tang Ben just", "Red and Blue", "Ai hui Avex", "13", "New List", "-", "1", "13", "0.6")
Datafields[13]=new Array ("Energy", "COME on", "Global Universal", "14", "Down", "10", "9", "5", "0.6")
Datafields[14]=new Array ("Edison Chen", "TRANSITION", "Ai hui Avex", "15", "Down", "9", "3", "5", "0.4%")
Datafields[15]=new Array ("collection", "MTV Hip-Hop Master", "Global Universal", "16", "Down", "12", "3", "12", "0.4")
</SCRIPT>
<script language=javascript>
var boxwidth = 480//table display width (excluding scroll)
var showline = 10//table showing number of columns
var rsheight = 21/Data column height
var lockcols = 1//number of fields to be locked (from left to right)
function writetable () {//write table
var iboxwidth=boxwidth
var newhtml= "<table border=\" 0\ "cellpadding=\" 0\ "cellspacing=\" 0\
<td><div style=\ "Width:100%;overflow-x:scroll\" >\
<table border=\ "0\" cellpadding=\ "0\" cellspacing=\ "0\" "><tr>"
for (i=0;i<datatitles.length;i++) {
if (i<lockcols) {
var ctitle=datatitles[i].split ("#")
IBOXWIDTH-=CTITLE[1]
var dyntip= ((i+1) ==lockcols)? " Unlock ": Lock This field"
newhtml+= "<td><div class=\" title\ "style=\" width: "+ctitle[1]+" Px;height: "+rsheight+" px\ "title=\" "+ dyntip+ "\ onclick=\" resettable ("+i+") \ ">" +ctitle[0]+ "</div></td>"
}
}
newhtml+= "</tr>\
<TR><TD colspan=\ "" +lockcols+ "\" >\
<div id=\ "dataframe1\" style=\ "position:relative;width:100%;overflow:hidden\" >\
<div id=\ "datagroup1\" style=\ "position:relative\" ></div></div>\
</td></tr></table></div></td>\
<TD valign=\ "top\" ><div style=\ "width:" +iboxwidth+ "px;overflow-x:scroll\" >\
<table border=\ "0\" cellpadding=\ "0\" cellspacing=\ "0\" "><tr>"
for (i=0;i<datatitles.length;i++) {
if (i>=lockcols) {
var ctitle=datatitles[i].split ("#")
newhtml+= "<td><div class=\" title\ "style=\" width: "+ctitle[1]+" Px;height: "+rsheight+" px\ "title=\" lock this field \ " Onclick=\ "Resettable" ("+i+") \ ">" +ctitle[0]+ "</div></td>"
}
}
newhtml+= "</tr>\
<TR><TD colspan=\ "" + (Datatitles.length-lockcols) + "\" >\
<div id=\ "dataframe2\" style=\ "position:relative;width:100%;overflow:hidden\" >\
<div id=\ "datagroup2\" style=\ "position:relative\" ></div>\
</div></td></tr></table>\
</DIV></TD><TD valign=\ "Top\" >\
<div id=\ "dataframe3\" style=\ position:relative;background: #000; overflow-y:scroll\ "onscroll=\" SYNC_Roll () \ " >\
<div id=\ "datagroup3\" style=\ "position:relative;width:1px;visibility:hidden\" ></div>\
</div></td></tr></table> "
Datatable.innerhtml=newhtml
Applydata ()
}
Function Applydata () { //write Data
var newhtml= "<table border=\" 0\ "cellpadding=\" 0\ " Cellspacing=\ "0\ >"
for (i=0;i<datafields.length;i++) {
newhtml+= ' <tr> '
for (j=0 ; j<datatitles.length;j++) {
if (j<lockcols) {
var Ctitle=datatitles[j].split ("#")
newhtml+= "<td><div class=\" Cdata\ " Style=\ "width: +ctitle[1]+" px;height: "+rsheight+" px;text-align: "+ctitle[2]+" \ ">" +datafields[i][j]+ "</div ></td> "
}
}
newhtml+=" </tr> "
}
newhtml+=" </ Table> "
datagroup1.innerhtml=newhtml
var newhtml= "<table border=\" 0\ "cellpadding=\" 0\ "cellspacing=\" 0\ ">"
for (i=0;i< datafields.length;i++) {
newhtml+= "<tr>"
for (j=0;j<datatitles.length;j++) {
if (j>=lockcols) {
var ctitle=datatitles[j].split ("#")
newhtml+= "<td><div class=\" cdata\ "style=\" width: "+ctitle[1]+" Px;height: "+ rsheight+ "px;text-align: +ctitle[2]+" \ ">" +datafields[i][j]+ "</div></td>"
}
}
newhtml+= "</tr>"
}
newhtml+= "</table>"
datagroup2.innerhtml=newhtml
Dataframe1.style.pixelheight=rsheight*showline
Dataframe2.style.pixelheight=rsheight*showline
Dataframe3.style.pixelheight=rsheight*showline+rsheight
datagroup3.style.pixelheight=rsheight* ( datafields.length+1)
}
function resettable (n) {
var iboxwidth=0
for (i=0;i<datatitles.length;i++) {
if (i< (n+1)) {
var ctitle=datatitles[i].split ("#")
Iboxwidth+=parseint (Ctitle[1])
}
}
if (iboxwidth>boxwidth) {
var sure=confirm ("\ nthe width of the locked field is greater than the width of the table display, which may cause the layout to display abnormally.") \n\n\n Are you sure you want to continue? ")
}else{
Sure=true
}
if (sure) {
Lockcols= (lockcols==n+1)? 0:n+1
Writetable ()
}
}
function Sync_roll () {
Datagroup1.style.postop=-dataframe3.scrolltop
Datagroup2.style.postop=-dataframe3.scrolltop
}
Window.onload=writetable
</SCRIPT>
<meta content= "MSHTML 6.00.2800.1170" name=generator><BODY>
<CENTER>
<H4> Lock table Field example page </H4><!--//Table (START)//-->
<table cellspacing=0 cellpadding=0 border=0>
<TBODY>
<TR>
<td
style= "Border-right:white 2px inset; Border-top:white 2px inset; Border-left:white 2px inset; Border-bottom:white 2px inset; Background-color:scrollbar ">
<div id=datatable></div></td></tr></tbody></table><!--//Information table (end)//-->
<P> Click to reset or remove the current lock status </P></CENTER></BODY></HTML>