05-09-2010, 07:59 PM
Hey folks .. long time lurker... and first post :D
Have been looking for a few weeks now and no luck in finding any answer to this.. so here goes
I have a html page that generates forms dynamically - all ok here
What I'd like to do is really only cosmetic - but would still like to see if its possible.
I have a legend for each form which appears as "Form Name"
I have a Global Variable called "counter" which keeps track of the number of forms created
What I would like to know is it possible to have my forms created so the Legend will state "Form Name 1" for the first form, "Form Name 2"
=> basically the number x in "Form Name x" is assigned on the form creation and is the value of "counter"
Is this possible ??:confused:
Any advice much appreciated
05-09-2010, 08:26 PM
Yes, it is possible. However to give more advice we will need some more information.
I have a html page that generates forms dynamically
How to achieve the result you want will depend in no small part on which language you are using to generate your forms.
Which language are you using?
05-09-2010, 10:04 PM
Thanks for your reply.
In my HTML body I have a DIV id="template" style="display: none"
on page load it displays one form
I can include the code if it will help.
05-10-2010, 03:05 AM
var counter = 5;
var formName = "Form Name";
var fullFormName = "";
fullFormName = formName + " " + counter;
If you need more than this, then posting your code would help.
05-10-2010, 02:30 PM
Hey thanks for getting back to me.. I know how to join things together..
however what I want is to have the Global Variable displayed directly ion the html page when it is rendered.. heres my code... any ideas
document.getElementById('additional_form').onclick = additional_panel_form;
var new_form = document.getElementById('panel_form_template').cloneNode(true);
new_form.id = '';
new_form.style.display = 'block';
var next_form = new_form.childNodes;
var form_name = next_form[index].name
next_form[index].name = form_name + counter;
var insertHere = document.getElementById('newpanel');
<div><label for="Page Name">Page Name</label> <input id="page_name" name="page_name" type="text" onfocus="this.value==this.defaultValue?this.value='':null" /></div>
<div id="panel_form_template" style="display: none" class="panel_class">
<div><label for="panel_label">Panel Label</label> <input id="panel_label" name="panel_label" type="text" onfocus="this.value==this.defaultValue?this.value='':null" /></div>
<div><label for="search">Search Term</label> <input id="search" name="search" type="text" onfocus="this.value==this.defaultValue?this.value='':null" /></div>
<input type="button" value="Remove Panel" onclick="remove_panel_form(this);" /></div>
<form name="myform" id="myform" method="post" onsubmit="return validate();" action="show_flickr_search_results.php"><span id="newpanel"></span> <input type="button" id="additional_form" value="Add Panel" /> <input type="submit" value="Show Gallery" /></form>
05-10-2010, 07:57 PM
To clarify a bit more..
On loading there is no form displayed *until* onpageload
this then displayes the first form counter=1
So I would like the form to appear showing "Panel Label 1"
on creating the second panel the counter will be 2 so I would like the form to appear "Panel Label 2"
write.document(counter) does not work - in simply displays counter value which is at 1 onpageload and *NO* form is displayed
alert(counter) does display the vlaue that I expect at the time of creation of the form but again this is in an alert box.. not actually "written" in the page itself..
AS I said earlier this is purely cosmetic - but would be nice if I could figure out how to do it :D:thumbsup: