phpgoal Posted June 11, 2013 Share Posted June 11, 2013 Hello, I have IF statement inside JS block. If the date = 'September 2020' I want to see the specific link(link1, link2), so on. If the date is not equal to given date, I dont want to see the link at all. It is not working. Please help. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> <head> <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.1/jquery.js"></script> <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.7.2/jquery-ui.min.js"></script> <link rel="stylesheet" type="text/css" media="screen" href="http://ajax.googleapis.com/ajax/libs/jqueryui/1.7.2/themes/base/jquery-ui.css"> <script type="text/javascript"> $(function() { $('.date-picker').datepicker( { changeMonth: true, changeYear: true, showButtonPanel: true, dateFormat: 'MM yy', onClose: function(dateText, inst) { var m = $("#ui-datepicker-div .ui-datepicker-month :selected").val(); var y = $("#ui-datepicker-div .ui-datepicker-year :selected").val(); $(this).datepicker('setDate', new Date(y, m, 1)); }, beforeShow : function(input, inst) { if ((datestr = $(this).val()).length > 0) { if (datestr == 'September 2020'){ $('#sep').attr('href')} if (datestr == 'October 2020'){ $('#oct').attr('href')} year = datestr.substring(datestr.length-4, datestr.length); month = jQuery.inArray(datestr.substring(0, datestr.length-5), $(this).datepicker('option', 'monthNames')); $(this).datepicker('option', 'defaultDate', new Date(year, month, 1)); $(this).datepicker('setDate', new Date(year, month, 1)); } } }); }); </script> <style> .ui-datepicker-calendar { display: none; } </style> </head> <body> <label for="startDate">Date :</label><input type="text" class="datepicker minimumSize" name="BirthDate" id="BirthDate" readonly="readonly"/> <input name="startDate" id="startDate" class="date-picker" /><a id="sep" href="http://www.google.com">1</a><a id="oct" href="http://www.yahoo.com">2</a></body> </html> Link to comment https://forums.phpfreaks.com/topic/279043-jquery-to-html/ Share on other sites More sharing options...
cpd Posted June 11, 2013 Share Posted June 11, 2013 I thoroughly enjoyed reading this absolutely magnificently in-depth OP. Please be sure to continue posting in such an insightful manner. Dude... I'm being sarcastic. You're going to get 0 responses without giving details of the specific problem. Link to comment https://forums.phpfreaks.com/topic/279043-jquery-to-html/#findComment-1435410 Share on other sites More sharing options...
phpgoal Posted June 11, 2013 Author Share Posted June 11, 2013 I am so sorry if i was not clear enogh. 1. When I run the code, I can select a month and a year. For example, Jun 2013. That part is working just fine. 2. What I want to do next is I want to add some hyperlinks to some specific dates. For example,I want to add two links to two specific dates. 3. If I select a date in step 1 that matches date in step 2, i want to see a hyperlink in html. That means, I want to see the href link only If I selected a date 'September 202'0 in step 1. I dont want to see the href link if i do not select 'September 2020'. Pls help. Link to comment https://forums.phpfreaks.com/topic/279043-jquery-to-html/#findComment-1435420 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.