tags:

views:

109

answers:

2

Hi,

In my application i want to keep my Form id in the Dom element So that on click of my Dom element, i get to know the Form id and make use of that for further purpose.

For eg: my app has a list of form names generated like

    <a href="/FormBuilder/index.php/main/entryManager" id="Form1">Contact Form</a>
    <a href="/FormBuilder/index.php/main/entryManager" id="Form2">Personal Form</a>

I want to save my form id that is 1 somewhere in the Dom element a. And onclick of that link i want to make use of it for further things . How can i do .. Where can i save my Form id in the Dom element.Please suggest me..

Edit:

In my application by using JQuery, i am generating list of Form names by fetching it from by MYSQL database using CakePHP framework.

eg:

     $('#entryManager').click(function(){

             $("<p class='title2'>Forms</p>").appendTo("#fb_contentarea_col1top");
             $("<ul class='formfield'>").appendTo("#fb_contentarea_col1down");
            <?php foreach ($Forms as $r): ?>

            $("<li><a id=Form'<?=$r['Form']['id'];?>' href='/FormBuilder/index.php/main/entryManager'><?=$r['Form']['name']?></a></li>").appendTo("#fb_contentarea_col1down .formfield");

           <?php endforeach; ?>

                 return false;
            });//entry Manager Click

On click of Entry manager the Form names are listed .

And now i want to use some function like onclick of each Form name i want to retrieve the Entries filled by invitees from the database.For this i want the FOrm id each Form name to store it somewhere in the DOm element so that i can get that value (form id) and send it to my ajax request to fetch the entries filled..How can i do so???

A: 

Don't use purely numeric id's, it's best if they start with a letter, but essentially you can can have...

<form id="form1"...>

And then store the information in your anchor like this...

<a rel="form1">Click...

Then you can pull the "rel" tag out and use it to reference form1.

This is technically stretching the purpose of the rel tag, but does work.

Sohnee
A: 

document.forms is an array that contains all of your forms and you can do something like this:

document.forms['myFormId'] and you would get the form of that ID. But yet I am not getting what you are trying to achieve. May be if you elaborate on it further then I can guide you better on this.

Mohsin Hijazee