Click to See Complete Forum and Search --> : Question about changes.


Burrow
04-19-2003, 06:30 PM
My question this time, is a simple biscuit one.

I have a selection of radio buttons each onClick loading a function that has a number of preset values.

Anyway, every time that I click this and it loads the new function, is that refreshing all the variables from before?

I have about 10 different functions with the EXACT same variables only different values for them, and what I'm asking is say in one the total is 10 well I click on another where the value is 30, does the 10 then become 30 or does something funky happen with it?

Thanks.

khalidali63
04-19-2003, 07:09 PM
:confused:

would you like to post the code you are talking about...

Burrow
04-19-2003, 07:39 PM
I figured out the problem yeah, it reloads. But here's basically what I'm talking about (The Real code is like 10 pages long)

<script>

function Number1()
{

Number= "10";

}

function Number2()
{

Number= "30";

}

function ShowMe()
{

document.writeln(Number);

}

</script>

<body>

<form>

<input type="radio" name="Number" value="10" onClick="Number1();">10<br>
<input type="radio" name="Number" value="30" onClick="Number2();">30<br><br>

<input type="button" name="Button" value="Show Me da Number" onClick="ShowMe();">

</form>


All I wanted to know was if when I clicked on the submit button that it would change to either 10 or 30, and wouldn't come out being a weird number like 40 or 20.

Jona
04-19-2003, 07:44 PM
Put this before any functions in your code:

var Number;

havik
04-20-2003, 01:04 PM
it's probably a good idea to have a default value too, otherwise you could get errors attempting to write it when no value exists.

Havik

Burrow
04-20-2003, 01:12 PM
hmm..

Okay, That would make it better and far more easy, so I'll go and rescript it, cause it's not working now.


Grr....

Seperately they all work perfectly.
Together they don't work at all.