Showing posts with label hyperlink. Show all posts
Showing posts with label hyperlink. Show all posts

Wednesday, March 21, 2012

Trouble with initiating a javascript function with a hyperlink

I have a page that is using ajax (javascript) to connect to a web service which does a number of back end features and then returns a value. This is being initiated from a hyperlink. I am having a hard time with the correct syntax for this. I am hoping for some help. The communication with the webservice works. I am just having trouble with the javascript syntax.

The link is as follows:

<a href="http://links.10026.com/?link=javascript:SubmitVote(1488,7cb84341-9a9f-4cd5-a714-550879c3dfa2);">Vote</a>

I want it to work with the following script (which has been simplified):

<

scriptlanguage="javascript"type="text/javascript">

<!--

function

SubmitVote(Num1, String1) {

funcRut = SubmitVote.SubmitVote(Num1.value, String1.value, OnComplete, OnTimeout, OnError);

return

true;

}

function

OnComplete(value) {

alert(value);

}

function

OnTimeout(value)

{

alert(

"OOPS - Timeout");

}

function

OnError(value)

{

alert(

"Oops - ERROR");

}

// -->

</

script>

Thank you kindly.

Hi,

i think you have just forgotten two single quotes for the second parameter:

<a href="http://links.10026.com/?link=javascript:SubmitVote(1488,'7cb84341-9a9f-4cd5-a714-550879c3dfa2');">Vote</a>

Regards
Marc Andre


Danke Marc. I knew it had to be something simple...it always is. I appreciate the effort.