0

i have the page "list.php" where my php script show the list of the records stored in a mysql table, when the user click on the record should go on the page "detail.php" and see all the details.

<a class='box' href='detail.php'>
<img src='img.gif' width='60' height='60' alt='' />
<span class='title'>$title</span><br>
<span class='text'>$text</span>
</a>

the code above work, but then i cannot add a second "a href" inside the first, for example:

<a class='box' href='detail.php'>
<img src='img.gif' width='60' height='60' alt='' />
  <a class='right' href='page2.php'>delete</a>
<span class='title'>$title</span><br>
<span class='text'>$text</span>
</a>

so i've try to use a "div" instead of the "a href", like this:

  <div class='box' style='cursor:pointer' onClick='location='detail.php'>
<img src='img.gif' width='60' height='60' alt='' />
  <a class='right' href='page2.php'>delete</a>
<span class='title'>$title</span><br>
<span class='text'>$text</span>
</div>

but the "onClick='location='page.php'" inside the "div" don't work, any workaround?

ipel
  • 1,326
  • 1
  • 18
  • 43
  • you need `onclick="window.location='detail.php';"` – Patrick Moore Feb 04 '14 at 17:49
  • You've closed your `onclick=''` prematurely when you've opened another `='detail.php'` inside. Can't do that. Enclose `''` inside `""` or vice versa. – Patrick Moore Feb 04 '14 at 17:54
  • Sure, sorry! but the syntax is correct? should i use the "div" with onclick? then google can follow these links? – ipel Feb 05 '14 at 07:55
  • Yes, syntax is correct. I would use `
    ` with onclick as the parent. Google will not follow that syntax, so if that is of importance, you can wrap your `` like: `` which will give Google a link to follow.
    – Patrick Moore Feb 05 '14 at 09:22

1 Answers1

0

Just wrap your nested a inside an object tag.

<a class='box' href='detail.php'>
<img src='img.gif' width='60' height='60' alt='' />
  <object><a class='right' href='page2.php'>delete</a></object>
<span class='title'>$title</span><br>
<span class='text'>$text</span>
</a>
BENARD Patrick
  • 30,363
  • 16
  • 99
  • 105