Jump to content

input text


donaldunca
 Share

Recommended Posts

I have studied javascript a bit. I have some problem to understand this code

var vID="";[color="#FF0000"]var sp="  ";[/color]// why does sp declare like it?for(var i=0; i<5; i++){		vID="i"+i;// I think that it should be vID= i		  document.write("<tr>");		  document.write("<td width= 10% align=center class=ht>");		document.write((i+1));		  document.write("</td>");		  // I don't understand meaning of class		  document.write("<td width= 20% [color="#FF0000"] class[/color]=ht>");		document.write("<input type=text id='" +vID+"' name='Diem' size=4> [color="#FF0000"]class[/color]=ip>");			 document.write("</td>");	document.write("</tr>");			 document.write("<tr><td colspan=4 align=right style='padding: 8 8 8 8'>")	document.write("<input type=submit value='Goi di'>");	document.write(sp+"<input type=reset value='Lam lai'></td></tr>");	document.write("</table></form>");}}

This's something I have been asking myseft. Could you help me? Have good day to you!!

Link to comment
Share on other sites

So I guess you got this code from someone/somewhere else?First of all, this code is extremely old-fashioned, so I hope you don't try to imitate it. document.write is extremely cumbersome and really only makes sense when the script needs to make changes in response to browser conditions. I don't see it being used that way here. Width and alignment attributes no longer have any place in element tags, and style attributes inside tags should be used very sparingly.Notice too that your questions have nothing to do with javascript per se. They are concerned with the HTML that all the document.write statements is generating.To answer your specific questions:  is code for a non-breaking space. Unlike normal spaces, multiple   will be printed AS multiples. "  " is being used here to increase to the space between two input elements. Very tacky. The document would be better off increasing the margin on one side of one of the elements. This is because you cannot really predict how wide a space will be. But you can specify a margin by an exact pixel width.Class refers to a CSS style declaration. You'll want to read about that on your own, probably, but just to give you a basic sense, here is a simple declaration:p.hot {color: #FF0000}Now, if my HTML uses a tag like this <p class="hot">some text</p> "some text" will be printed in red letters.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...