I'm creating an interface that will take data from 2 different databases, feed that data to the interface and use the interface to determine which piece of information will be stored into a new database. (Basically creating a system to merge databases but the user gets to choose what data gets passed to the new database.) In this interface there would also be a text box so the user can input the data in case both databases have the incorrect data.
Currently I'm working with the part of the 2 databases only and wanted to implement a type of checkbox system where the user would check one box to choose the data and if they wanted the other one the previous checked box would go to false.
I found a way to do it but it would take the whole form in and once you tried it with another table row it would crash. I wanted to try and make the JS independent for each table row. Is there a way to implement such a mechanism to each row? This is my current code: (Ps. The HTML used to be a PHP file)
HTML:
<html>
<head>
<script src="jquery-1.12.4.min.js"></script>
<script src="formAdd.js"></script>
<link rel="stylesheet" type="text/css" href="dbInfo.css">
<title>Database 1</title>
</head>
<body>
<form name="contactform" method="post" action="">
<table id="Forms" width="100%">
<col width="10%" >
<col width="30%" >
<col width="30%" >
<col width="30%" >
<tr>
<th style="background-color:#7FCCCC"> Fields </th>
<th style="background-color:#7FCCCC"> DB 1 </th>
<th style="background-color:#7FCCCC"> DB 2 </th>
<th style="background-color:#7FCCCC"> DB Nueva </th>
</tr>
<tr style="background-color:#CCCCCC">
<td style="font-weight:bold"> Fecha UTC </td>
<td> <input type="checkbox" name="FechaUTC1" onclick="CopyF(this.form)" value="September 14" align="right"> September 14 </td>
<td> <input type="checkbox" name="FechaUTC2" onclick="CopyF2(this.form)" value="November 17" align="right"> November 17 </td>
<td> <input type="text" name="FechaUTC3" size="60"> </td>
</tr>
</table>
<!-- <tr>
<td style="font-weight:bold"> Fecha Local </td>
<td> <input type="checkbox" name="FechaLoc1" onclick="CopyFLoc(this.form)" value="<?php echo $test ?>" align="right"> Septiembre 13, 2016 23:06:31 Hora Local </td>
<td> <input type="checkbox" name="FechaLoc2" onclick="CopyFLoc3(this.form)" value="<?php echo $test ?>" align="right"> Noviembre 14 2016 23:06:31 Hora Local </td>
<td> <input type="text" name="FechaLoc3" size="60"> </td>
</tr>
-->
</table>
<p>
<input type="submit" value="Submit">
</p>
</form>
</body>
</html>
JS:
function CopyF(f) {
if(f.FechaUTC1.checked == true) {
f.FechaUTC3.value = f.FechaUTC1.value;
if(f.FechaUTC2.checked == true)
f.FechaUTC2.checked = false;
}
}
function CopyF2(f) {
if(f.FechaUTC2.checked == true) {
f.FechaUTC3.value = f.FechaUTC2.value;
if(f.FechaUTC1.checked == true)
f.FechaUTC1.checked = false;
}
}