2

I am new in smarty and i want to know something like...

i have javasript code in .tpl file

var dispDate = myJsDate.getDate()+'/'+ (myJsDate.getMonth()+1) + '/' + myJsDate.getFullYear();
above code return : 08/12/2012

and have html code in that .tpl file

<a href="eventPost.php">Create A New Event</a>
<a href="commitment.php">Create A New Commitment.</a>
<a href="areaPost.php">Create A New Visiting Area.</a>

my query is i want to pass that javascript variable "dispDate" in url

like Code:

eventPost.php?ed=08/12/2012
commitment.php?ed=08/12/2012
areaPost.php?ed=08/12/2012
3
  • 1
    Is necessary to send the date from javascript? PHP could not calculate the date internally? Commented Dec 8, 2012 at 6:50
  • yah because i have used calendar so it is necessary to send the date from javascript. when someone clicked on date box it shows the date of the box and i want to pass that date to other page Commented Dec 8, 2012 at 6:52
  • Then you can create a form and send the date by post method. You can use jQuery. Commented Dec 8, 2012 at 6:54

2 Answers 2

1

Try using jQuery:

$("#eventPost").click(function() {
  var dispDate = myJsDate.getDate()+'/'+ (myJsDate.getMonth()+1) + '/' + myJsDate.getFullYear();
  $.get("eventPost.php", { date: dispDate} );
});

<a href="#" id="eventPost">Create A New Event</a>

It is not the complete answer but you can serve to start.

Regards.

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

Comments

0

Scond option, without jquery would be: simply not use href attribute, but onclick.

Then you would have for example:

  <a href="areapost.php"
     onclick="location.href='areapost.php?ed=' + dispDate; return false;">
     .... 
  </a>

Comments

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.