Jump to content
  • 0

Create "add an appointment" button in a calendar


Ioannis

Question

5 answers to this question

Recommended Posts

  • 0

Hi Alison

Thanks for your reply

Caspio has uploaded the app into my account. In the calendar form the "add new" button is missing even with the following code in the footer:

<script>
  document.addEventListener('DataPageReady', function (event) {

    // Set links for navigation bar
    $('a[data-cb-name="JumpToFirst"] > img').attr('src', '[@app:URL_2]');
    $('a[data-cb-name="JumpToPrev"] > img').attr('src', '[@app:URL_5]');
    $('a[data-cb-name="JumpToNext"] > img').attr('src', '[@app:URL_4]');
    $('a[data-cb-name="JumpToLast"] > img').attr('src', '[@app:URL_3]');

    // Add link to New Appointment page
    var month = "";
    var allSpanTags = document.getElementsByTagName("li");
    for (i = 0; i < allSpanTags.length; i++) {
      if (allSpanTags[i].className == "cbResultSetCalendarCaption") {
       month = allSpanTags[i].innerText;
      }
    }
    month = month.replace(/January /gi, "1/Day/");
    month = month.replace(/February /gi, "2/Day/");
    month = month.replace(/March /gi, "3/Day/");
    month = month.replace(/April /gi, "4/Day/");
    month = month.replace(/May /gi, "5/Day/");
    month = month.replace(/June /gi, "6/Day/");
    month = month.replace(/July /gi, "7/Day/");
    month = month.replace(/August /gi, "8/Day/");
    month = month.replace(/September /gi, "9/Day/");
    month = month.replace(/October /gi, "10/Day/");
    month = month.replace(/November /gi, "11/Day/");
    month = month.replace(/December /gi, "12/Day/");
    var allHTMLTags = new Array();
    // Create Array of All HTML Tags
    var allHTMLTags = document.getElementsByTagName("div");
    // Loop through all tags using a for loop
    for (i = 0; i < allHTMLTags.length; i++) {
      // Get all tags with the specified class name.
      if (allHTMLTags[i].className == "cbResultSetCalendarField") {
        var transfer = month.replace(/Day/gi, allHTMLTags[i].innerHTML);
        // Check if date is not past date
        var sysDate = '[@cbTimestamp*]';
        var dateToday = new Date(sysDate); 
        var dateCalendar = new Date(transfer);
        if (dateCalendar >= dateToday) {
          // Begin Add New Link Section
          allHTMLTags[i].innerHTML =  '<a class="truncated float-left" title="New Appointment" style="text-decoration:none;" href="./new-appointment.html?Date=' + transfer + '"><i class="fa fa-calendar-plus fa-lg"></i></a>' + allHTMLTags[i].innerHTML;
          // End of Add New Link Section
        }     
      }
    }    
  });
</script>

I have also tried the directions of the article and I pasted the following code into the footer of calendar form:

<script>
document.addEventListener('DataPageReady', function(event) {
var month = "";
var allSpanTags = document.getElementsByTagName("span");
for (i=0; i<allSpanTags.length; i++) {
if (allSpanTags[i].className == "cbResultSetCalendarCaption"){
month = allSpanTags[i].innerHTML;
}
}
month = month.replace(/January /gi,"1/Day/");
month = month.replace(/February /gi,"2/Day/");
month = month.replace(/March /gi,"3/Day/");
month = month.replace(/April /gi,"4/Day/");
month = month.replace(/May /gi,"5/Day/");
month = month.replace(/June /gi,"6/Day/");
month = month.replace(/July /gi,"7/Day/");
month = month.replace(/August /gi,"8/Day/");
month = month.replace(/September /gi,"9/Day/");
month = month.replace(/October /gi,"10/Day/");
month = month.replace(/November /gi,"11/Day/");
month = month.replace(/December /gi,"12/Day/");
var allHTMLTags = new Array();

//Create Array of All HTML Tags
var allHTMLTags = document.getElementsByTagName("div");

//Loop through all tags using a for loop
for (i=0; i<allHTMLTags.length; i++) {

//Get all tags with the specified class name.
if (allHTMLTags[i].className == "cbResultSetCalendarField") {
var transfer = month.replace(/Day/gi,allHTMLTags[i].innerHTML);

/*Begin Add New Link Section*/
allHTMLTags[i].innerHTML = allHTMLTags[i].innerHTML +'<br><a style="text-decoration:none;" href="https://www.breastmedicare.eu/test.html?Date='+transfer+'">Add New</a>';

/*End of Add New Link Section*/
}
}
});
</script>

where https://www.breastmedicare.eu/test.html is the URL of the submission form. The "add new" button is there but it doesn't transfer the date to the submission form!

Is there something I have done wrong?

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  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.

Loading...
×
×
  • Create New...