Jump to content

<a href> and Javascript with PHP


never_rain

Recommended Posts

This is something very simple but no able to handle it. I am trying to do two things by one click. I would like to call a function in Javascript that'll simply display the div. Till this part, there is no problem. But at the same time, I wish to pass a variable id so that the div can use that variable to fetch values from the table. Here is what I am doing.

 

<a href="javascript:addEducation();">

 

 

This one works fine. But when I try to send a variable, it wont do any thing. Not even this function will work.

 

<a href="javascript:addEducation()?id=3;">

 

 

I know its very simple but Just not been able to handle it. Quick reply will really help.

 

Thanks.

Link to comment
https://forums.phpfreaks.com/topic/202387-and-javascript-with-php/
Share on other sites

Firstly, there really is no need to mix JavaScript in with your markup these days. There are plenty of frameworks around that make unobtrusive code simple to achieve. You should look into using one of them.

 

Secondly, you would need to pass the I'd numbers into your addEducation function, it's not a URL.

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.