Jump to content

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

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.