• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 399
  • Last Modified:

Error: document.forms.0.callerId is null or not an object

    function redirectForm()
     {
          // default form action - if trash icon or button
          var actionURL = "default.cfm?fuse_action=Main&Dest=RecSimGift&SavePayment=Submit";

          if(document.pressed == 'Process')
          {
               // other URL if this condition is met
               actionURL = "default.cfm?fuse_action=Main&Dest=RecSimGift&SavePayment=Submit";
          }

          document.storePayment.action = actionURL;
          return true;
     }


<input type="hidden" name="callerId" value="trash2122" />
<TD><div align="center"><a href="javascript://void(0);" id="trash2122" onClick="document.forms[0].callerId.value=this.id;return redirectForm();"><img src="./images/trash.gif" width="12" height="13" border="0"></a></div></TD>
      
How to fix this?
0
JohnLucania
Asked:
JohnLucania
  • 7
  • 5
1 Solution
 
RoonaanCommented:
You can give your form a name:

<form name="myForm">

then use

document.forms.myForm.callerId.value;

-r-
0
 
JohnLucaniaAuthor Commented:
I have tried these:

<TD><div align="center"><a href="javascript://void(0);" id="trash#MyInstallments.installID#" onClick="document.forms.storePayment.callerId.value;return redirectForm();"><img src="./images/trash.gif" width="12" height="13" border="0"></a></div></TD>

<TD><div align="center"><a href="javascript://void(0);" id="trash#MyInstallments.installID#" onClick="document.forms.storePayment.callerId.value=this.id;return redirectForm();"><img src="./images/trash.gif" width="12" height="13" border="0"></a></div></TD>

But, nothing happens when clicked.
0
 
RoonaanCommented:
No, but wouldn't you have to include a document.forms.storePayment.submit() somewhere?

-r-
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
JohnLucaniaAuthor Commented:
<input tabindex="#myTab#" class=notetext2 name = "cmdSubmit" type = "button" value = "Process Gift" onClick = "document.pressed=this.value;this.disabled=true;this.value='Please wait...';this.form.submit()"/>

This button works fine.  so, as log as it has the same effect, it would work.  

<form name="storePayment" action="default.cfm?fuse_action=Main&Dest=RecSimGift&SavePayment=Submit" method="post" onsubmit="return redirectForm();">

.....

</form>

where should I put document.forms.storePayment.submit() ?
0
 
RoonaanCommented:
You could try and use a <input type="image" rather than <a><img>:


Change:
<a href="javascript://void(0);" id="trash#MyInstallments.installID#" onClick="document.forms.storePayment.callerId.value=this.id;return redirectForm();"><img src="./images/trash.gif" width="12" height="13" border="0"></a>

To:

<input type="image" id="trash#MyInstallments.installID#" src="./images/trash.gif" onclick="this.form.callerId=this.id";return redirectForm();" />

-r-
0
 
RoonaanCommented:
Sorry, above has a typo:

<input type="image" id="trash#MyInstallments.installID#" src="./images/trash.gif" onclick="this.form.callerId=this.id;return redirectForm();" />

-r-
0
 
JohnLucaniaAuthor Commented:
<TD><div align="center"><input type="image" id="trash#MyInstallments.installID#" src="./images/trash.gif" onclick="this.form.callerId=this.id;return redirectForm();" /></a></div></TD>

It returns “object does not support this property or method”, and then submit the form.
How do you suppress the error?
0
 
RoonaanCommented:
try this.form.callerId.value=this.id (adding .value)

-r-
0
 
JohnLucaniaAuthor Commented:
yes,

<TD><div align="center"><input type="image" id="trash#MyInstallments.installID#" src="./images/trash.gif" onclick="this.form.callerId.value=this.id;return redirectForm();" /></a></div></TD> works.

The only remaining challenge is how to pass i.e the id="trash1234onto the next page.  
There are muiltple of ids:

     <tr>
            <INPUT type=hidden name="INST1463" value="1463">
            <TD class=notetext2><INPUT tabindex="75" type=text class=notetext2 name="InAmount1463" value="25" id="InAmount1463"></TD>
            
            <TD class=notetext2><INPUT style="width:7em" tabindex="76" type=text class=notetext2 name="InDate1463" value="12/08/2006" id="InDate1463"></TD>
            
            <input type="hidden" name="callerId" value="1463" />

                <TD><div align="center"><input type="image" id="trash1463" src="./images/trash.gif" onclick="this.form.callerId.value=this.id;return redirectForm();" /></a></div></TD>
            
            <TD colspan="2" class=notetext2></TD>
            
               
      </TR>
 


       <tr>
            <INPUT type=hidden name="INST1464" value="1464">
            <TD class=notetext2><INPUT tabindex="79" type=text class=notetext2 name="InAmount1464" value="25" id="InAmount1464"></TD>
            
            <TD class=notetext2><INPUT style="width:7em" tabindex="80" type=text class=notetext2 name="InDate1464" value="01/08/2007" id="InDate1464"></TD>
            
            <input type="hidden" name="callerId" value="1464" />

                <TD><div align="center"><input type="image" id="trash1464" src="./images/trash.gif" onclick="this.form.callerId.value=this.id;return redirectForm();" /></a></div></TD>
            
            <TD colspan="2" class=notetext2></TD>
            
               
      </TR>

bla....

I need to pass the id (i.e. 1464) to the next page when the gif on id="trash1464" is clicked.
0
 
RoonaanCommented:
Isn't that what the part: "this.form.callerId.value=this.id" does?

-r-
0
 
JohnLucaniaAuthor Commented:
how do you view  "this.form.callerId.value=this.id" on the next page?
0
 
RoonaanCommented:
That lines sets a value to the hidden field callerId. You should just be able to use $_POST['callerId'] or $_GET['callerId'] when in PHP, I don't know the syntax for JSP/ASP.

-r-
0

Featured Post

Vote for the Most Valuable Expert

It’s time to recognize experts that go above and beyond with helpful solutions and engagement on site. Choose from the top experts in the Hall of Fame or on the right rail of your favorite topic page. Look for the blue “Nominate” button on their profile to vote.

  • 7
  • 5
Tackle projects and never again get stuck behind a technical roadblock.
Join Now