?
Solved

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

Posted on 2008-10-14
12
Medium Priority
?
712 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
Get real performance insights from real users

Key features:
- Total Pages Views and Load times
- Top Pages Viewed and Load Times
- Real Time Site Page Build Performance
- Users’ Browser and Platform Performance
- Geographic User Breakdown
- And more

 

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 2000 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

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

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.

Question has a verified solution.

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

Building a website can seem like a daunting task to the uninitiated but it really only requires knowledge of two basic languages: HTML and CSS.
Nothing in an HTTP request can be trusted, including HTTP headers and form data.  A form token is a tool that can be used to guard against request forgeries (CSRF).  This article shows an improved approach to form tokens, making it more difficult to…
The viewer will receive an overview of the basics of CSS showing inline styles. In the head tags set up your style tags: (CODE) Reference the nav tag and set your properties.: (CODE) Set the reference for the UL element and styles for it to ensu…
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …
Suggested Courses

770 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