I have an application like this. I need to validate the start time in 2nd row against the start row in first row. I mean The start time value entered in the second row must not b the value entered in 1st and the value entered in 3rd must not b the value entered in 1st,2nd etc.. like this. Please tell me how it can be done. I'm sending the code here. Its a html file. Just copy paste the code and run to execute it and see how it works.
[HTML]<html><head><ti tle>Time Sheet Entry</title>
</head>
<body>
<center><h2>Tim e Sheet Details </h2></center>
<br><br>
<Script>
var INPUT_NAME_PREF IX = 'inputName';
var TABLE_NAME = 'tblSample';
var headerRows;
window.onload=f illInRows;
function fillInRows()
{
headerRows = document.getEle mentById(TABLE_ NAME).rows.leng th;
addRowToTable(' this could be set to something but I don\'t currently use it in addRowToTable') ;
addRowToTable() ;
}
// CONFIG:
// myRowObject is an object for storing information about the table rows
function myRowObject(one , two, three, four) {
this.one = one; // text object
this.two = two; // input text object
this.three = three; // input checkbox object
this.four = four;
}
function addRowToTable(v al)
{
var tbl = document.getEle mentById(TABLE_ NAME);
var nextRow = tbl.rows.length ;
var iteration = nextRow - parseInt(header Rows) + parseInt(1);
// add the row
var row = tbl.insertRow(n extRow);
// CONFIG: This whole section can be configured
// cell 0 - check box select delete
var cell0 = row.insertCell( 0);
var cb = document.create Element('input' );
cb.setAttribute ('type', 'checkbox');
cb.setAttribute ('name', INPUT_NAME_PREF IX + iteration);
//txtInp.setAttri bute('size', '10');
cell0.appendChi ld(cb);
// cell 1 - select WBS code
var cell1 = row.insertCell( 1);
var cb0 = document.create Element('select ');
cb0.setAttribut e("name","wbsco de");
cb0.setAttribut e("id","lesslen gth");
Opt01=document. createElement(" option");
Opt01.setAttrib ute("id","wbs1" );
Opt01.setAttrib ute("value","wb s1");
Opt01.appendChi ld(document.cre ateTextNode("wb s[0]"));
Opt02=document. createElement(" option");
Opt02.setAttrib ute("id","wbs2" );
Opt02.setAttrib ute("value","wb s2");
Opt02.appendChi ld(document.cre ateTextNode("wb s[1]"));
cb0.appendChild (Opt01);
cb0.appendChild (Opt02);
cell1.appendChi ld(cb0);
// cell 2 - input text Start Time
var cell2 = row.insertCell( 2);
var txtInp = document.create Element('input' );
txtInp.setAttri bute('type', 'text');
txtInp.setAttri bute('name', INPUT_NAME_PREF IX + iteration);
txtInp.setAttri bute('size', '10');
cell2.appendChi ld(txtInp);
// cell 3 - Text End time
var cell3 = row.insertCell( 3);
var btn = document.create Element('input' );
btn.setAttribut e('type', 'text');
btn.setAttribut e('name', INPUT_NAME_PREF IX + iteration);
btn.setAttribut e('size', '10');
cell3.appendChi ld(btn);
row.myRow = new myRowObject(cb, cb0,txtInp,btn) ;
}
// CONFIG: this entire function is affected by myRowObject settings // If there isn't a checkbox in your row, then this function can't be used.
function deleteChecked()
{
var checkedObjArray = new Array();
var cCount = 0;
var tbl = document.getEle mentById(TABLE_ NAME);
for (var i=0; i<tbl.rows.leng th; i++) {
if (tbl.rows[i].myRow && tbl.rows[i].myRow.one.getA ttribute('type' ) == 'checkbox' && tbl.rows[i].myRow.one.chec ked) {
checkedObjArray[cCount] = tbl.rows[i];
cCount++;
}
}
if (checkedObjArra y.length > 0 ) {
var rIndex = checkedObjArray[0].rowIndex;
deleteRows(chec kedObjArray);
reorderRows(tbl , rIndex);
}
}
function reorderRows(tbl , startingIndex) {
if (tbl.rows[startingIndex]) {
var count = startingIndex;
for (var i=startingIndex ; i<tbl.rows.leng th; i++) {
// CONFIG: next line is affected by myRowObject settings
tbl.rows[i].myRow.one.data = count; // text
// CONFIG: next line is affected by myRowObject settings
tbl.rows[i].myRow.two.name = INPUT_NAME_PREF IX + count; // input text
// CONFIG: next line is affected by myRowObject settings
//var tempVal = tbl.rows[i].myRow.two.valu e.split(' '); // for debug purposes
//tbl.rows[i].myRow.two.valu e = count + ' was' + tempVal[0]; // for debug purposes
count++;
}
}
}
function deleteRows(rowO bjArray)
{
for (var i=0; i<rowObjArray.l ength; i++) {
var rIndex = rowObjArray[i].rowIndex;
rowObjArray[i].parentNode.del eteRow(rIndex);
}
}
function openInNewWindow (frm)
{
// open a blank window
var aWindow = window.open('', 'TableAddRow2Ne wWindow',
'scrollbars=yes ,menubar=yes,re sizable=yes,too lbar=no,width=4 00,height=400') ;
// set the target to the blank window
frm.target = 'TableAddRow2Ne wWindow';
// submit
frm.submit();
}
</Script>
</head><body>
<form action="tablead drow_nw.html" method="post">
<center>
<table border="1" id="tblSample" class="sample">
<tr>
<th >Select</th>
<th >WBS</th>
<th >Start Time</th>
<th >End Time</th>
</tr>
</table>
<p>
<input type="button" value="Add" onclick="addRow ToTable();" class="button" />
<input type="submit" value="Save" onclick="openIn NewWindow(this. form);" class="button" />
<input type="button" value="Delete Selected" onclick="delete Checked();" />
<input type="button" value="Exit" onclick="window .close();" class="button"/>
</p> </center> </form> </html>[/HTML] Please post code using code tags - moderator 1 1872 acoder 16,027
Recognized Expert Moderator MVP
Iterate through the rows (see example of how) and compare the values. You could have a function which goes through each row and compares against the rest until all rows are complete. Alternatively, the function could keep an array of all unique row values and compare against that. If a new value is found, just add to that array.
Sign in to post your reply or Sign up for a free account.
Similar topics |
by: aevans1108 |
last post by:
Greetings All
If this is the wrong place to post this question, please give me a push
in the right direction. Thanks.
I know there has to be a simpler way to do this, but this is as simple
a way as I could come up with. Yes, it's obvious I don't know what I'm
doing.
I'm creating an XSD string and an XML string at runtime (ie: NOT read
|
by: Jeff Evans |
last post by:
I have a custom composite control which has a validator for a textbox. The validator and textbox are declared in the class and created in the CreateChildControls() method
Here is the code for the textbox, in CreateChildControls()
searchBox = new TextBox();
searchBox.ID = "searchBox";
searchBox.EnableViewState = false;
It is then added to a TableCell, which is added to a row, etc.
|
by: Jim Heavey |
last post by:
When should you use the Page.Validate() method? I thought you would use this method if you have some Server side validation (CustomControl's) you wanted to use and this would cause them to be invoked. I am probably wrong about that.
If I am suppose to use this function, the edits seemed to be invoked even when you have pressed the cancel and the "CausesValidation" is set to false. Is there a way to get around this (might just be an...
|
by: webrod |
last post by:
Hi,
I have some php pages with a lot of HTML code.
I am looking for a HTML validator tool (like TIDY).
TIDY is not good enough with PHP tags (it removes a lot of php code).
Do you have any idea?
Thanks you very much
|
by: SkipNRun |
last post by:
I am a novice when comes to JavaScript, AJAX. I am working on a form, which will allow users to update their contact information. In order to make the form flexible, I need to use pull down list.
Depends on the pull down list selection, I use script.aculo.us to validate the user input before submit and pass the necessary data, such as contact type, contact information and ranking to a php program for updating. This form should allow multiple...
| |
by: Mike Hofer |
last post by:
Please forgive the cross-post to multiple forums. I did it
intentionally, but I *think* it was appropriate given the nature of my
question.
I'm working on an open source code library to help automate and clean
up parameter validation code. It's almost ready to go into open beta.
But one last little glitch is holding me up, and that would be the
name of the factory class that serves as the entry point into the
library: Validate.
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
| |
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
| |