Click to See Complete Forum and Search --> : Have a final question


Burrow
04-17-2003, 08:00 PM
Okay,

This is the biggest question that I will ask, and it will also be the hardest as I have no script I am able to show you.


I am creating a stat rolling program for a game, you may have seen my previous post, and I am going to have some I think it's 8 or so different classes ranging from 5 or 6 different races. Not a lick of that is important though.

Anyway, I am going to be creating this solely for myself and associates to use, It doesn't have to be completely user friendly or anything, but I am going to have all of these selections of classes and such set up in a table with radio buttons that are holding my functions data and all that good stuff.

I have already figured all that out, but my first question relates to how to get that data that I selected to another frame set up on my page, using a submit button it just reloads upon the same page like it's supposed to.

And my second question is after I have completed all this and gotten the data over to the other frame, so I can see that I am using to correct class/race, how can I change the preset data that is set up with that particular race to change the variables that are in place by default.


Here:

There are some attributes that I will have, some races/classes will get bonuses. By default the total points are multiplied by one, what I want is to be able to say do this.

var Total= 30;
var Cats= 8;
var Multi= Total/Cats;

var Acc= Math.floor((Math.round() * Multi) + 1);
var AccMul= 1 (By Default);
var Accuracy= Acc + ( AccMul * Acc);

What I want to do, is change the AccMul, to it's corrosponding value. Ugh, this is turning out really ugly and it's confusing to me, so I know it's confusing to you. Well, I can't really explain it better than that, so it's not really important, but if you can help, thanks.

DrDaMour
04-17-2003, 08:07 PM
you can target a form action is fthat's what you mean:

<form action="punk you" target="frame">


but i don't think you want to post the data to teh frame, as that require some server side information.

say your frame name is killer <iframe id="killer">
and it has var total;



in the parent
document.all.frames.killer.document.total
will be the same objects as total in the frame killer, see that's how they can talk to each other


so say in killer you have this function calculate() which calculates teh forms based on the variables, well then in the parent
document.all.frames.document.calculate() will run that function in the killer frame.

what you need to understand is the child parent relations ship
think of real life, you are the child of your mom and she is your parent, but she's the child of your grandma. think of the . operator as the generation gap.

so total is the child, and it's parent is killer, killer is the child of parent document. document is the child of parent killer (it's fframe) and killer is the child of the parent frames, and frames is the child of parent all, and all is the child of parent document which is actually the child of window, but that isn't needed as document is a keyword. basically you have to start a keyword, otheriwse the browser won't know where to go.

Burrow
04-17-2003, 09:01 PM
ah,

okay, thanks.

DrDaMour
04-17-2003, 09:03 PM
is that an ok i get it, or ok i need more help? :)

Nedals
04-17-2003, 09:26 PM
To transfer 'formOne' data in frameOne to 'formTwo' in frameTwo...

<script>
function movit() {
top.frameTwo.document.formTwo.fieldname.value = document.formOne.fieldname.value;
... change default settings...
return false
}
</script>

<form name="formOne" onSubmit="return moveit()">
<input....>
</form>

I don't really understand part 2, but, I think, you could change your default settings within the movit function

Burrow
04-17-2003, 09:27 PM
tiny bit of both. :D

No, I'm pretty sure I get it.
I'm just really tired right now, so I'll just look it over in the morning.

DrDaMour
04-17-2003, 10:04 PM
hey man, i wasn't completely sure about that syntax i gave you,a nd of course i was wrong. But it was interesting to learn where the variables in a page are actually at based off of a keyword.

this is what i found

your main page has <iframe id="car"/>

car has a variable:
var test = 1;

and method
function yes(){
alert(test);
}

say your main page has a button with onclick even that updates the value of test, adn calls yes. it will look like this

onclick="document.frames.car.test += 1;document.frames.car.yes()"

so basically all is not needed and the second document is not needed, which makes sense cause document is akeyword, so taht would really screw things up...

anyways, that should help you, one thing if you'r enot using an iframe and using a standard frameset then you'll have to use parent keyword.

Burrow
04-18-2003, 11:40 AM
good, good.

It makes more sense now that I got sleep. Thanks for the help.