Click to See Complete Forum and Search --> : assigning value


Burrow
04-21-2003, 07:35 PM
<script>

function Car(Make,Model,Year)
{

this.Make=Make;
this.Model=Model;
this.Year=Year;

}


new Car("Ford","Tempo","1988");
new Car("Dodge","Ram","2003");
new Car("AMC","Gremlin","1980");

</script>

<body>

<form name="Cars">
<input type="radio" name="Car" value=(Problem)>Tempo<br>
<input type="radio" name="Car" value=(Problem)>Ram<br>
<input type="radio" name="Car" value=(Problem)>Gremlin<br><br>
</form>

</body>

------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

Alright my first question is as you see there are three radio buttons there each with their respective car title next to them.

Any way as you see above the body is a function that calls upon one of the three new Car("Make","Model","Year"); strings.

Anyway, what I need is to set each one of those new Car("Make","Model","Year"); to the value of its respective radio button. I'm not quite sure that it's even possible.

Any help is greatly appreciated.

DrDaMour
04-21-2003, 08:08 PM
you mean you'll have three sets of radio buttons, that will corrospond to those 3 car values?

Jona
04-21-2003, 08:50 PM
Change the value of each radio button to its respective model. Then use onClick="if(this.value=='Tempo'){var myCar = new Car('Ford',this.value,'1988');}else if(this.value=='Ram'){myCar = new Car('Dodge',this.value,'2003');else{myCar = new Car('AMC',this.value,'1980');}"

Burrow
04-21-2003, 10:36 PM
would it be simpler to just set up a function to carry out the process of finding which is checked?

Or would that just botch things up for a realitively inexperienced scripter?

oh, and thanks for the help so far.

Jona
04-21-2003, 10:46 PM
Well, hopefully you could read the code. ;) But anyways, yes you could do that... But then the problem would be, you'd have to also have other elements in the form on which to base the make and year, not just the model.

Burrow
04-22-2003, 05:13 PM
I see.

Okay, that makes more sense once I look at the larger picture, of what I'm scripting.
Thanks for the help.

Jona
04-22-2003, 05:17 PM
It's always good to be of help! :)