1

I need a bit of help here.

I have some code which collects dates and places them in a Calendar.

It works fine but I need 1 more thing, which is to add a link for each date.

Up to now I have hardcode a link and it works but I need to make each link to it's own page.

This is my hardcoded link:

$('<div><a href="view-paginated.php#&ui-page=Event-Date--3-10-2011-0">' + today + '</a></div>')

The array holds just the dates, so it would contain this: "3-10-2011" .. without the quotes.

Here is the code which gets the dates and populates the Calendar:

<script>
Array.prototype.contains = function(element)  {
   for(var i=0;i<this.length;i++) if(this[i] == element) return true;
   return false;
};

//INITIALIZE DATES ARRAY SAME AS YOU DID BEFORE
var dates = [];

function ProcessDates(){    
  //ADD YOUR PAGE LOAD CODE HERE
  //NOT USING THIS
}

</script>


<?php 
    include('connect-db.php');
    $sql = mysql_query("SELECT * FROM tbl_calendar") OR DIE(mysql_error());

    echo "<script type='text/javascript'>";

    //LOOP THROUGH DB RESULTS AND PUSH TO JAVASCRIPT ARRAY
    while($row = mysql_fetch_array($sql)) {
        echo "dates.push('$row[date]');";
    }

        //DATES ARRAY SETUP COMPLETE.  CALL FUNCTION TO PROCESS DATES
    echo "ProcessDates(); </script>";
?>

1 Answer 1

1

Simply concatenate the name into the url as well, '<a href="page?date=' + today + '>' + today + '</a>'.

Sign up to request clarification or add additional context in comments.

1 Comment

Not far, but the variable "today" only contains the day number and not the dates. The dates are in the array called "dates" Know what I mean?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.