Click to See Complete Forum and Search --> : copy fields using button


twixy2k
03-18-2003, 09:40 AM
Thanks for your help before but i'm stuck and wondered if anyone could explain this to me abit, Thanks
I've got six text boxes going into two text boxes. I have three checkboxes that copy down the two of the first four text boxes when clicked. I've included a diagram that shows how i want to it to work pref. How it is now is with checkboxes instead of buttons. Thanks

<!-- Begin
var mtoprice3 = "";
var otherprice3 = "";


function InitSaveVariables(form) {
mtoprice3 = form.mtoprice3.value;
otherprice3 = form.otherprice3.value;

}

function madetomeasure(form) {
if (form.copy.checked) {
InitSaveVariables(form);
form.mtoprice3.value = form.mtoprice.value;
form.otherprice3.value = form.otherprice.value;

}
else {
form.mtoprice3.value = mtoprice3;
form.otherprice3.value = otherprice3;

}
}
// End -->

<!-- Begin
var mtoprice3 = "";
var otherprice3 = "";


function InitSaveVariables(form) {
mtoprice3 = form.mtoprice3.value;
otherprice3 = form.otherprice3.value;

}

function standard(form) {
if (form.copy2.checked) {
InitSaveVariables(form);
form.mtoprice3.value = form.mtos.value;
form.otherprice3.value = form.others.value;

}
else {
form.mtoprice3.value = mtoprice3;
form.otherprice3.value = otherprice3;

}
}
// End -->




<!-- Begin
var mtoprice3 = "";
var otherprice3 = "";


function InitSaveVariables(form) {
mtoprice3 = form.mtoprice3.value;
otherprice3 = form.otherprice3.value;

}

function nextup(form) {
if (form.copy3.checked) {
InitSaveVariables(form);
form.mtoprice3.value = form.mtoprice.value;
form.otherprice3.value = form.otherprice.value;

}
else {
form.mtoprice3.value = mtoprice3;
form.otherprice3.value = otherprice3;

}
}
// End -->

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

<INPUT type="checkbox" name="copy"
onClick="javascript:madetomeasure(this.form);" value="checkbox">
<INPUT type="checkbox" name="copy2"
onClick="javascript:standard(this.form);" value="checkbox">
<INPUT type="checkbox" name="copy3"
onClick="javascript:nextup(this.form);" value="checkbox">

Thanks
Alan

cyberade
03-18-2003, 10:47 AM
Try this.


<html>
<head>
<title>No Title</title>
<script type="text/javascript" language="javascript">
<!-- Begin
var buttons= new Array(0,0,0);
var mtoprice3 = "";
var otherprice3 = "";


function InitSaveVariables(form) {
mtoprice3 = form.mtoprice3.value;
otherprice3 = form.otherprice3.value;

}

function madetomeasure(form) {
if (buttons[0]==1) {
InitSaveVariables(form);
form.mtoprice3.value = form.mtoprice.value;
form.otherprice3.value = form.otherprice.value;

}
else {
form.mtoprice3.value = mtoprice3;
form.otherprice3.value = otherprice3;

}
}
// End -->

<!-- Begin

function standard(form) {
if (buttons[1]==1) {
InitSaveVariables(form);
form.mtoprice3.value = form.mtos.value;
form.otherprice3.value = form.others.value;

}
else {
form.mtoprice3.value = mtoprice3;
form.otherprice3.value = otherprice3;

}
}
// End -->




<!-- Begin

function nextup(form) {
if (buttons[2]==1) {
InitSaveVariables(form);
form.mtoprice3.value = form.mtoprice.value;
form.otherprice3.value = form.otherprice.value;

}
else {
form.mtoprice3.value = mtoprice3;
form.otherprice3.value = otherprice3;

}
}
// End -->
</script>
</head>


<body>
<form>
<table border=0>
<tr><td>
<input type="text" name="mtoprice" value="mtoprice1"></td><td>
<input type="text" name="otherprice" value="otherprice1"></td><td>
<BUTTON name="button1" onClick="javascript:buttons[0]=1;madetomeasure(this.form);" >BUTTON 1</BUTTON></td></tr>
<tr><td>
<input type="text" name="mtos" value="mtoprices"></td><td>
<input type="text" name="others" value="otherprices"></td><td>
<BUTTON name="button2" onClick="javascript:buttons[1]=1;standard(this.form);">BUTTON 2</BUTTON></td><tr>
<td id="mtoprice1">text3</td>
<td id="otherprice1">no box</td><td>
<BUTTON name="button3" onClick="javascript:buttons[2]=1;nextup(this.form);">BUTTON 3</BUTTON></td>
</tr>
</table>
<br><br>
<input type="text" name="mtoprice3" value=" ">
<input type="text" name="otherprice3" value=" ">
</form>
</body>
</html>