Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Simple HyperLink to alert function..? 2

Status
Not open for further replies.

werD420

Technical User
Sep 14, 2004
181
US
Code:
<script language="javascript">
  funtion Termed(){
  alert('Termed Client');
 }
</script>
<a href="javascript:void(0)" onclick="Termed();"

I receive the error expected ; Im an asp buff but kinda dumb on javascript what am i doing wrong?
 
Thanks for the response.. Yes I definately left out the c in function.. but for some reason i still get the same error

Updated code
Code:
 <script language="javascript">
  function Termed(){
  alert('Termed Client');
 }
</script>

<a href="javascript:void(0) onclick="Termed();"
Thanks for the reply
 
<a href="javascript:void(0) onclick="Termed();">test</a>
 
You have left out the closing quote in your anchor tag. Additionally, you haven't closed your anchor tag.

One thing that I've noticed is that in your first post the closing quote WAS in the anchor tag. It would probably be helpful for you to *paste* your code instead of trying to retype it to demonstrate, cause it seems that things are getting left out when you retype your code.

For example, modifying your code, this will work fine (try typing it into a new .html file):
Code:
<script language="javascript">
  function Termed(){
  alert('Termed Client');
 }
</script>

<a href="javascript:void(0)[b][COLOR=red]"[/color][/b] onclick="Termed();"[b][COLOR=red]>test</a>[/color][/b]

-kaht

...looks like you don't have a job, so why don't you get out there and feed Tina.
headbang.gif
[rockband]
headbang.gif
 
sorry but my problem with recreating the hyperlink is that this page isn't written in html its pulling a list of names, hyperlinks, and whatnot out of an xml page and displaying this through an xsl stylesheet(notice the copy patedness :)of the javascript function). I
was placing the link in the xml data page so i had to avoid quotes
ie.
Code:
 javascript:void(0)&quot;onclick and all that jazz
.. my attempts were to find the neccessary output syntax.. which i tried the above and still got the same error.. i ended up just using
Code:
<a href="javascript:Termed();">Test</a>..
Is there a problem with doing it this way? the page is very simple in nature and wont have any other javascript in it
 
Sure, or this and lose the function.
Code:
<a href="javascript:alert('Termed Client')">Test</a>
 
Hey all another question is it possible to run a confirm on redirect url

ie.
Code:
<a href="javascript:confirm('A dumb site.Are you Sure','[URL unfurl="true"]http://www.google.com','self')>A[/URL] dumb Site</a>
 
One way:
Code:
<script language="javascript">
  function Termed(){
    if(confirm('A dumb site.Are you Sure')){
       location.href='[URL unfurl="true"]http://www.google.com';[/URL]
    }
  }
</script>

<a href="javascript:Termed()">test</a>
Another way:
Code:
<script language="javascript">
  function Termed(){
    return confirm('A dumb site. Are you Sure');
  }
</script>

<a href="[URL unfurl="true"]http://www.google.com"[/URL] onclick="[b]return[/b] Termed()">test</a>

Adam
 
ok...

I have the following xsl code
Code:
<xsl:for-each select="list">
<script language="javascript">
function checknum(){
<xsl:for-each select="list/line/Cell">

<xsl:if test="Control">
if (document.board.pn.value=="{Control}"){
if(confirm("You are about to view a {product} Client")){
       location.href={link};
    }
  }

</xsl:if>
</xsl:for-each>
return false;
}

</script>
</xsl:for-each>

The final output would look something like this
Code:
<script language="javascript">
function checknum(){
if (document.board.pn.value=="11111"){
if(confirm("You are about to view a FSA Client")){
       location.href=[URL unfurl="true"]http:///www.google.com;[/URL]
    }
  }
return false;
}
</script>

Somewhere i am getting an error that says expected ":"

Is there an error in the above javascript or do i need to look more at the xsl.. Thanks
 
When i change to a different display method

ie..
location.href=<xsl:value-of select="link"/>;

I get the error expected ";"
 
Are you putting the link in quotes?
ie..
location.href=[red]'[/red]<xsl:value-of select="link"/>[red]'[/red];

Adam
 
Yes.. now i was not but have since corrected.. my issue seems to be with my method for calling the function i would like to call it from a form when enter is pressed and then redirect if they hit ok.. this issue is addressed and explained a little more in my other post..

Thanks
Drew
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top