Reiss
07-08-2009, 07:46 AM
Hi All,
Im new to javascript, but I've learned to write a function that copies the values of 1 text input (day1_00) to another (day2_00)
like this -
function data_copy()
{
document.itinerary.day2_00.value=document.itinerary.day1_00.value;
}
<a href="#" onclick="data_copy()">©</a>
The above code works fine, but what I would like to do is make the function more dynamic as I have to repeat it a lot but can't seem to find the correct syntax for something like this -
function data_copy(day1,day2)
{
document.itinerary.(day1).value=document.itinerary.(day2).value;
}
<a href="#" onclick="data_copy(day1_00,day2_00)">©</a>
obviously the above doesn't work, so how do I pass the values and use them in my function?
many thanks
Im new to javascript, but I've learned to write a function that copies the values of 1 text input (day1_00) to another (day2_00)
like this -
function data_copy()
{
document.itinerary.day2_00.value=document.itinerary.day1_00.value;
}
<a href="#" onclick="data_copy()">©</a>
The above code works fine, but what I would like to do is make the function more dynamic as I have to repeat it a lot but can't seem to find the correct syntax for something like this -
function data_copy(day1,day2)
{
document.itinerary.(day1).value=document.itinerary.(day2).value;
}
<a href="#" onclick="data_copy(day1_00,day2_00)">©</a>
obviously the above doesn't work, so how do I pass the values and use them in my function?
many thanks