日付に1桁を2桁表示にする
日付の表示で1月や2月など一桁のものを01月02月表示にする
<!--
//now = new Date();
//document.write("あなたがアクセスした時間は現地時間で<br>");
//document.write( now.getYear(), "年");
//document.write( now.getMonth() +1, "月");
//document.write( now.getDate(), "日");
//document.write( now.getHours(), "時");
//document.write( now.getMinutes(), "分");
function time(){
now = new Date();
var str1 = now.getFullYear() + "-";
if( (now.getMonth()+1) < 10 ){ str1 = str1 + "0"; }
str1 = str1 + (now.getMonth()+1) + "-";
if( now.getDate() < 10 ){ str1 = str1 + "0";}
str1 = str1 + now.getDate();
//var year = now.getYear();
//var month = now.getMonth() +1;
//var date = now.getDate();
document.test.text.value = str1;
}
//-->
</script>
以下はbody以下の部分 ボタンを押したら、テキストボックスに日付が入ります。
<input type="text" size="40" name="text"/>
<input type="button" value="時間をセット" onclick="time()" />
</form>
リンクで関数を呼び出す
javascriptの部分
<script type="text/javascript">
<!--
function bg_color(new_color){
document.bgColor = new_color;
}
-->
</script>
いかがbody以下の部分
<table border="1" align="center">
<tr align="center">
<td width="50" height="50" bgcolor="red"><a href="javascript:bg_color('#ff0000')">赤</a></td>
<td width="50" height="50" bgcolor="blue"><a href="javascript:bg_color('blue')">青</a></td>
<td width="50" height="50" bgcolor="yellow"><a href="javascript:bg_color('yellow')">黄色</a></td>
</tr>
</table>
<a href= ""> の部分に、javascript:「javascriptの後に:(コロン)をつける」
そのあとは、今回の場合は直接設定する値を指定した。
一週間終わりましたね!
いや~!みなさんおつかれさま!
一週間終わりました。IT業界は大体土日は休みです。
みなさんは、電車で寝る派?それとも、有効に使って本読みなど?
昨日、帰りの電車で、扉の近くで、立って寝ている人を発見
起用だよね。ある意味 ! 時々、ガクってなるんだよ!
そのうち、倒れるんじゃないかって、気になってねれなかったです!
