简体   繁体   中英

How to Make an entire table cell act as a clickable form area

I have a table with a cell that I want everything within it to be clickable I need the data within the cell to POST data via a form

<td  BGCOLOR="#77777" align="center" valign="center">
<form method="post" action="index.php?option=com_content&view=article&id=11"  name="details">
<input type="hidden" id="UUID" name="UUID" value="<?php echo $dealUUID?>">
<input type="image"  height="300" width="365" src="php_scripts/getdealimage.php?id='<?php echo $dealUUID?>'" name="checked" value="<?php echo $info[0]; ?>">
</form>
<div id="dealdata">
<br /><?echo $dealpromo;?> 
<h1><?echo $dealvalue; ?></h1>
</div> 
</td>

so I would like the entire area to be a clickable area and SEND the form data

To submit the table cell u can use this

$('td > form').each(function(i,e){
   var form = $(this);
   var cell = form.parent();
   if(cell.is('td')){
     cell.click(function(){
       form.submit();
     });
   }
});

If you jsut want to follow the link instead, jsut modify the form.submit() part to change window.location.href with form.attr('action').

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM