Book Section
-----
TY JavaScript 3rd Ed.
Teach Yourself JS 1.5
Teach Yourself DHTML
Teach Yourself JS 1.3
LLWW: JavaScript

General Section
-----
Discussion Forum
Articles / Tips
JavaScript Links
About the Author
Privacy Policy
Contact Me



Other Sites
-----
Website Workshop
JavaScript Weblog

JavaScript Workshop Forums

 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 
Trying to pass a php id to javascript on the same page

 
Post new topic   Reply to topic    JSWorkshop Forum Index -> JavaScript
View previous topic :: View next topic  
Author Message
dk4210
New member
New member


Joined: 28 May 2003
Posts: 1

PostPosted: Wed Jul 20, 2011 3:51 am    Post subject: Trying to pass a php id to javascript on the same page Reply with quote

Hello Guys,

I need some help here..

I have a page that has a grid on it and I have a hidden div(below the grid). When the link is clicked inside the grid it opens the hidden div using the following code for the link in the grid.

Here is my code with the PHP id that I need to pass

[PHP]foreach($ct->data as $key => $value){
$ct->data[$key][3]='<a href=#" onclick="part2('.$ct->data[$key][0].');" href="javascript:void();">'.$ct->data[$key][3].'</a>';[/PHP]
Trying to pass a php id to javascript on the same page


Here is the code in my head
Code:
<script type="text/javascript">
function part2(id) {
var part2 = document.getElementById('part2');
   if ( part2.className == 'hidden' ) {
      part2.className = 'visible';
      document.getElementById('message').InnerHTML = 'This is the ID: '+id
   } else {
      part2.className = 'hidden';
   }
}
</script>


Added this to my hidden div to show the id
Code:
<span id=message></span>


Any help would be appreciated..

Thanks, Dan
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    JSWorkshop Forum Index -> JavaScript All times are GMT - 7 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2002 phpBB Group
(c) 1997-2002 Starling Technologies and Michael Moncur. Portions (c) Sams Publishing.