2013年10月22日星期二

struts1.x pages made ??using a logic: iterte label assignment

with javascript struts1.x pages made ​​using a logic: iterte tag loops represent data, each data has a month and day of the text box , and now want to use javascript to achieve , determine box If you enter only a month when the median complement 0 . For example , when a box to enter the month after the submission of javascript expressed as 01, said .


. . . . . .


Month

. . . . . .


javascript how can we put this value into a month of box fill 0 it ? Neighborhoods, and I know that if not with list that directly document.forms [0]. OrderMonth.value assignment 01 can display , but now with a list, to document.forms [0]. SpecialValueFormInfoArr [i]. OrderMonth.value ; assignment die, please master pointing
------ Solution ------------------------------- -------------
can fill in the background can also be used to achieve js .
alert(pad3(3,2));
alert(pad3(13,2));

function pad3(num, n) { 
return (Array(n).join(0) + num).slice(-n); 


can also use regular match.
------ For reference only -------------------------------------- -
did not understand , ah,
If the page on a orderMonth box js where I could judge if the value entered is 1-9 and length <2 occasions , form.orderMonth.value = "0" ; + form.orderMonth.value

now because of the use list, as in the past when I do not know how playback is worth writing .
------ For reference only -------------------------------------- -
themselves
html: text tag has an attribute styleId
put this fight on the value of the format attribute : styleId = "txtid" <% = i%>
document.getxxxxId ("txtid1"). value
I use html tags , document.getxxxxId time <% cnt%> do not know why it seems can not be edited , jsp where shown is not txtid0, but txtid% cnt%, input tag will be replaced no problem. Of course, if you must use html tags , experiment , you can use document.get **** name approach.

没有评论:

发表评论