我使用灯箱加载单个表单,但是我希望能够将不同的变量作为隐藏值传递给表单,具体取决于哪个'提醒我'链接已被点击。
我想通过产品标题,发布日期和产品链接,因为这些都会在名称,电子邮件地址和提醒日期之后存储在MySQL表格中。这些都是我的代码中的PHP变量,它们的设置如下:
<div class="column third">
<div class="featcontainer">
<figure class="image-container"><div class="featimage">
<img src="<?=$row['img_url']?>"/></div>
<figcaption class="clearfix">
<h3><?=$row['small_title']?></h3>
<div class="release_date"><?=$row['release_date']?></div>
<a href="<?=$row['prod_link']?>" class="btn1" target="_blank">Product Link</a>
<a href="" class="remindme" target="_blank">Remind Me</a>
</figcaption>
</figure>
</div>
</div>
输出的HTML如下所示:
<div class="column third">
<div class="featcontainer">
<figure class="image-container">
<div class="featimage">Image here</div>
<figcaption class="clearfix">
<h3>Product 1 Title</h3>
<div class="release_date">Release Date Here</div>
<a href="Link 1" class="btn1" target="_blank">Product Link</a>
<a href="" class="remindme" target="_blank">Remind Me</a>
</figcaption>
</figure>
</div>
</div>
<div class="column third">
<div class="featcontainer">
<figure class="image-container">
<div class="featimage">Image here</div>
<figcaption class="clearfix">
<h3>Product 2 Title</h3>
<div class="release_date">Release Date Here</div>
<a href="Link 2" class="btn1" target="_blank">Product Link</a>
<a href="" class="remindme" target="_blank">Remind Me</a>
</figcaption>
</figure>
</div>
</div>
<div class="column third">
<div class="featcontainer">
<figure class="image-container">
<div class="featimage">Image here</div>
<figcaption class="clearfix">
<h3>Product 3 Title</h3>
<div class="release_date">Release Date Here</div>
<a href="Link 3" class="btn1" target="_blank">Product Link</a>
<a href="" class="remindme" target="_blank">Remind Me</a>
</figcaption>
</figure>
</div>
</div>
<form class="remindme" method="post">
<fieldset>
<label>Name</label>
<input name="name" id="name" type="text">
<label>Email</label>
<input name="email" id="email" type="text">
<label>When to remind</label>
<input type="radio" id="date" name="date" value="ondate">On Release
<input type="radio" id="date" name="date" value="beforedate">Day Before Release
</fieldset>
<input type="submit" value="Remind Me" name="submit">
</form>
答案 0 :(得分:0)
您是否尝试过<ipnut type="hidden">
代码?
您可以像这样使用它:
(在表格内)
<form>
...
<input type="hidden" name="prod_title" value="<?= row['prod_title'] ?>" />
<input type="hidden" name="release_date" value="<?= row['release_date'] ?>" />
<input type="hidden" name="prod_link" value="<?= row['prod_link'] ?>" />
...
</form>
修改强>
检查这个小提琴,我给你写了一个例子。当用户单击链接时,它会从数组中获取所需的详细信息(链接,标题,日期),并将其设置在表单的隐藏输入中:http://jsfiddle.net/W5L2D/
应该使用PHP迭代创建数组,并将数字放在链接的name属性中。