| | |
Date function in Drop-Down Box
Please support our JavaScript / DHTML / AJAX advertiser: PostgreSQL or MySQL? Compare and contrast the two most popular open source databases
![]() |
html Syntax (Toggle Plain Text)
<select name="test1" style="width: 200px"> <option></option> </select>
This is typical drop-down box in html forms. My question is, hot to make the option to capture current date. Or Must I use any other function than drop-down box.
Please advise.
"I might not be the BEST but I'm not like the REST!"
Hi there,
try this code("Function") this may help you
JavaScript:
HTML
But if you like to to capture current date, then you can use Text Box, i think there is not any need of multiple selections for current date...
Function for Text Box
JavaScript:
HTML
I Hope this will help you
Best Regards,
Rahul Dev Katarey
try this code("Function") this may help you
JavaScript:
JavaScript / DHTML / AJAX Syntax (Toggle Plain Text)
<script type="text/javascript"> //<![CDATA[ <!-- function addDate(){ var d=new Date(); var monthname=new Array("January","February","March","April","May","June","July","August","September","October","November","December"); var TODAY = monthname[d.getMonth()] + " " + d.getDate() + ", " + d.getFullYear(); var selectBox = document.getElementById("test1"); var optn = document.createElement("OPTION"); optn.text = TODAY; optn.value = TODAY; selectBox.options.add(optn); } //--> //]]> </script>
HTML
JavaScript / DHTML / AJAX Syntax (Toggle Plain Text)
<a href="javascript:void(0);" onclick="addDate()">create Option</a> <select name="test1" style="width: 200px" id="test1"> <option>Select Date</option> </select>
But if you like to to capture current date, then you can use Text Box, i think there is not any need of multiple selections for current date...
Function for Text Box
JavaScript:
JavaScript / DHTML / AJAX Syntax (Toggle Plain Text)
<script type="text/javascript"> //<![CDATA[ <!-- function addDate(){ var d=new Date(); var monthname=new Array("January","February","March","April","May","June","July","August","September","October","November","December"); var TODAY = monthname[d.getMonth()] + " " + d.getDate() + ", " + d.getFullYear(); /***** TextBox *****/ var TextBox = document.getElementById("TextBox"); TextBox.value = TODAY; /************/ } //--> //]]> </script>
JavaScript / DHTML / AJAX Syntax (Toggle Plain Text)
<a href="javascript:void(0);" onclick="addDate()">create Option</a> <input name="TextBox" type="text" id="TextBox">
I Hope this will help you
Best Regards,
Rahul Dev Katarey
Thanks for the codes. Actually I'm looking for the codes which can produce output like this
2000-03-24(masked)
The date should be in that particular format and masked. Once the form is open, the current date will be automatically there and masked.
advise pls.
2000-03-24(masked)
The date should be in that particular format and masked. Once the form is open, the current date will be automatically there and masked.
advise pls.
Last edited by lordx78; Mar 3rd, 2008 at 6:34 am.
"I might not be the BEST but I'm not like the REST!"
![]() |
Similar Threads
- XP not booting - lsass.exe not found (Windows NT / 2000 / XP)
- Acer TravelMate 2300 cmos battery (Troubleshooting Dead Machines)
- explorer.exe uses 99% CPU (Viruses, Spyware and other Nasties)
- Populating Multiple Text Fields Based On A Dynamic Drop-Down List Selection (PHP)
- Creating a VB dll (Visual Basic 4 / 5 / 6)
- login box not working (JavaScript / DHTML / AJAX)
- Unsure how to handle advance date calculations (JavaScript / DHTML / AJAX)
- Good Luck w/This one: Excel Question VBA/Macro/other (MS Access and FileMaker Pro)
Other Threads in the JavaScript / DHTML / AJAX Forum
- Previous Thread: createElement wont show table/div
- Next Thread: Pop-up ballon in AJAX
| Thread Tools | Search this Thread |
acid2 ajax ajaxcode ajaxexample ajaxhelp ajaxjspservlets animate automatically beta box browser bug captchaformproblem checkbox close codes createrange() css cursor debugger dependent disablefirebug dom download dropdown editor element engine enter error events explorer ext file firefox form forms frameworks getselection google gwt gxt hiddenvalue highlightedword hint html htmlform ie7 ie8 iframe internet java javascript javascripthelp2020 jawascriptruntimeerror jquery jsf jsfile jsp jump listbox maps masterpage math media menu microsoft mp4 object onmouseoutdivproblem onreadystatechange paypal pdf php player position programming progressbar prototype redirect regex runtime safari scale scriptlets search security select size software sql text textarea unicode w3c window windowofwords windowsxp wysiwyg \n





