开发者

Loading random form into jQuery Tools overlay

I asked how to load a random form in another thread and got great answers. Here is what I开发者_如何学编程 got and verified to work

$(function() {
 $("a.random")click.(function){
    $(".test_form").hide();
    var formNumber = Math.floor(Math.random() * 4);//will equal a number between 0 and 3
    $("#form" + formNumber).show();
 });
});

I need to apply this somehow to a jQuery Tools overlay that is being triggered as such

<a href="Forms/SupportFormTest.php" rel="#overlayForm"> 

and modify the href somehow to include the a reference to the function. would simply removing the href and using a class work? But then I would somehow have to add a path to the forms they are in another directory "/Forms". Help is much appreciated, the flowplayer.org forms are less than helpful


You can use .data() to attach arbitrary data to an element.

If it's just string data you're looking to store, you can instead use .attr() to save the string to an attribute on the element. For HTML-5-compliant goodness, use an attribute that starts with data-.


Edit as requested, lazy copypasta:

I don't know PHP, and I definitely don't know how your site is set up, but the basic idea would be:

  1. link to Forms/RandomForm.php
  2. RandomForm.php would send an HTTP redirect to the browser, telling it to request an actual form page, chosen at random - say, Forms/Form2.php.
  3. The browser now has the actual form to put into the overlay.

Does that sound reasonable? If you do still want to have the randomization in the browser, could you explain exactly what you're trying to randomize?

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜