Jump to content

Jquery to html


phpgoal

Recommended Posts

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
Share on other sites

I thoroughly enjoyed reading this absolutely magnificently in-depth OP. Please be sure to continue posting in such an insightful manner.

 

 

 

Dude...  :sarcastic:  I'm being sarcastic. You're going to get 0 responses without giving details of the specific problem.

Edited by cpd
Link to comment
Share on other sites

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
Share on other sites

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.