Matthew Croft
Matthew Croft

Reputation: 71

Calling Javascript Function from Hyperlink

I am working on a page that contains a digital phone directory. The names and numbers are listed, but I would like for more details about the entry to display in a popup when the name is clicked. Unfortunately, I am having a problem with the Javascript. I am very new to this language, but I think that either the code within the function I declared is wrong, the syntax of the argument I am passing is incorrect, or I omitted an essential part of the code. Any assistance you can provide on this issue would be greatly appreciated.

<html>
<head>
<link rel="stylesheet" type="text/css" href="style.css">
<script>
Function DisplayContactDetail(contact, windowname) {
    window.open(contact, windowname);
}
</script>
<title>Cigna Security & Reception Phone Directory</title>
</head>
<body>
    <div class="centerelement">
        <div id="indexpageheader">
            CIGNA SECURITY & RECEPTION DIGITAL PHONE DIRECTORY
        </div>
    </div>
    <table>
        <th colspan=2 width="auto">
            ALLIEDBARTON
        </th>
        <tr>
            <td width="50%">
                <a href="" onclick="DisplayContactDetail('cigna.com','ContactDetail')">
                    NEPA District Office
                </a>
            </td>
            <td>(610) 954-8590</td>
        </tr>
        <tr>
            <td width="50%">Post Watch</td>
            <td>(800) 643-8714</td>
        </tr>
    </table>

Thanks in advance!

Upvotes: 1

Views: 24021

Answers (1)

Teemu
Teemu

Reputation: 23396

You've a quoting error in the value of the onclick attribute:

<a href="" onclick="DisplayContactDetail("http://www.cigna.com")">

Should be for example:

<a href="" onclick="DisplayContactDetail('http://www.cigna.com')">

Also Function should be function, JS is case-sensitive.

Upvotes: 4

Related Questions