[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 715
  • Last Modified:

Calling JavaScript Function using href inside a <td ...>

Currently, on one screen , the following code to display the clicked invoice works.


           <td class="data"><a href="fin_InvoicePartList.htm?Invnum=<HSM name=Invnbr>&xxDealerCd=<HSM name=xxDealerCd>"><HSM name="Invnbr"></a></td>
 <td class="data"><HSM name=DlrOrd></td>
  <td class="data"><hsm name=SysOrd></td>
   <td class="data"><hsm name=OrdDate></td>

Now, I am working on a different screen which is a window. On that screen, when an invoice is clicked, I want to close the window and go back to the parent fields

To do this, I wrote a javascript function goback as below.
  function goback(in1) {
      var parent1 = opener.document;
    var parentField = parent1.getElementById("Invnum");
         parentField.value = in1;
       parentField.focus();
       window.close();
       }
 
Can I invoke this javascript function inside the href inside a <td>   ?

I tried the following two ways but without much success.  The code is not even going to the javascript function.

  <td class="data" <a href="javascript:goback(<HSM name=Invnbr>)"> <HSM name="Invnbr"></a> </td>

  <!--    <td class="data" onclick="goback(<HSM name=Invnbr>)"> <HSM name="Invnbr">  </td> -- > 

Please ignore the HSM tag. It is a local middleware thing and I can assure you that it does not interfere wih standard HTML/JavaScript.

Thanks a Lot.


0
narayanhy
Asked:
narayanhy
  • 6
  • 5
1 Solution
 
sijishJohnCommented:
try this..

<td class="data" <a href="#" onclick="javascript:goback(<HSM name=Invnbr>)"> <HSM name="Invnbr"></a> </td>
0
 
sijishJohnCommented:
forget to close the td tag..

hope this will do..

<td class="data"> <a href="#" onclick="javascript:goback(<HSM name=Invnbr>)"> <HSM name="Invnbr"></a> </td>
0
 
scrathcyboyCommented:
simply use onClick="this.window.close();"

that will return you to the parent, won't it?  Where else can it go?
0
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 
narayanhyAuthor Commented:
I need to paswed the clciked invoice number to parent.

WHen I tried
<td class="data"> <a href="#" onclick="javascript:goback(<HSM name=Invnbr>)"> <HSM name="Invnbr"></a> </td>
Now, I get the display of invoices  now properly. But when I click on an onvoce numebr say 1234, I get errorsaying that
"1234" is undefined. I then trined goback(inv1=<HSM name=Invnbr>). Even this did not work.
Thanks a lot for your quick responses.

0
 
narayanhyAuthor Commented:
I get the error

"1234" is undefined on the line number where we have the statement having teh href as below.

<td class="data"> <a href="#" onclick="javascript:goback(<HSM name=Invnbr>)"> <HSM name="Invnbr"></a> </td>
Cheers
0
 
sijishJohnCommented:
give it like this...

<td class="data"> <a href="#" onclick="javascript:var Inv = <HSM name=Invnbr>;goback('Inv');"> <HSM name="Invnbr"></a> </td>
0
 
sijishJohnCommented:
Oops...No need for quotes inside the method...

<td class="data"> <a href="#" onclick="javascript:var Inv = <HSM name=Invnbr>;goback(Inv);"> <HSM name="Invnbr"></a> </td>
0
 
narayanhyAuthor Commented:
Sorry mate, Still I get the same error.
0
 
sijishJohnCommented:
try this..

var Inv = <HSM name=Invnbr>.toString()
0
 
narayanhyAuthor Commented:
The solution originally proposed by sijishJohn is working now.

The following is the working bit.

 <a href="#"onclick="javascript:goback('<HSM name=Invnbr>');"> <HSM name=Invnbr></a> </td>

Thanks a Lot John !  

0
 
narayanhyAuthor Commented:
Thanks a Lot John for your help. When i removed the variable definition and straight away put the  code, it worked.

Can u suggest a good educational site for HTML/javascript ?  
0
 
sijishJohnCommented:
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

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