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?
JohnLucaniaAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

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
Ultimate Tool Kit for Technology Solution Provider

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy now.

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

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
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
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
JavaScript

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.