473,320 Members | 1,900 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

HELP. this.form does not seem to pass value...

Please help, this is doing my head in!!!! I am sure it is something
really simple and ovbious that I am missing but for the life of me I
cant find where!!!

I have this function...

<script>
<!--
function update(frm) {
var mon, mon1, form;

form=frm;
mon=frm.mon.value;

alert(mon);
}
-->
</script>
and this calls it...

<form method="post" name="sas002">
<tr>
<td><input name="mon" value="1" size="5"></td<td><input name="tue"
value="1" size="5"></td>
<td><img src="../images/edit.gif" onClick="update(this.form)"></td>
</tr>
</form>

how whenever I run this i get an undefined for the form name...

its as if the this.form is not passing the form name through like it
should be - any suggestions?

need to do it like this as the form is created dynamically....

Jul 19 '06 #1
3 1588
Shippy wrote:
Please help, this is doing my head in!!!! I am sure it is something
really simple and ovbious that I am missing but for the life of me I
cant find where!!!

I have this function...

<script>
<!--
function update(frm) {
var mon, mon1, form;

form=frm;
mon=frm.mon.value;

alert(mon);
}
-->
</script>
and this calls it...

<form method="post" name="sas002">
<tr>
<td><input name="mon" value="1" size="5"></td<td><input name="tue"
value="1" size="5"></td>
<td><img src="../images/edit.gif" onClick="update(this.form)"></td>
</tr>
</form>

how whenever I run this i get an undefined for the form name...

its as if the this.form is not passing the form name through like it
should be - any suggestions?
Excactly, and why do you say it should be passing the formname if you use
this.form in an image?

The keyword 'this' should only be used if you knwo WHAT it is refering to.
eg: If you use it in an input type="text" it will reference that
inputelement.
If you use it in an image....

Solution: simple give your form a name, and pass that to the function.
From your function you can use:
function update(formname) {
var formref=document.forms[formname];
var mon=formref.mon.value;
alert(mon);
}
>
need to do it like this as the form is created dynamically....

That is no reason to leave the names of the forms out. :-)

Good luck!

Regards,
Erwin Moller

Jul 19 '06 #2
Erwin Moller wrote:
Shippy wrote:
>Please help, this is doing my head in!!!! I am sure it is something
really simple and ovbious that I am missing but for the life of me I
cant find where!!!

I have this function...

<script>
<!--
function update(frm) {
var mon, mon1, form;

form=frm;
mon=frm.mon.value;

alert(mon);
}
-->
</script>
and this calls it...

<form method="post" name="sas002">
<tr>
<td><input name="mon" value="1" size="5"></td<td><input name="tue"
value="1" size="5"></td>
<td><img src="../images/edit.gif" onClick="update(this.form)"></td>
</tr>
</form>

how whenever I run this i get an undefined for the form name...

its as if the this.form is not passing the form name through like it
should be - any suggestions?

Excactly, and why do you say it should be passing the formname if you use
this.form in an image?

The keyword 'this' should only be used if you knwo WHAT it is refering to.
eg: If you use it in an input type="text" it will reference that
inputelement.
If you use it in an image....

Solution: simple give your form a name, and pass that to the function.
From your function you can use:
function update(formname) {
var formref=document.forms[formname];
var mon=formref.mon.value;
alert(mon);
}
>>
need to do it like this as the form is created dynamically....


That is no reason to leave the names of the forms out. :-)
Oops, my bad.
You DID name the form already, so if you want to use it in your
image-onClick-handler you can do this:
<td><img src="../images/edit.gif" onClick="update('sas002');"></td>
Jul 19 '06 #3
Your an absolute STAR - many thanks!

completely forgot about "this." being related to that item...
Erwin Moller wrote:
Shippy wrote:
Please help, this is doing my head in!!!! I am sure it is something
really simple and ovbious that I am missing but for the life of me I
cant find where!!!

I have this function...

<script>
<!--
function update(frm) {
var mon, mon1, form;

form=frm;
mon=frm.mon.value;

alert(mon);
}
-->
</script>
and this calls it...

<form method="post" name="sas002">
<tr>
<td><input name="mon" value="1" size="5"></td<td><input name="tue"
value="1" size="5"></td>
<td><img src="../images/edit.gif" onClick="update(this.form)"></td>
</tr>
</form>

how whenever I run this i get an undefined for the form name...

its as if the this.form is not passing the form name through like it
should be - any suggestions?

Excactly, and why do you say it should be passing the formname if you use
this.form in an image?

The keyword 'this' should only be used if you knwo WHAT it is refering to.
eg: If you use it in an input type="text" it will reference that
inputelement.
If you use it in an image....

Solution: simple give your form a name, and pass that to the function.
From your function you can use:
function update(formname) {
var formref=document.forms[formname];
var mon=formref.mon.value;
alert(mon);
}

need to do it like this as the form is created dynamically....


That is no reason to leave the names of the forms out. :-)

Good luck!

Regards,
Erwin Moller
Jul 19 '06 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Phil Schmidt | last post by:
I'm trying to make a custom entry widget, as in the code that follows. There are two problems I'm trying to fix: 1) I would like the widget to behave as myEntry.Escape() does now, except that it...
7
by: Mike | last post by:
I've been trying for the past week to put a simple code together. I have done a LOT of searching, found scripts showing the functions I would like to use, however when I mix them it all goes wrong,...
1
by: Ed | last post by:
I've search around endlessly for a solution to this problem but have not found anything yet. I'm using Crystal 9 with .NET. I am not using a DSR to create the report. Instead I am creating a...
0
by: Uma Vivek | last post by:
Hi, I have a problem with Flash remoting via .NET . I seem to have all the code right, but flash does not seem to display the data at all. Here's is what Ive done so far... (1) Ive...
7
by: Jack Addington | last post by:
I've got a fairly simple application implementation that over time is going to get a lot bigger. I'm really trying to implement it in a way that will facilitate the growth. I am first writing a...
5
by: Steve Cosh | last post by:
Hi, can some one please help me, Ive got a javascript variable called totScore that i need to pass to an asp variable in an asp page so i can then write this out to my database. Any help...
16
by: pamelafluente | last post by:
I am still working with no success on that client/server problem. I need your help. I will submit simplified versions of my problem so we can see clearly what is going on. My model: A client...
0
by: gunimpi | last post by:
http://www.vbforums.com/showthread.php?p=2745431#post2745431 ******************************************************** VB6 OR VBA & Webbrowser DOM Tiny $50 Mini Project Programmer help wanted...
11
by: cybervigilante | last post by:
I can't seem to change the include path on my local winmachine no matter what I do. It comes up as includ_path .;C:\php5\pear in phpinfo() but there is no such file. I installed the WAMP package...
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.