Solved

javascript

Posted on 2011-09-09
2
258 Views
Last Modified: 2012-05-12
I have the following java-script codes. it is working fine with alert msg.
I would like to stop alert msg and show the msg on the webpage
like
<body>
<span>something wrong</span>
</body>

Is that possible? Please show me how to do it. Thanks


function handleErrors() {
        if (gdir.getStatus().code == G_GEO_UNKNOWN_ADDRESS)
            alert("Error code: " + gdir.getStatus().code);
        else if (gdir.getStatus().code == G_GEO_SERVER_ERROR)
            alert("Error code: " + gdir.getStatus().code);
        else if (gdir.getStatus().code == G_GEO_MISSING_QUERY)
            alert("Error code: " + gdir.getStatus().code);
        else if (gdir.getStatus().code == G_GEO_BAD_KEY)
            alert("Error code: " + gdir.getStatus().code);
        else if (gdir.getStatus().code == G_GEO_BAD_REQUEST)
            alert("A directions request could not be successfully parsed.\n Error code: " + gdir.getStatus().code);
        else alert("An unknown error occurred.");

    }
0
Comment
Question by:Webboy2008
2 Comments
 
LVL 82

Accepted Solution

by:
leakim971 earned 500 total points
ID: 36514317
<span id="span_ID" >something wrong</span>

function handleErrors() {
        if (gdir.getStatus().code == G_GEO_UNKNOWN_ADDRESS || gdir.getStatus().code == G_GEO_SERVER_ERROR || gdir.getStatus().code == G_GEO_MISSING_QUERY || gdir.getStatus().code == G_GEO_BAD_KEY)
        {
            document.getElementById("span_ID").innerHTML = "Error code: " + gdir.getStatus().code;
        }
        else if (gdir.getStatus().code == G_GEO_BAD_REQUEST)
        {
            document.getElementById("span_ID").innerHTML = "A directions request could not be successfully parsed.\n Error code: " + gdir.getStatus().code;
        }
        else
        {
            document.getElementById("span_ID").innerHTML = "An unknown error occurred.";
        }
}

Open in new window

0
 

Author Comment

by:Webboy2008
ID: 36514433
http://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/Q_27300973.html

Thanks, I have another easy question and see you have time for helps.
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
SQL Login 17 38
SQL Exceptions 3 37
highcharts wont fix inside a bootstrap modal window 6 27
bootstrap footer centering and columns alignement 3 16
Having worked on larger scale sites, we found out that you are bound to look at more scalable solutions to integrating widgets, code snippets or complete applications and mesh them into functional sites, in any given composition. To share some of…
Boost your ability to deliver ambitious and competitive web apps by choosing the right JavaScript framework to best suit your project’s needs.
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

911 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

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now