javascript for date using if condition

Please support our JavaScript / DHTML / AJAX advertiser: PostgreSQL or MySQL? Compare and contrast the two most popular open source databases
Reply

Join Date: Nov 2008
Posts: 3
Reputation: gurudattbhat is an unknown quantity at this point 
Solved Threads: 0
gurudattbhat gurudattbhat is offline Offline
Newbie Poster

javascript for date using if condition

 
0
  #1
Nov 13th, 2008
i have one statement .that statement has two combo field(Entered/Approved) .
when combo field is marked as Approved then date isto be moved to date field.and date should not moved to date field when entered is selected from combo feild
i mean i want to move todays date if and only if Approved is selected from combo field
Reply With Quote Quick reply to this message  
Join Date: Aug 2008
Posts: 954
Reputation: essential will become famous soon enough essential will become famous soon enough 
Solved Threads: 131
Featured Poster
essential's Avatar
essential essential is offline Offline
Posting Shark

Re: javascript for date using if condition

 
0
  #2
Nov 14th, 2008
Since i don't have any reference in your code. I will just play a simple demo based on what you wanted to happend. Here's the basic to deal with it...

  1. <html>
  2. <head>
  3. <title><!--Sample--></title>
  4. <script type="text/javascript">
  5. <!--
  6. document.onclick = function(e) {
  7. e = e ? e : window.event;
  8. t = e.target ? e.target : e.srcElement;
  9. var approved = frm1.rdo[1];
  10. var now = new Date();
  11. var month = (now.getMonth()+1);
  12. var date = now.getDate();
  13. var year = now.getFullYear();
  14. month = ( month < 10 ? '0' : '' ) + month;
  15. date = ( date < 10 ? '0' : '' ) + date;
  16. var today = month + '-' + date + '-' + year;
  17.  
  18. if ( t.name && t.name == 'rdo' && approved.checked ) { frm1.txt.value = today; }
  19. else { alert('Do your things from here!') }
  20. }
  21. //-->
  22. </script>
  23. </head>
  24. <body>
  25. <form name="frm1" action="javascript:void(0);" onSubmit="return false;">
  26. <label><input type="radio" name="rdo" value="Entered" />&nbsp;Entered</label> <label><input type="radio" name="rdo" value="Approved" />&nbsp;Approved</label><br /><br />
  27. <label> Date Field: </label> <input type="text" name="txt" value="" style="text-align:center;color:red;font-weight:700;width:100px;" />
  28. </form>
  29. </body>
  30. </html>
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:



Similar Threads
Other Threads in the JavaScript / DHTML / AJAX Forum
Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC