Solved

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

Posted on 2008-10-14
12
710 Views
Last Modified: 2010-04-21
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
Comment
Question by:narayanhy
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 6
  • 5
12 Comments
 
LVL 4

Expert Comment

by:sijishJohn
ID: 22717957
try this..

<td class="data" <a href="#" onclick="javascript:goback(<HSM name=Invnbr>)"> <HSM name="Invnbr"></a> </td>
0
 
LVL 4

Expert Comment

by:sijishJohn
ID: 22717966
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
 
LVL 44

Expert Comment

by:scrathcyboy
ID: 22717988
simply use onClick="this.window.close();"

that will return you to the parent, won't it?  Where else can it go?
0
Technology Partners: 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!

 

Author Comment

by:narayanhy
ID: 22718022
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
 

Author Comment

by:narayanhy
ID: 22718028
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
 
LVL 4

Expert Comment

by:sijishJohn
ID: 22718044
give it like this...

<td class="data"> <a href="#" onclick="javascript:var Inv = <HSM name=Invnbr>;goback('Inv');"> <HSM name="Invnbr"></a> </td>
0
 
LVL 4

Expert Comment

by:sijishJohn
ID: 22718055
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
 

Author Comment

by:narayanhy
ID: 22718096
Sorry mate, Still I get the same error.
0
 
LVL 4

Accepted Solution

by:
sijishJohn earned 500 total points
ID: 22718545
try this..

var Inv = <HSM name=Invnbr>.toString()
0
 

Author Comment

by:narayanhy
ID: 22727375
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
 

Author Closing Comment

by:narayanhy
ID: 31506185
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
 
LVL 4

Expert Comment

by:sijishJohn
ID: 22728003
0

Featured Post

SharePoint Admin?

Enable Your Employees To Focus On The Core With Intuitive Onscreen Guidance That is With You At The Moment of Need.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Jquery Ajax - on change event not being picked up 9 36
Put POST values into cookies. 14 35
Hit counters in SharePoint 2013 2 30
CSS for Popup in ASP.NET 4 19
This article discusses four methods for overlaying images in a container on a web page
The article shows the basic steps of integrating an HTML theme template into an ASP.NET MVC project
In this Micro Tutorial viewers will learn how to create navigation buttons that change on rollover, using CSS (Continuation of the CSS Image Sprite tutorial) Create a parent ID for all the list items       - Specify position: absolute and display: block…
In this tutorial viewers will learn how to style transparent/translucent elements using alpha transparency in CSS Start with a normal styled element, such as a div.: Define its "background-color" property as "rgba (255, 255, 255, .5): The numbers in…

726 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question