Click to See Complete Forum and Search --> : Looking at this example.


Burrow
04-20-2003, 07:06 PM
I'm looking at the following example code to make sure that I'm doing everything correctly.

Code from DevGuru site:
-----------------------------
function describeAge(obj)
{
if(obj.year < 1996)
return "Old-fashioned"
else
return "Good-as-new"
}

function car(make, year, description)
{this.make = make, this.year = year, this.description = describeAge(this)}

myCar = new car("Ford", "1993", describeAge(this))
-----------------------------

Just that code if I am correct would not create any visable data, to be shown on the page.

First off though in the function car, the this.description = describeAge(this), wouldn't (this), be (obj). Aren't you wanting to call upon that function to get the description?

Anyway you would create another function to actually have it display something on the screen in I am correct. Aren't I?

Also, just as a clarification.
The parameters are what I want the return values to be?
And if I want to change those parameters within a script I'd use return (Variable name) correct?

ie-

function AgeDifference(YourCarAge)
{
Age= (11 - YourCarAge);
return Age;
}

function ShowAge()
{
var YourCarAge=prompt("Your Car Age Is?","");
var myCarAge= AgeDifference(Age);

document.writeln("The Difference is " + YourCarAge + " years.");
}

Burrow
04-20-2003, 07:35 PM
Ahh,

I see.

thanks.

Burrow
04-20-2003, 07:47 PM
This is kinda silly and all,

but how do you declare variables for radio buttons in the same name group?

ie.

Button1 = document.(Form Name).(Radio Button Name)[(Number in Array)]?

so would,
<form name="ButtonForm">

<input type="radio" name="Buttons" value="1">Button 1<br>
<input type="radio" name="Buttons" value="2">Button 2<br>
<input type="radio" name="Buttons" value="3">Button 3

</form>

those 3 be defined as

var Button1 = document.ButtonForm.Buttons[0];
var Button2 = document.ButtonForm.Buttons[1];
var Button3 = document.ButtonForm.Buttons[2];


I think that's wrong, but I'm not sure where exactly.