tags:

views:

48

answers:

2

hi,

I have a funtion like this

<script type="text/javascript">
function result()
{
   return "string";
}
</script>

I need to get this string value in to var

var gotresult= ???? how to get here that result value

+5  A: 

Fix your HTML to use the correctish MIME type (text/javascript), spell return and function (thanks Rob) correctly then just replace your question marks with result().

David Dorward
ooh ooh ooh! And spell function correctly
Rob Fonseca-Ensor
yes its my typo..
kumar
Sorry I know its stupid questions to ask but sometimes gives lot of probs....:)
kumar
A: 

Are you simply talking about var gotresult = result();? Or does that not work for some reason?

Mike
Yes i ma not getting the resul?
kumar
@kumar - how do you know that?
Daniel Earwicker
I am keeping the alert(gotresult).. its showing undefinedthanks
kumar
My funtion is something like this..function result() { $("#Grid1").click(function(e) { var row = jQuery(e.target).parent(); var value= row.attr("id"); return value; }); }
kumar
As you can see, there are two functions. Your return value is in the inner function and is executed in the click event handler. The outer function just defines the event handler and returns nothing, hence the undefined.
edwin