3

I feel as if this issue is pretty simple, so I may be overlooking something pretty straightforward, but I can't seem to find the solution on Facebook. Basically I have two AJAX functions that interface with PHP scripts through the onClick event. Here is how I am laying out the HTML:

onClick = "previousMonth(this.id); monthDisplay_previous(this.id)"

Currently, it is displaying the output from previousMonth(this.id). But if I reverse the function calls and set it up as:

onClick = "monthDisplay_previous(this.id); previousMonth(this.id)"

then it only displays the output from monthDisplay_previous(this.id) -- it just won't run them both. In addition, they both interface with different PHP scripts. I feel like this is enough information to go off of, but if you want me to post more code I will, reluctantly. Any ideas?

3
  • not enough detail. what do these two functions do? if monthDisplay does a redirect and moves the browser to a different page, it would be impossible for previousMonth to ever do anything. Commented Feb 15, 2013 at 19:18
  • @MarcB they dont redirect, they change text on the page bassed off of a two different php scripts Commented Feb 15, 2013 at 19:19
  • @Nick where you able to figure this out? Commented Apr 22, 2020 at 15:52

2 Answers 2

2

If they can run in parallel, you might try somethign like this

var someFunction = function(that_id) {
  previousMonth(that_id);
  monthDisplay_previous(that_id);
}

onClick = "someFunction(this.id);"
Sign up to request clarification or add additional context in comments.

1 Comment

still nothing.. i suppose if i stare at it long enough something will come to me. thanks for the help though
0

Try wrapping both of your functions into another one.

onClick = function(){ previousMonth(this.id); monthDisplay_previous(this.id); }

1 Comment

Ops, sorry about that. Well, I made a simple code using jquery that might help you. jsfiddle.net/uQVW7

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.