View Full Version : Substitute for this.form ?
pankaj_it09
02-07-2007, 11:15 AM
In the below code each loop as a FORM.
I use these FORMS in the onChange event.
Is there any substitute for FORM ?
<TMPL_LOOP NAME="AttachedFiles">
<form name="attach_<TMPL_VAR NAME=datetime><TMPL_VAR NAME=filename>">
<tr>
<td class="plogitemselectable" align="center"width="10%"><TMPL_VAR NAME="filesig"></td>
<td class="plogitemselectable" align="center" width="20%"><TMPL_VAR NAME="datetime"></td><td class="plogitemselectable" align="center"><a href="/cgi-bin/tps/attach_file.cgi?act=search&filename=<TMPL_VAR NAME=filename>&conid=<TMPL_VAR NAME=conid>&datetime=<TMPL_VAR NAME=datetime>"><TMPL_VAR NAME="filename"></a></td><td class="plogitemselectable"><TMPL_VAR NAME="comment"></td><td class="plogitemselectable" align="center"><TMPL_VAR NAME="type"></td><td class="plogitemselectable" align="center"><input type="checkbox" name="hidefile" "<TMPL_VAR NAME=hidefile>" onChange="updateHideStatus(this.form,'<TMPL_VAR NAME=datetime>','<TMPL_VAR NAME=filename>');"/></td>
</tr>
</form>
</TMPL_LOOP>
nikkiH
02-07-2007, 09:39 PM
Not sure what you're asking. It might be. It might not be. Depends on what you're doing.
You can certainly loop with no form, in general.
http://html-template.sourceforge.net/article.html
http://www.sitepoint.com/article/introducing-html-template/2
pankaj_it09
02-08-2007, 06:11 AM
Is there any other HTML tag by which I can LOOP and use it just like this.form ?
For eg:- if the other tag is <div> then this.div ?
nikkiH
02-08-2007, 03:17 PM
You mean here?
onChange="updateHideStatus(this.form, ...
You're mixing up your languages here.
The TMPL stuff is Perl. It's evaluated on the server before the page is ever passed to the client. this.form is javascript and is evaluated onChange, on the client.
As coded, no, you need this.form, because the "this" refers to the form element. If you want to pass another element, that might be possible. The function updateHideStatus is the important part here; what kind of element does IT expect. Seems it expects a form, since that's what you're passing. If that's the case, passing another element would be an error. You'd have to change that function to accept some other element, then pass it appropriately.
This is pretty much a pure javascript question and has little to do with your Perl stuff.
pankaj_it09
02-09-2007, 05:52 AM
Just like this.form is related to the current form in the loop I want another HTML TAG in place of form.
For eg:- if the other HTML tag is <div> then can I use this.div ?
nikkiH
02-09-2007, 03:25 PM
The called function that you are passing this.form to, updateHideStatus, expects a form. Not a div.
Are you going to recode that function to accept a div?
Do you mean something like this?
<script type="text/javascript">
function test(obj){
obj.innerHTML="I am a "+obj.nodeName+"<br>"+" my id is "+obj.id
}
</script>
<div id="mydiv" onclick="test(this)">CLICK ME</div>
pankaj_it09
02-12-2007, 07:00 AM
The called function that you are passing this.form to, updateHideStatus, expects a form. Not a div.
Are you going to recode that function to accept a div?
Thats what I am telling.
I want a HTML tag which can substitute the FORM tag.
For eg:- if the HTML tag is <div> then i should be able to use this.div.
Any HTML tag which will do the same thing what the form is doing ?
pankaj_it09
02-12-2007, 08:05 AM
Do you mean something like this?
<script type="text/javascript">
function test(obj){
obj.innerHTML="I am a "+obj.nodeName+"<br>"+" my id is "+obj.id
}
</script>
<div id="mydiv" onclick="test(this)">CLICK ME</div>
I want to fire the event when I click on the CHECKBOX .
The above code won't work in that case.
nikkiH
02-12-2007, 09:09 PM
Is there some reason for switching to something other than form when the clicked item is a form element?
pankaj_it09
02-13-2007, 05:49 AM
I got the solution.
I got the solution.
Would you care to share it so we know what exactly you were trying to do?
pankaj_it09
02-14-2007, 05:40 AM
Would you care to share it so we know what exactly you were trying to do?
I used this instead of this.form.
pankaj_it09
02-15-2007, 05:33 AM
As per my post #7 then
Not exact like your post.
I put this in the JS calling function .
vBulletin® v3.8.2, Copyright ©2000-2012, Jelsoft Enterprises Ltd.