Jump to content

can a function be inside another function?


frozentree

Recommended Posts

erm.....can anyone help me here? am having problem with the .......function.guys, trying so hard but cant think of anything anymore that need to repair this script. me try to make the input value and when u click the second button. it should show the output value. well i did follow some example but wanna see how far it can go somemore.<html><head><script type="text/javascript">function mainpart (text){ref="0123456789abcdefghijklmnopqrstuvwxyz-~ABCDEFGHIJKLMNOPQRSTUVWXYZ"result="" ;for(kira=0;kira<text.length;kira++){firstrow=text.substring(kira,kira+1) secondrow=ref.indexOf(firstrow) thirdrow=ref.substring(secondrow+1,secondrow+2) result+=thirdrow}function extendedpart(gg){return (document.grass.magic.value=result)}}</script></head><body><form name="grass">check this::<input type=text name="text"><input type=button value="send" onclick="mainpart (document.grass.text.value)"><br>appear here::<input type=text name="magic"><input type=button value="recieving" onclick="extendedpart(document.grass.magic.value)"></form></body></html>

Link to comment
Share on other sites

Guest Sanjeewa

Yes dude u can inside another function:example :function name(){function age() { /* add ur statements */}}then if you want to call the age function first of all call name and call age.. :)

Link to comment
Share on other sites

if can make this happen....then how do i call the main function ---> function name() followed by function age() ?? i try this<head><script type="text/javascript">function watchtree(a,b,c,d){ winter= a+b+c-d ; function ball(winter) { return(winter) }}</script></head><body>document.write(watchtree(ball(2,2,2,2)))</body>

Link to comment
Share on other sites

Yes dude u can inside another function:example :function name(){function age() { /* add ur statements */}}then if you want to call the age function first of all call name and call age.. :)

or you could do this which is much easier
function name(){   age();}function age(){}

That way you can call age() directly very easily

Link to comment
Share on other sites

if can make this happen....then how do i call the main function

I wouldn't put a function inside another, that's just messy, try something like this
<head><script type="text/javascript">function watchtree(a,b,c,d){  winter=a+b+c-d;  winter=ball(winter);  return winter;}function ball(winter){   z=winter+10;  return(z);}</script></head><body><script type="text/javascript">  var result=watchtree(2,2,2,2);  document.write(result);</script></body>

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...