LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 08-03-2004, 06:08 PM   #1
Boby
Member
 
Registered: Feb 2004
Posts: 781

Rep: Reputation: Disabled
use <TD> as link


Hi!

If I use this:
PHP Code:
...
print 
'<TD><A href="getit.php?id=1">Click Me</a></TD>';
... 
everything works fine. The file getit.php, gets the id and writes whats on that row in the database. Now I want to use the hole <TD> as a link, I think there should be something with onClick, but what?
PHP Code:
...
print 
'<TD onClick="WHAT_COMES_HERE??">Click Me<TD>';
... 
Thank you!

Boby
 
Old 08-03-2004, 06:18 PM   #2
Charalambos
Member
 
Registered: Aug 2004
Location: Switzerland
Distribution: debian
Posts: 149

Rep: Reputation: 15
something like this?

onClick="window.location.href='getit.php?id=1'"
 
Old 08-03-2004, 07:21 PM   #3
Boby
Member
 
Registered: Feb 2004
Posts: 781

Original Poster
Rep: Reputation: Disabled
It's not working

I forgot to say...I'm using a frame too, the link sends an URL and the file getit.php writes there the text from a DB that coresponds to the URL.
I want this <TD> that's a link to sent it to the getit.php file that's in a frame.

Used like I use it now with a normal link it's like this:
PHP Code:
...
<
TD align="right" valign="top" rowspan="2">
<
iframe name="MAIN" width=470px height=300px marginwidth=0 marginheight=0 hspace=0 vspace=0
frameborder
=1 scrolling=no></iframe>
</
TD>

<
TD>
print 
'<A target="MAIN" href="getit.php?id=1">Click Me</a>';
</
TD
So the onClick should have something that makes the target to the frame [i guess].

Thank you!

Boby

Last edited by Boby; 08-03-2004 at 07:22 PM.
 
Old 08-04-2004, 01:56 AM   #4
Charalambos
Member
 
Registered: Aug 2004
Location: Switzerland
Distribution: debian
Posts: 149

Rep: Reputation: 15
to make it work with frames do it like this:

onClick="JavaScriptarent.<some_frame>.location='firstlink.php';parent.<some_second_frame>.location ='secondlink.php';"

add as many links as you want to change the content of multiple frames with one click.

for you this should work:

onClick="JavaScriptarent.MAIN.location='getit.php?id=1';" (is suppose it should open in MAIN)
 
Old 08-04-2004, 03:20 AM   #5
Cedrik
Senior Member
 
Registered: Jul 2004
Distribution: Slackware
Posts: 2,140

Rep: Reputation: 244Reputation: 244Reputation: 244
I would use the replace() method like :
PHP Code:
<TD>
print 
"<A target=\"MAIN\" href=\"#\" onClick=\"parent.location.replace('getit.php?id=1');\">Click Me</a>";
</
TD
 
Old 08-04-2004, 08:27 AM   #6
Charalambos
Member
 
Registered: Aug 2004
Location: Switzerland
Distribution: debian
Posts: 149

Rep: Reputation: 15
Quote:
Originally posted by Charalambos
onClick="JavaScript:parent.MAIN.location='getit.php?id=1';" (is suppose it should open in MAIN)
this was not supposed to be a emoticon
 
Old 08-07-2004, 03:15 PM   #7
Boby
Member
 
Registered: Feb 2004
Posts: 781

Original Poster
Rep: Reputation: Disabled
I got it


<TD onClick='parent.frames.MAIN.location.href="getit.php?id=2";'>
Click Me
</TD>


But thanks guys for trying to help me!

Boby
 
Old 08-17-2004, 06:28 PM   #8
VibeOfOurTribe
LQ Newbie
 
Registered: Jul 2004
Posts: 21

Rep: Reputation: 16
THANKS! YOU RULE!
I had a similar question where i wanted to change two links simultaneously.


<a href="somesite.html" target="AFrameName" onClick="parent.frames.AnotherFrameName.location.href='someothersite.htm'""> click here </a>

where AFrameName and AnotherFrameName are the two frames i needed to change
 
Old 08-18-2004, 12:20 AM   #9
Charalambos
Member
 
Registered: Aug 2004
Location: Switzerland
Distribution: debian
Posts: 149

Rep: Reputation: 15
Quote:
Originally posted by VibeOfOurTribe
[B]
<a href="somesite.html" target="AFrameName" onClick="parent.frames.AnotherFrameName.location.href='someothersite.htm'""> click here </a>
I'd rather do that like that
Code:
<a href="#" onClick="parent.frames.AFrameName.location.href='somesite.html';\
parent.frames.AnotherFrameName.location.href='someothersite.htm'"> click here </a>
since some browsers ingnore the html part of the link if a javascript is specified (i.e. the somesite.html isn't loaded in your example).

Last edited by Charalambos; 08-18-2004 at 12:24 AM.
 
Old 08-19-2004, 12:53 PM   #10
VibeOfOurTribe
LQ Newbie
 
Registered: Jul 2004
Posts: 21

Rep: Reputation: 16
in fact, that is also a better way because you can change any number of frames simultaneously rather than just two. I realized this after I posted. Thanks for your help.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Broadcom BCM4401 NIC: Link is Down, Link is up mr.wobble Linux - Hardware 6 08-31-2007 10:48 AM
Soft Link and Hard Link Moataz Red Hat 1 04-25-2005 06:30 AM
OpenBSD 3.6 install D-Link 300T / D-Link DFE 528TX lesleyb *BSD 2 04-01-2005 06:29 PM
Wake on Lan - Link on b4 power up, No Link light after shutdown? Mark007 Linux - Networking 0 11-20-2004 08:16 PM
eth1... failed; no link present. Check Link? illegalien Linux - Networking 3 11-03-2002 10:46 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 05:01 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration