Jump to content

INSERT the current date generated to the combo box !


alvinchua

Recommended Posts

hi ppl erm.. this javascript is to generate current date ...

 

<script type="text/javascript">
<!--
var currentTime = new Date()
var month = currentTime.getMonth() + 1
var day = currentTime.getDate()
var year = currentTime.getFullYear()
document.write(month + "/" + day + "/" + year)
//-->
</script>

and this is the code for a combobox...

<SELECT name = "select" id ="select">
<OPTION>i need the current date to be display !!
<OPTION>USA
<OPTION>UK
<OPTION>omg
</SELECT> 

 

how can i insert the current date generated to the combo box ???

You should start by using good coding:

- Don't use select as the id name

- Always use closing tags (options)

- Give your options values - otherwise what's the point

 

<script type="text/javascript">

<!--

var currentTime = new Date();

var month = currentTime.getMonth() + 1;

var day = currentTime.getDate();

var year = currentTime.getFullYear();

var today = month + "/" + day + "/" + year;

//-->

</script>

 

<SELECT name = "select" id ="selectField">

<script type="text/javascript">

<!--

document.write('<OPTION value="'+today+'">'+today+'</option>');

//-->

</script>

<OPTION value="USA">USA</option>

<OPTION value="UK">UK</option>

<OPTION value="omg">omg</option>

</SELECT>

 

hmm i need it to be displayed in the combo box .... and the value is passed to a form ... something like below... and later on will be added to the database ..

 

<?php
if(!isset($_POST['button']))
{
?>
<form  method="post" name="tryform" id="tryform">

<SELECT name = "select" id ="select">
<OPTION>India
<OPTION>USA
<OPTION>UK
<OPTION>omg
</SELECT> 

<input name="button" type="submit" id="button" value="SUBMIT">

</body>
<?php
}
?>
</html>

 

i just need the time generated to be passed to a form and later on can be added into the database

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.