pallilu
asked on
Design form question:Online form with multiple text boxes for meter No and MeterIN/OUT selection boxes. When user submits with info filled then the records should be there in db for each the meterNo
The online form will allow employees to enter the meter information.
Employee will enter EmployeeID, Select region from drop down, Select dates from dropdown, and enter Meter No and select MeterIN/OUT(sometime employee will have 20 meters at a time and they have to enter meter no's and select MeterIN/OUT.) with same Employee ID and region information.
My suggestion was to give 5 text boxes for the Meter No's and and Selection for MeterIN/OUT.
If they have more, They will load 2nd time form and enter employee Id , region,dates and meterno's
Please help me , if you have any better ideas to perform this requirement succesfully.
I have to create a new form and new database. I will appreciate, if you can give datbase suggestion also. I am thinking of Access database. Please help me with database structure for the feilds.
Please give me suggestions, How to design the form and database with this kind of requirement.
I will really appreciate your help on this
Thank
Suruku
Employee will enter EmployeeID, Select region from drop down, Select dates from dropdown, and enter Meter No and select MeterIN/OUT(sometime employee will have 20 meters at a time and they have to enter meter no's and select MeterIN/OUT.) with same Employee ID and region information.
My suggestion was to give 5 text boxes for the Meter No's and and Selection for MeterIN/OUT.
If they have more, They will load 2nd time form and enter employee Id , region,dates and meterno's
Please help me , if you have any better ideas to perform this requirement succesfully.
I have to create a new form and new database. I will appreciate, if you can give datbase suggestion also. I am thinking of Access database. Please help me with database structure for the feilds.
Please give me suggestions, How to design the form and database with this kind of requirement.
I will really appreciate your help on this
Thank
Suruku
I'm not too sure how to use Access as a database. Can you tell us which scripting language (i.e. PHP, ASP, JSP, etc.) you're planning to use?
ASKER
I guess ASP. I am planning on using ASP and Access database.
Please Suggest me with alternatives
Thanks
Pallilu
Please Suggest me with alternatives
Thanks
Pallilu
I am more familiar with PHP than ASP. However, I also recommend using a database like mySQL with ASP also. First of all, I doubt many webhosts support Access unless you are on your own server. Secondly, mySQL is generally one of the easiest databases to learn, and for that reason, tons of supplementary material is posted on it. You need only to search 'ASP + mySQL' on Google to discover many resources.
That is my suggestion.
However, if you seriously wish to stick to Access, I believe I can read some material on it and help you. Can you elaborate a bit on what you are trying to accomplish, such as what database fields you believe you will need. Also, if you would care to explain what a meter is (I embarrasingly don't know), I would be grateful lol.
Thanks.
That is my suggestion.
However, if you seriously wish to stick to Access, I believe I can read some material on it and help you. Can you elaborate a bit on what you are trying to accomplish, such as what database fields you believe you will need. Also, if you would care to explain what a meter is (I embarrasingly don't know), I would be grateful lol.
Thanks.
ASKER
Can I explain in detail tomorrow please.
I have tro leave early today.
Thanks for your pateince and suggestions.
Pallilu
I have tro leave early today.
Thanks for your pateince and suggestions.
Pallilu
Oops, sorry about that. I just read COBOL's comment. I won't leave my email anymore. Sorry for the inconvenience.
I would suggest that before the individual starts filling in the form maybe have a box where they enter the number of meters that they have - you can then dynamically generate the page to accomodate say 20 readings - this will also mean that the individual only has to deal with a single page and it means that the form submission only need to be done once.
Hi there,
I'd go for the Access databse. It's a little bit easier to manage. Besides that, you can se an Exchange database with almost any provider (this still is a standard).
For the asp code to be generated, there is a very nice program that's called ASP Maker, tis is an absolute must try... For $39 it's even better in creating web based applications than Macromedias Webdev...
Here's the link.
http://www.hkvstore.com/aspmaker
You can download a 30 days trail, this program does everything it says..
And for all you PHP freaks out there, there also is a php maker version
http://www.hkvstore.com/phpmaker
I'd go for the Access databse. It's a little bit easier to manage. Besides that, you can se an Exchange database with almost any provider (this still is a standard).
For the asp code to be generated, there is a very nice program that's called ASP Maker, tis is an absolute must try... For $39 it's even better in creating web based applications than Macromedias Webdev...
Here's the link.
http://www.hkvstore.com/aspmaker
You can download a 30 days trail, this program does everything it says..
And for all you PHP freaks out there, there also is a php maker version
http://www.hkvstore.com/phpmaker
ASKER
Hey Lord McFly
Can you explain little bit bit more on how to give a Box for entering how many meters users has before entering meterno and Meters In/Out. Should I submit and go back to asp page to decide how many Text boxes to diSplay for the Meters. I like your suggestion, because individual can submit information only once for all meters.
Please provide me the code, If you have any examples. I will really appreciate your help.
Thanks for your suggestion and response.
Can you explain little bit bit more on how to give a Box for entering how many meters users has before entering meterno and Meters In/Out. Should I submit and go back to asp page to decide how many Text boxes to diSplay for the Meters. I like your suggestion, because individual can submit information only once for all meters.
Please provide me the code, If you have any examples. I will really appreciate your help.
Thanks for your suggestion and response.
Ok, I've done a very rough example - but its functional, copy and paste and give it a go.
Basically the user first enters a figure for the no of meter reading they want to enter, say 5 for example. This will then generate a form with name, address or what ever and the 5 lots of boxes for entering the reading. I have also included a quick routine to display the entered data.
Well here you go...
========================== ========== ========== ========== ========== ========== ========== ========== ========== ========== ======
<%@ Language=VBScript %>
<%
Dim iLp
If Request.Form("Action") = "NoMeters" then
Session("NoMeters") = Request.Form("f_0")
Response.Redirect "Meters.asp"
End If
If Request.Form("Action") = "Process" then
For iLp = 0 to 2
Response.Write "Field " & iLp & ": " & Trim(Request.Form("f_"&iLp )) & "<br>"
Next
Response.Write "<br>"
For iLp = 1 to Session("NoMeters")
Response.Write "Meter No: " & Trim(Request.Form("f_0_"&i Lp)) & " // Reading: " & Trim(Request.Form("f_1_"&i Lp)) & "<br>"
Next
Session("NoMeters") = ""
Response.End
End If
%>
<html>
<head>
</head>
<body>
<%If Session("NoMeters") <> "" then%>
<form name="Meter" method="post" action="Meters.asp">
Name: <input type="text" name="f_0" value=""><br>
House: <input type="text" name="f_1" value=""><br>
Phone: <input type="text" name="f_2" value=""><br><br>
<%For iLp = 1 to Session("NoMeters")%>
Meter No: <input type="text" name="f_0_<%=iLp%>" value="">   ;Reading: <input type="text" name="f_1_<%=iLp%>" value=""><br>
<%Next%>
<input type="hidden" name="Action" value="Process">
<input type="submit" name="Button" value="Submit">
</form>
<%Else%>
<form name="Meter" method="post" action="Meters.asp">
<input type="text" name="f_0" value=""><br>
<input type="hidden" name="Action" value="NoMeters">
<input type="submit" name="Button" value="Submit">
</form>
<%End If%>
</body>
</html>
========================== ========== ========== ========== ========== ========== ========== ========== ========== ========== ======
Basically the user first enters a figure for the no of meter reading they want to enter, say 5 for example. This will then generate a form with name, address or what ever and the 5 lots of boxes for entering the reading. I have also included a quick routine to display the entered data.
Well here you go...
==========================
<%@ Language=VBScript %>
<%
Dim iLp
If Request.Form("Action") = "NoMeters" then
Session("NoMeters") = Request.Form("f_0")
Response.Redirect "Meters.asp"
End If
If Request.Form("Action") = "Process" then
For iLp = 0 to 2
Response.Write "Field " & iLp & ": " & Trim(Request.Form("f_"&iLp
Next
Response.Write "<br>"
For iLp = 1 to Session("NoMeters")
Response.Write "Meter No: " & Trim(Request.Form("f_0_"&i
Next
Session("NoMeters") = ""
Response.End
End If
%>
<html>
<head>
</head>
<body>
<%If Session("NoMeters") <> "" then%>
<form name="Meter" method="post" action="Meters.asp">
Name: <input type="text" name="f_0" value=""><br>
House: <input type="text" name="f_1" value=""><br>
Phone: <input type="text" name="f_2" value=""><br><br>
<%For iLp = 1 to Session("NoMeters")%>
Meter No: <input type="text" name="f_0_<%=iLp%>" value="">  
<%Next%>
<input type="hidden" name="Action" value="Process">
<input type="submit" name="Button" value="Submit">
</form>
<%Else%>
<form name="Meter" method="post" action="Meters.asp">
<input type="text" name="f_0" value=""><br>
<input type="hidden" name="Action" value="NoMeters">
<input type="submit" name="Button" value="Submit">
</form>
<%End If%>
</body>
</html>
==========================
ASKER
Hey Lord McFly
I am very sorry, I liked that idea of displaying text box to decide how many text box before form loads.
When I talked tio user he did not want like that. User wants to display 10 textboxes all the time and insert records to the database
according to user input.
Sorry for not telling this before. I wasted your time. I hope you forgive me and provide a solution for inserting records depending uopn user input to the form.
Please help me Lord McFly
Thanks
Pallilu
I am very sorry, I liked that idea of displaying text box to decide how many text box before form loads.
When I talked tio user he did not want like that. User wants to display 10 textboxes all the time and insert records to the database
according to user input.
Sorry for not telling this before. I wasted your time. I hope you forgive me and provide a solution for inserting records depending uopn user input to the form.
Please help me Lord McFly
Thanks
Pallilu
ASKER
Lord McFly
Can you explain for below code how will I insert multiple records for each meter Serail No record
For ex- If user enters 7 meterSerial No and the database should have 7 records with same employee info for each meter no.
Should I use array values or txtMeterNo1,txtMeterNo2,tx tMeterNo3 etc upto txtMeterNo10 and How should I wirte insert statement, if 7 textboxes are entered
I will really appreciate, If you have any sample code to perform this kind of requirement
sEmployeeID = Request.Form("txtEmployeeI D")
sRegion = Request.Form("cboRegion")
sMeterNo = Request.Form("txtMeterNo1" )
sINOUT = Request.Form("MeterINOUT1" )
sSQL= "INSERT INTO GasMeterTrack "
sSQL = sSQL & "(EmployeeID,Region,MeterD ate,MeterS erialNo,St atus)"
sSQL = sSQL & " VALUES ("
sSQL = sSQL & sEmployeeID & ",'"
sSQL = sSQL & sRegion & "',#"
sSQL = sSQL & sDate & "#,"
sSQL = sSQL & sMeterNo & ",'"
sSQL = sSQL & sINOUT & "')"
Thanks
Pallilu
Can you explain for below code how will I insert multiple records for each meter Serail No record
For ex- If user enters 7 meterSerial No and the database should have 7 records with same employee info for each meter no.
Should I use array values or txtMeterNo1,txtMeterNo2,tx
I will really appreciate, If you have any sample code to perform this kind of requirement
sEmployeeID = Request.Form("txtEmployeeI
sRegion = Request.Form("cboRegion")
sMeterNo = Request.Form("txtMeterNo1"
sINOUT = Request.Form("MeterINOUT1"
sSQL= "INSERT INTO GasMeterTrack "
sSQL = sSQL & "(EmployeeID,Region,MeterD
sSQL = sSQL & " VALUES ("
sSQL = sSQL & sEmployeeID & ",'"
sSQL = sSQL & sRegion & "',#"
sSQL = sSQL & sDate & "#,"
sSQL = sSQL & sMeterNo & ",'"
sSQL = sSQL & sINOUT & "')"
Thanks
Pallilu
Ok, how about this - the form has 50 meter reading boxes hidden and there is a single reading reading box - the user enters a reading and then click Add, this displays it underneath, they can then keep adding until their tired - take a look and tell me what you think :)
========================== ========== ========== ========== ========== ========== ========== ========== ========== ========== ======
<%@ Language=VBScript %>
<%
Dim iLp
If Request.Form("Action") = "Process" then
For iLp = 0 to 2
Response.Write "Field " & iLp & ": " & Trim(Request.Form("f_"&iLp )) & "<br>"
Next
Response.Write "<br>"
For iLp = 1 to Request.Form("NoMeters")
Response.Write "Meter No: " & Trim(Request.Form("m_0_"&i Lp)) & " // Reading: " & Trim(Request.Form("m_1_"&i Lp)) & "<br>"
Next
Session("NoMeters") = ""
Response.End
End If
%>
<html>
<head>
<script language="JavaScript">
function AddMeter()
{
var i
document.Meter.NoMeters.va lue = parseInt(document.Meter.No Meters.val ue) + 1;
for (i=1; i<=50; i++)
{
if(document.Meter.NoMeters .value<=i)
{
document.getElementById("T able_"+doc ument.Mete r.NoMeters .value).st yle.displa y=""
}
}
eval("document.Meter.m_0_" +document. Meter.NoMe ters.value +".value=d ocument.Me ter.m_0.va lue");
eval("document.Meter.m_1_" +document. Meter.NoMe ters.value +".value=d ocument.Me ter.m_1.va lue");
document.Meter.m_0.value=" ";
document.Meter.m_1.value=" ";
}
//-->
</script>
</head>
<body>
<form name="Meter" method="post" action="Meters.asp">
Name: <input type="text" name="f_0" value=""><br>
House: <input type="text" name="f_1" value=""><br>
Phone: <input type="text" name="f_2" value=""><br><br>
Meter No: <input type="text" name="m_0" value="">
Reading: <input type="text" name="m_1" value="">
<input type="button" name="Add" value="Add" onClick="AddMeter()"><br>< br>
<%For iLp = 1 to 50%>
<table ID="Table_<%=iLp%>" style="display: none">
<tr>
<td>
Meter No: <input type="text" name="m_0_<%=iLp%>" value="">
Reading: <input type="text" name="m_1_<%=iLp%>" value="">
</td>
</tr>
</table>
<%Next%>
<input type="hidden" name="NoMeters" value="0">
<input type="hidden" name="Action" value="Process">
<input type="submit" name="Button" value="Submit">
</form>
</body>
</html>
========================== ========== ========== ========== ========== ========== ========== ========== ========== ========== ======
==========================
<%@ Language=VBScript %>
<%
Dim iLp
If Request.Form("Action") = "Process" then
For iLp = 0 to 2
Response.Write "Field " & iLp & ": " & Trim(Request.Form("f_"&iLp
Next
Response.Write "<br>"
For iLp = 1 to Request.Form("NoMeters")
Response.Write "Meter No: " & Trim(Request.Form("m_0_"&i
Next
Session("NoMeters") = ""
Response.End
End If
%>
<html>
<head>
<script language="JavaScript">
function AddMeter()
{
var i
document.Meter.NoMeters.va
for (i=1; i<=50; i++)
{
if(document.Meter.NoMeters
{
document.getElementById("T
}
}
eval("document.Meter.m_0_"
eval("document.Meter.m_1_"
document.Meter.m_0.value="
document.Meter.m_1.value="
}
//-->
</script>
</head>
<body>
<form name="Meter" method="post" action="Meters.asp">
Name: <input type="text" name="f_0" value=""><br>
House: <input type="text" name="f_1" value=""><br>
Phone: <input type="text" name="f_2" value=""><br><br>
Meter No: <input type="text" name="m_0" value="">
Reading: <input type="text" name="m_1" value="">
<input type="button" name="Add" value="Add" onClick="AddMeter()"><br><
<%For iLp = 1 to 50%>
<table ID="Table_<%=iLp%>" style="display: none">
<tr>
<td>
Meter No: <input type="text" name="m_0_<%=iLp%>" value="">
Reading: <input type="text" name="m_1_<%=iLp%>" value="">
</td>
</tr>
</table>
<%Next%>
<input type="hidden" name="NoMeters" value="0">
<input type="hidden" name="Action" value="Process">
<input type="submit" name="Button" value="Submit">
</form>
</body>
</html>
==========================
Lets get pass the form first :)
ASKER
Lord McFly
I am really sorry. I hope you forgive me one more time.
I am feeling bad, You are working on it so much. I really liked your idea and played with your code.
It works Just right with high level programming. But you know what - My company users are very backwards.
User is saying it will be confusing for meter readers to enter data - if we give them Add button for more meters.
i apolozie for what happend now. You have put lot of efforts. gave me code. I hope you forgive me.
What I want now is . This is final now I will not change promise.......
For the first page I display default 10 text boxes for Meter No and 10 select boxes for MeterIN/OUT.
If they have more , they will load the form one more time and enter the info.
and the required feilds are EmployeeID,Date, Region, atleast 1 Meter No and 1 MeterIN/Out.(Please suggext me with required feilds code)
Meter Number should be 7 digits and should not start with number"7". Employee ID should be 5 digits.
I want for second page to enter the data for each meter Number that user enters
For Ex- Users enters all info and enters 6 meterNo and 6 select boxes, then database should have 6 records with employee info.
I have one concern defaulting MeterIN/OUt feild to OUT for not entered records. Please suggest.
I'll appreciate your help
Thanks
Pallilu
I am really sorry. I hope you forgive me one more time.
I am feeling bad, You are working on it so much. I really liked your idea and played with your code.
It works Just right with high level programming. But you know what - My company users are very backwards.
User is saying it will be confusing for meter readers to enter data - if we give them Add button for more meters.
i apolozie for what happend now. You have put lot of efforts. gave me code. I hope you forgive me.
What I want now is . This is final now I will not change promise.......
For the first page I display default 10 text boxes for Meter No and 10 select boxes for MeterIN/OUT.
If they have more , they will load the form one more time and enter the info.
and the required feilds are EmployeeID,Date, Region, atleast 1 Meter No and 1 MeterIN/Out.(Please suggext me with required feilds code)
Meter Number should be 7 digits and should not start with number"7". Employee ID should be 5 digits.
I want for second page to enter the data for each meter Number that user enters
For Ex- Users enters all info and enters 6 meterNo and 6 select boxes, then database should have 6 records with employee info.
I have one concern defaulting MeterIN/OUt feild to OUT for not entered records. Please suggest.
I'll appreciate your help
Thanks
Pallilu
No probs - I do this stuff for fun :)
ASKER
User does not want combo boxes dates either. For Date user wants to display in text box 00/00/2004 year to be current year.
Is that possible to do that defaulting to current year in 00/00/2004 in a text box.Do you have sample code.
Please suggest me with ideas.
I'll defenetly need you guys help here
Thanks
pallilu
Is that possible to do that defaulting to current year in 00/00/2004 in a text box.Do you have sample code.
Please suggest me with ideas.
I'll defenetly need you guys help here
Thanks
pallilu
Have you created a db yet?
I'm suggesting Meter IN (is this as is electric / gas meter) coz they are typically indoors aren't they?
What do you say IN...
What do you say IN...
ASKER
Yes,
I created DB in access with this structure. I though of giving Meter No a primary key. But user said thay can enter duplicate meter no with different dates it seems
Below is the structure
Employee ID -Text
Region Text
Date - Date/Time
MeterSerail No - Text
Status -Text
Please suggect with database changes.
I ll appreciste your help.
Pallilu
I created DB in access with this structure. I though of giving Meter No a primary key. But user said thay can enter duplicate meter no with different dates it seems
Below is the structure
Employee ID -Text
Region Text
Date - Date/Time
MeterSerail No - Text
Status -Text
Please suggect with database changes.
I ll appreciste your help.
Pallilu
ASKER
MeterIN/Out means, User enters the information, That meter are taken In/Out from the customers location.
User takes bunch of meters from region sub division, then aenters all the meter no and IN/Out for status.
Sometimes they can have 20 (Max is 20 itseems) and records get updated in the network drive
access database so that supervisors can track the meters in U:drive. We'll ask network people to give authentication to only supervisors
Thanks for working with me. I apprecuiate your pateince
User takes bunch of meters from region sub division, then aenters all the meter no and IN/Out for status.
Sometimes they can have 20 (Max is 20 itseems) and records get updated in the network drive
access database so that supervisors can track the meters in U:drive. We'll ask network people to give authentication to only supervisors
Thanks for working with me. I apprecuiate your pateince
Just so we are clear...
Users (or rather Employees - please confirm is it just Employees entering the readings or confirm that all Users will have a EmployeeID) can enter as any meter reading as they wish but in batches of 10.
You mention 'For Ex- Users' - what does this mean - please explain.
I'm going to do the IN / OUT as radio buttons - I will set IN as default - using radio buttons ensure that IN / OUT will have a value of some sort - say otherwise if this is not appropriate.
What is the 'Status' field in the DB?
Create an ID column - datatype AutoNumber - this will give each record a unique ID - will be required for deleteing / updating etc.
Ok - I await your response.
Users (or rather Employees - please confirm is it just Employees entering the readings or confirm that all Users will have a EmployeeID) can enter as any meter reading as they wish but in batches of 10.
You mention 'For Ex- Users' - what does this mean - please explain.
I'm going to do the IN / OUT as radio buttons - I will set IN as default - using radio buttons ensure that IN / OUT will have a value of some sort - say otherwise if this is not appropriate.
What is the 'Status' field in the DB?
Create an ID column - datatype AutoNumber - this will give each record a unique ID - will be required for deleteing / updating etc.
Ok - I await your response.
ASKER
I meant Employees. I do not use users from now on wards, yes I agree, It is confusing ....
Why canot be combo boxes, Default should be OUT.
Status - I named status for Meter IN/Out
Yes, I will create Id Auto Id for eacy record.
Thanks
I think a combo for for the IN / OUT is over kill especially for 2 options - IN & OUT - I think radio buttons are more suitable but if you really want dropdowns then say.
ASKER
Radio button is fine with me. Again I have to ask client. He is very particular non expereinced web person.
I think for now we can work with radio button. If I have to change, Then I 'll change to drop down box
Thanks
I think for now we can work with radio button. If I have to change, Then I 'll change to drop down box
Thanks
What dis you call the db?
Re-cap...
What is the DB name?
What is the Table name?
What is the DB name?
What is the Table name?
ASKER
Meter.mdb is DB name
GasMeterTrack is table name
GasMeterTrack is table name
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Additional Notes....
The Meter No starts off empty - but when you click in the box it enters the starting 7 at that start, helps keep the form in order.
I've put in a function which allows for different styles of dates, you can put for example...
10/2/05 - will come out as 10/02/2005
1/1/1- will come out as 01/01/2001
1 1 1- will come out as 01/01/2001
1-1-1 - will come out as 01/01/2001
..you get the general idea.
Meter Nos must be 7 chars long - you cahnge that if you need to.
When the form is submitted error checking is done and if there is an error a msg is displayed.
When all is ok - it gets inserted into the db - the general info EmpID, Date and Region will carry through onto the new page.
Have a play anyway.
The Meter No starts off empty - but when you click in the box it enters the starting 7 at that start, helps keep the form in order.
I've put in a function which allows for different styles of dates, you can put for example...
10/2/05 - will come out as 10/02/2005
1/1/1- will come out as 01/01/2001
1 1 1- will come out as 01/01/2001
1-1-1 - will come out as 01/01/2001
..you get the general idea.
Meter Nos must be 7 chars long - you cahnge that if you need to.
When the form is submitted error checking is done and if there is an error a msg is displayed.
When all is ok - it gets inserted into the db - the general info EmpID, Date and Region will carry through onto the new page.
Have a play anyway.
ASKER
Lord_MCFly
THanks a lot for your hard work. Oh Boy I can not beliave you have so much pateince.. Keep it up
Confirmations:
The Meter No starts off empty - but when you click in the box it enters the starting 7 at that start, helps keep the form in order.
Why did you put that code, can you please explain. I asked for this:
Meter Number should be 7 digits and should not start with number"7". Employee ID should be 5 digits.
I think You misunderstood with my statement.
I said it should not start with "7"
I am not getting any error messages , when I left the fields empty . Am I doing any wrong?
THanks a lot for your hard work. Oh Boy I can not beliave you have so much pateince.. Keep it up
Confirmations:
The Meter No starts off empty - but when you click in the box it enters the starting 7 at that start, helps keep the form in order.
Why did you put that code, can you please explain. I asked for this:
Meter Number should be 7 digits and should not start with number"7". Employee ID should be 5 digits.
I think You misunderstood with my statement.
I said it should not start with "7"
I am not getting any error messages , when I left the fields empty . Am I doing any wrong?
ASKER
Lord Mc
I took out the function onmouseclick. I think now, it is fine, i am not getting 7 when i click on text box.
And I got date aslo invalid. Let me check all the functionality.
It did not(values) insert to the dtabase.
Let me test
I woe you so much . I don't think whatever point i have is not enough for you.
I took out the function onmouseclick. I think now, it is fine, i am not getting 7 when i click on text box.
And I got date aslo invalid. Let me check all the functionality.
It did not(values) insert to the dtabase.
Let me test
I woe you so much . I don't think whatever point i have is not enough for you.
ASKER
wONDERFUL, The values are inserted into database. I checked for adding 3 rmeter no's. the database has threee records with same employee info.
But only thing is not working is the meter no starting with 7 are also inserted to database. I think, I did not explained properly to you.
If we figure out that, then we are set to go.
Thanks a lot for your help.
But only thing is not working is the meter no starting with 7 are also inserted to database. I think, I did not explained properly to you.
If we figure out that, then we are set to go.
Thanks a lot for your help.
Ok - if you've removed the onClick() don't forget to delete the following (its no longer needed)...
<script language="JavaScript">
<!--
function AddPrefix(Number, Object)
{
if(Object.value=="") Object.value=7
}
//-->
</script>
To correct the checking of the 7 paste this over the old code thats there....
For iLp = 0 to 9
If sData(iLp,0) <> "" then
If Left(sData(iLp,0),1) = "7" then
sErrMsg = "Error: Meter No (" & sData(iLp,0) & ") - can't start with 7."
Else
If Len(sData(iLp,0)) <> 7 then
sErrMsg = "Error: Meter No (" & sData(iLp,0) & ") - wrong length."
Else
bIsMeter = True
End If
End If
If sErrMsg <> "" then
iLp = 9
End If
End If
Next
What date did you enter - can you remember?
<script language="JavaScript">
<!--
function AddPrefix(Number, Object)
{
if(Object.value=="") Object.value=7
}
//-->
</script>
To correct the checking of the 7 paste this over the old code thats there....
For iLp = 0 to 9
If sData(iLp,0) <> "" then
If Left(sData(iLp,0),1) = "7" then
sErrMsg = "Error: Meter No (" & sData(iLp,0) & ") - can't start with 7."
Else
If Len(sData(iLp,0)) <> 7 then
sErrMsg = "Error: Meter No (" & sData(iLp,0) & ") - wrong length."
Else
bIsMeter = True
End If
End If
If sErrMsg <> "" then
iLp = 9
End If
End If
Next
What date did you enter - can you remember?
ASKER
Mc Lord
It worked fine with your new code, you are hawsom....
I want to display the region feild with the contents from database to dropdownbox.
Database will have table called Region and feild called Region.
I tried using this in near OpenDB section code
OpenDB
'------------------------- -----
Dim sRegions
sRegions = "SELECT REGION FROM REGION"
set rsRegions = objcon.Execute(sRegions)
'------------------------- -----
I am getting rsRegions in not defined, even after using set
I though of using this near dropdownbox
<% while not rsRegions.eof %>
<OPTION><%=rsRegions("Regi on").value %></OPTION >
<% rsRegions.MoveNext %>
<% wend %>
<% rsRegions.close %>
<% set rsRegions = nothing %>
Please suggect me Mc lord.
I think after this, I will close this as accepted answer.
I think I am delaying for giving points to you.
Only my concern , if it not works afterwards.
Please bear with me
Thanks for your pateince
pallilu
It worked fine with your new code, you are hawsom....
I want to display the region feild with the contents from database to dropdownbox.
Database will have table called Region and feild called Region.
I tried using this in near OpenDB section code
OpenDB
'-------------------------
Dim sRegions
sRegions = "SELECT REGION FROM REGION"
set rsRegions = objcon.Execute(sRegions)
'-------------------------
I am getting rsRegions in not defined, even after using set
I though of using this near dropdownbox
<% while not rsRegions.eof %>
<OPTION><%=rsRegions("Regi
<% rsRegions.MoveNext %>
<% wend %>
<% rsRegions.close %>
<% set rsRegions = nothing %>
Please suggect me Mc lord.
I think after this, I will close this as accepted answer.
I think I am delaying for giving points to you.
Only my concern , if it not works afterwards.
Please bear with me
Thanks for your pateince
pallilu
ASKER
Mc Lord,
Drop down box just worked fine with the code.
Information is inserted to database
Thank for all your help and pateince.
Keep it up
Thanks
Pallilu
Drop down box just worked fine with the code.
Information is inserted to database
Thank for all your help and pateince.
Keep it up
Thanks
Pallilu
Any questions that I get involved with I'm still willing to assist with even after points have been awarded providing the help is still relevant to the posted question.
ASKER
Thanks For your offer Lord Mc Fly. Currently I am working on different project. WHen I test this form and put in production, I defenltely ask questions, if I have any.
Thanks Once again for youe help
Pallilu
Thanks Once again for youe help
Pallilu
ASKER
Lord Mc Fly
I hve one question
Please help me.
Employee ID in the form canot have more than 5 digits. I think through form we gave has Maxlength to 5. We took care of that
And Now user is asking for not to enter Number "99999" for Employee Id. if user enters 99999 for EMployee ID , we should give them a
error meesage Error: Employee ID - Wrong
If you have some time, can you please let me know, How we can perform that requirement.
I'll Apprecaite your help
Thanks
pallilu
I hve one question
Please help me.
Employee ID in the form canot have more than 5 digits. I think through form we gave has Maxlength to 5. We took care of that
And Now user is asking for not to enter Number "99999" for Employee Id. if user enters 99999 for EMployee ID , we should give them a
error meesage Error: Employee ID - Wrong
If you have some time, can you please let me know, How we can perform that requirement.
I'll Apprecaite your help
Thanks
pallilu
Ok, make a slight change to the code - replace the old (or change it manually) code with this....
'Start To Validate Form
If sErrMsg = "" then
'Employee ID
If sForm(0) = "" or sForm(0) = "99999" then
If sForm(0) = "" then
sErrMsg = "Error: Employee ID - required field."
Elseif sForm(0) = "99999" then
sErrMsg = "Error: Employee ID - invalid value."
End If
Else
'Start To Validate Form
If sErrMsg = "" then
'Employee ID
If sForm(0) = "" or sForm(0) = "99999" then
If sForm(0) = "" then
sErrMsg = "Error: Employee ID - required field."
Elseif sForm(0) = "99999" then
sErrMsg = "Error: Employee ID - invalid value."
End If
Else
ASKER
Sorry mc Lord, I have 1 more request, i forgot to tell you in my last posted message, Employee Id also should not accept
characters, it should only take numbers
(for Ex- cvbgt is not valid,
cv1234 is not valid ,
only 24567is valid
can we add more the same query.
Thanks for your immediate response.
Thanks
pallilu
characters, it should only take numbers
(for Ex- cvbgt is not valid,
cv1234 is not valid ,
only 24567is valid
can we add more the same query.
Thanks for your immediate response.
Thanks
pallilu
ASKER
Should we change our database structure also? for Employee ID change to Number instead of text(7)
can You if possible give correct database datatypes with numbers.
Thanks
pallilu
can You if possible give correct database datatypes with numbers.
Thanks
pallilu
:)
Ok change the code to....
'Start To Validate Form
If sErrMsg = "" then
'Employee ID
If sForm(0) = "" or sForm(0) = "99999" or not IsNumeric(sForm(0)) then
If sForm(0) = "" then
sErrMsg = "Error: Employee ID - required field."
Elseif sForm(0) = "99999" or not IsNumeric(sForm(0)) then
sErrMsg = "Error: Employee ID - invalid value."
End If
Else
Ok change the code to....
'Start To Validate Form
If sErrMsg = "" then
'Employee ID
If sForm(0) = "" or sForm(0) = "99999" or not IsNumeric(sForm(0)) then
If sForm(0) = "" then
sErrMsg = "Error: Employee ID - required field."
Elseif sForm(0) = "99999" or not IsNumeric(sForm(0)) then
sErrMsg = "Error: Employee ID - invalid value."
End If
Else
ASKER
Lord Mc fly
I need your help please.
I changed the code to get the regions from drop down box and when I submit the values,if I have any validation message , then
the Drop down box is empty with no value. I have to select the drop down for every message I get,
Basically page is not refreshing with the selected drop down box value every time.
and I also have one more question on connecting to network drive for access database. not the physical path location. It should be "U:/Meter Track/Meters.mdb
Is it possible to give that location to connect to database.
I am attaching the changed code.
Please relpy me with the options
I'll appreciate your help.
Pallilu
<%@ Language=VBScript %>
<%Option Explicit%>
<%
'Function / Sub Variables
Dim objCon
Dim sTempStr, sTmpStr, iTempVal, iTmpVal
'Page Variables
Dim sForm(2), sData(9,1), sErrMsg, sQuery
Dim iLp, iLoop
Dim bIsMeter
OpenDB
'Load IN / OUT Deafult
For iLp = 0 to 9
sData(iLp,1) = "OUT"
Next
'Get Passed Back Form Data After INSERT
If CBool(Request.QueryString( "pass")) = True then
sForm(0) = Request.QueryString("empid ")
sForm(1) = Request.QueryString("date" )
sForm(2) = Request.QueryString("reg")
End If
'Form Has Been Submitted
If Request.Form("Action") = "Add" then
sErrMsg = ""
'Collect Up The General Info
For iLp = 0 to 2
sForm(iLp) = Trim(Request.Form("f_"&iLp ))
Next
'Collect Up The Meter Info
For iLp = 0 to 9
For iLoop = 0 to 1
sData(iLp,iLoop) = Trim(Request.Form("m_"&iLo op&"_"&iLp ))
Next
Next
'Validation of form with proper values
If sErrMsg = "" then
'Employee ID
If (sForm(0) = "") or (sForm(0) = "99999") or not (IsNumeric(sForm(0)))or (Len(sForm(0)) <> 5) then
If sForm(0) = "" then
sErrMsg = "Error: Employee ID - Required field."
Elseif sForm(0) = "99999" or not IsNumeric(sForm(0))or (Len(sForm(0)) <> 5) then
sErrMsg = "Error: Employee ID - Invalid Value."
End If
Else
'Date
If sForm(1) = "" then
sErrMsg = "Error: Date - Required Field."
Else
sForm(1) = PadDate(sForm(1))
If ValidateDate(sForm(1),sErr Msg) = True then
sForm(1) = sErrMsg
sErrMsg = ""
'Region
If sForm(2) = "" then
sErrMsg = "Error: Region - Required Field."
Else
sForm(2) = SetCap(sForm(2))
'Meter Info
bIsMeter = False
For iLp = 0 to 9
If sData(iLp,0) <> "" then
If Left(sData(iLp,0),1) = "7" then
sErrMsg = "Error: Meter No (" & sData(iLp,0) & ") - Can't Start With 7."
Else
If Len(sData(iLp,0)) <> 7 then
sErrMsg = "Error: Meter No (" & sData(iLp,0) & ") - Wrong Length."
Else
bIsMeter = True
End If
End If
If sErrMsg <> "" then
iLp = 9
End If
End If
Next
If sErrMsg = "" then
'All Ok - INSERT Details into DB
If bIsMeter = False then
sErrMsg = "Error: Meter No Details - Required."
Else
If sErrMsg = "" then
For iLp = 0 to 9
If sData(iLp,0) <> "" then
sQuery = "INSERT INTO GasMeterTrack (EmployeeID, MeterDate, Region, MeterSerialNo, Status) VALUES " &_
"('" & SQL(sForm(0)) & "','" & sForm(1) & "','" & SQL(sForm(2)) & "'," &_
"'" & SQL(sData(iLp,0)) & "','" & sData(iLp,1) & "')"
objCon.Execute sQuery
End If
Next
Response.Redirect "Testing.asp?pass=True&emp id=" & sForm(0) & "&date=" & sForm(1) & "®=" & sForm(2)
End If
End If
End If
End If
End If
End If
End If
End If
End If
CloseDB
%>
<html>
<head>
<title>Meter Information</title>
</head>
<body>
<table width="500" cellspacing="1" cellpadding="0" border="0" bgcolor="#000000" align=center>
<form name="Reading" method="post" action="Testing.asp">
<tr bgcolor="#FFFFFF">
<td>
<table width="500" cellspacing="0" cellpadding="2" border="0">
<tr>
<td height="30"><b>M E T E R I N F O R M A T I O N</b></td>
</tr>
</table>
<td>
</tr>
<%If sErrMsg <> "" then%>
<tr bgcolor="#FFFFFF">
<td>
<table width="500" cellspacing="0" cellpadding="2" border="0">
<tr>
<td height="30"><font color="#FF0000"><%=sErrMsg %></font>< /td>
</tr>
</table>
</td>
</tr>
<%End If%>
<%If CBool(Request.QueryString( "pass")) = True then%>
<tr bgcolor="#FFFFFF">
<td>
<table width="500" cellspacing="0" cellpadding="2" border="0">
<tr>
<td height="30">Notice: Info Successfully inserted into DB.</td>
</tr>
</table>
</td>
</tr>
<%End If%>
<tr bgcolor="#FFFFFF">
<td>
<table width="500" cellspacing="0" cellpadding="2" border="0">
<tr>
<td colspan="2" height="30"><b>General Details:</b></td>
</tr>
<tr>
<td width="100" height="25">*Employee ID:</td>
<td width="400">
<input type="text" name="f_0" size="5" maxlength="5" value="<%=sForm(0)%>">
</td>
</tr>
<tr>
<td height="25">*Date:</td>
<td>
<input type="text" name="f_1" size="10" maxlength="10" value="<%=sForm(1)%>">(Ex- 01/01/2004 )
</td>
</tr>
<tr>
<td height="25">*Region:</td>
<td>
<!--<input type="text" name="f_2" size="25" maxlength="25" value="<%=sForm(2)%>">-->
<SELECT name="f_2" value="<%=sForm(2)%>">
<OPTION value =""></OPTION>
<OPTION value ="BELLWOOD">BELLWOOD</OPTI ON>
<OPTION value ="GLEN ELLYN">GLEN ELLYN</OPTION>
</SELECT>
</td>
</tr>
</table>
</td>
</tr>
<tr bgcolor="#FFFFFF">
<td>
<table width="500" cellspacing="0" cellpadding="2" border="0">
<tr>
<td colspan="4" height="30"><b>Meter Numbers:</b></td>
</tr>
<%For iLp = 0 to 9%>
<tr>
<td width="100" height="25">Meter No:</td>
<td width="125">
<input type="text" name="m_0_<%=iLp%>" size="6" maxlength="7" value="<%=sData(iLp,0)%>"" >(7 Digits)
</td>
<td width="50">Status:</td>
<td width="225">
<input type="radio" name="m_1_<%=iLp%>" value="OUT" <%If sData(iLp,1) = "OUT" then%>checked<%End If%>> OUT
<input type="radio" name="m_1_<%=iLp%>" value="IN" <%If sData(iLp,1) = "IN" then%>checked<%End If%>> IN
</td>
</tr>
<%Next%>
</table>
</td>
</tr>
<tr bgcolor="#FFFFFF">
<td>
<table width="500" cellspacing="0" cellpadding="2" border="0">
<tr>
<td height="30" align="center">
<input type="hidden" name="Action" value="Add">
<input type="submit" name="Button" value="Submit">
<INPUT id=reset name=reset type=reset value=Reset></TD>
</td>
</tr>
</table>
</td>
</tr>
</form>
</table>
</body>
</html>
<%
Function PadDate(Value)
If Len(Value) = 0 then
PadDate = Value
Else
If IsDate(Value) then
sTmpStr = ""
sTempStr = ""
iTempVal = 0
For iLp = 1 to Len(Value)
If IsNumeric(Mid(Value,iLp,1) ) then
sTempStr = sTempStr & Mid(Value,iLp,1)
Else
If Len(sTempStr) > 2 then
PadDate = Value
Else
sTempStr = Left("00",2-Len(sTempStr)) & sTempStr & "/"
sTmpStr = sTmpStr & sTempStr
sTempStr = ""
End If
End If
Next
If Len(sTempStr) > 4 then
PadDate = Value
Else
PadDate = sTmpStr & Left("2000",4-Len(sTempStr )) & sTempStr
End If
Else
PadDate = Value
End If
End If
End Function
Function ValidateDate(Value, sErrMsg)
If Len(Value) <> 10 then
ValidateDate = False
sErrMsg = "Error: Date - Invalid."
Else
If IsNumeric(Mid(Value,1,2)) and IsNumeric(Mid(Value,4,2)) and IsNumeric(Mid(Value,7,4)) then
Value = Mid(Value,1,2) & "/" & Mid(Value,4,2) & "/" & Mid(Value,7,4)
If IsDate(Value) then
ValidateDate = True
sErrMsg = Value
Else
ValidateDate = False
sErrMsg = "Error: Date - Invalid."
End If
Else
ValidateDate = False
sErrMsg = "Error: Date - Invalid."
End If
End If
End Function
Sub OpenDB
Set objCon = Server.CreateObject("ADODB .Connectio n")
objCon.Open "PROVIDER=Microsoft.Jet.OL EDB.4.0;Da ta Source=" & Request.ServerVariables("A PPL_PHYSIC AL_PATH") & "\MeterCheck\Meter.mdb"
End Sub
Sub CloseDB
Set objCon = Nothing
End Sub
Function SQL(Value)
SQL = Replace(Value,"'","''")
End Function
Function SetCap(Value)
If Value <> "" Then
sTempStr = ""
sTempStr = sTempStr & UCase(Mid(Value, 1, 1))
For iTempval = 2 To Len(Value)
If Mid(Value, iTempval-1, 1) = " " Then
sTempStr = sTempStr & UCase(Mid(Value, iTempval, 1))
Else
sTempStr = sTempStr + Mid(Value, iTempval, 1)
End If
Next
SetCap = sTempStr
End If
End Function
%>
I need your help please.
I changed the code to get the regions from drop down box and when I submit the values,if I have any validation message , then
the Drop down box is empty with no value. I have to select the drop down for every message I get,
Basically page is not refreshing with the selected drop down box value every time.
and I also have one more question on connecting to network drive for access database. not the physical path location. It should be "U:/Meter Track/Meters.mdb
Is it possible to give that location to connect to database.
I am attaching the changed code.
Please relpy me with the options
I'll appreciate your help.
Pallilu
<%@ Language=VBScript %>
<%Option Explicit%>
<%
'Function / Sub Variables
Dim objCon
Dim sTempStr, sTmpStr, iTempVal, iTmpVal
'Page Variables
Dim sForm(2), sData(9,1), sErrMsg, sQuery
Dim iLp, iLoop
Dim bIsMeter
OpenDB
'Load IN / OUT Deafult
For iLp = 0 to 9
sData(iLp,1) = "OUT"
Next
'Get Passed Back Form Data After INSERT
If CBool(Request.QueryString(
sForm(0) = Request.QueryString("empid
sForm(1) = Request.QueryString("date"
sForm(2) = Request.QueryString("reg")
End If
'Form Has Been Submitted
If Request.Form("Action") = "Add" then
sErrMsg = ""
'Collect Up The General Info
For iLp = 0 to 2
sForm(iLp) = Trim(Request.Form("f_"&iLp
Next
'Collect Up The Meter Info
For iLp = 0 to 9
For iLoop = 0 to 1
sData(iLp,iLoop) = Trim(Request.Form("m_"&iLo
Next
Next
'Validation of form with proper values
If sErrMsg = "" then
'Employee ID
If (sForm(0) = "") or (sForm(0) = "99999") or not (IsNumeric(sForm(0)))or (Len(sForm(0)) <> 5) then
If sForm(0) = "" then
sErrMsg = "Error: Employee ID - Required field."
Elseif sForm(0) = "99999" or not IsNumeric(sForm(0))or (Len(sForm(0)) <> 5) then
sErrMsg = "Error: Employee ID - Invalid Value."
End If
Else
'Date
If sForm(1) = "" then
sErrMsg = "Error: Date - Required Field."
Else
sForm(1) = PadDate(sForm(1))
If ValidateDate(sForm(1),sErr
sForm(1) = sErrMsg
sErrMsg = ""
'Region
If sForm(2) = "" then
sErrMsg = "Error: Region - Required Field."
Else
sForm(2) = SetCap(sForm(2))
'Meter Info
bIsMeter = False
For iLp = 0 to 9
If sData(iLp,0) <> "" then
If Left(sData(iLp,0),1) = "7" then
sErrMsg = "Error: Meter No (" & sData(iLp,0) & ") - Can't Start With 7."
Else
If Len(sData(iLp,0)) <> 7 then
sErrMsg = "Error: Meter No (" & sData(iLp,0) & ") - Wrong Length."
Else
bIsMeter = True
End If
End If
If sErrMsg <> "" then
iLp = 9
End If
End If
Next
If sErrMsg = "" then
'All Ok - INSERT Details into DB
If bIsMeter = False then
sErrMsg = "Error: Meter No Details - Required."
Else
If sErrMsg = "" then
For iLp = 0 to 9
If sData(iLp,0) <> "" then
sQuery = "INSERT INTO GasMeterTrack (EmployeeID, MeterDate, Region, MeterSerialNo, Status) VALUES " &_
"('" & SQL(sForm(0)) & "','" & sForm(1) & "','" & SQL(sForm(2)) & "'," &_
"'" & SQL(sData(iLp,0)) & "','" & sData(iLp,1) & "')"
objCon.Execute sQuery
End If
Next
Response.Redirect "Testing.asp?pass=True&emp
End If
End If
End If
End If
End If
End If
End If
End If
End If
CloseDB
%>
<html>
<head>
<title>Meter Information</title>
</head>
<body>
<table width="500" cellspacing="1" cellpadding="0" border="0" bgcolor="#000000" align=center>
<form name="Reading" method="post" action="Testing.asp">
<tr bgcolor="#FFFFFF">
<td>
<table width="500" cellspacing="0" cellpadding="2" border="0">
<tr>
<td height="30"><b>M E T E R I N F O R M A T I O N</b></td>
</tr>
</table>
<td>
</tr>
<%If sErrMsg <> "" then%>
<tr bgcolor="#FFFFFF">
<td>
<table width="500" cellspacing="0" cellpadding="2" border="0">
<tr>
<td height="30"><font color="#FF0000"><%=sErrMsg
</tr>
</table>
</td>
</tr>
<%End If%>
<%If CBool(Request.QueryString(
<tr bgcolor="#FFFFFF">
<td>
<table width="500" cellspacing="0" cellpadding="2" border="0">
<tr>
<td height="30">Notice: Info Successfully inserted into DB.</td>
</tr>
</table>
</td>
</tr>
<%End If%>
<tr bgcolor="#FFFFFF">
<td>
<table width="500" cellspacing="0" cellpadding="2" border="0">
<tr>
<td colspan="2" height="30"><b>General Details:</b></td>
</tr>
<tr>
<td width="100" height="25">*Employee ID:</td>
<td width="400">
<input type="text" name="f_0" size="5" maxlength="5" value="<%=sForm(0)%>">
</td>
</tr>
<tr>
<td height="25">*Date:</td>
<td>
<input type="text" name="f_1" size="10" maxlength="10" value="<%=sForm(1)%>">(Ex-
</td>
</tr>
<tr>
<td height="25">*Region:</td>
<td>
<!--<input type="text" name="f_2" size="25" maxlength="25" value="<%=sForm(2)%>">-->
<SELECT name="f_2" value="<%=sForm(2)%>">
<OPTION value =""></OPTION>
<OPTION value ="BELLWOOD">BELLWOOD</OPTI
<OPTION value ="GLEN ELLYN">GLEN ELLYN</OPTION>
</SELECT>
</td>
</tr>
</table>
</td>
</tr>
<tr bgcolor="#FFFFFF">
<td>
<table width="500" cellspacing="0" cellpadding="2" border="0">
<tr>
<td colspan="4" height="30"><b>Meter Numbers:</b></td>
</tr>
<%For iLp = 0 to 9%>
<tr>
<td width="100" height="25">Meter No:</td>
<td width="125">
<input type="text" name="m_0_<%=iLp%>" size="6" maxlength="7" value="<%=sData(iLp,0)%>""
</td>
<td width="50">Status:</td>
<td width="225">
<input type="radio" name="m_1_<%=iLp%>" value="OUT" <%If sData(iLp,1) = "OUT" then%>checked<%End If%>> OUT
<input type="radio" name="m_1_<%=iLp%>" value="IN" <%If sData(iLp,1) = "IN" then%>checked<%End If%>> IN
</td>
</tr>
<%Next%>
</table>
</td>
</tr>
<tr bgcolor="#FFFFFF">
<td>
<table width="500" cellspacing="0" cellpadding="2" border="0">
<tr>
<td height="30" align="center">
<input type="hidden" name="Action" value="Add">
<input type="submit" name="Button" value="Submit">
<INPUT id=reset name=reset type=reset value=Reset></TD>
</td>
</tr>
</table>
</td>
</tr>
</form>
</table>
</body>
</html>
<%
Function PadDate(Value)
If Len(Value) = 0 then
PadDate = Value
Else
If IsDate(Value) then
sTmpStr = ""
sTempStr = ""
iTempVal = 0
For iLp = 1 to Len(Value)
If IsNumeric(Mid(Value,iLp,1)
sTempStr = sTempStr & Mid(Value,iLp,1)
Else
If Len(sTempStr) > 2 then
PadDate = Value
Else
sTempStr = Left("00",2-Len(sTempStr))
sTmpStr = sTmpStr & sTempStr
sTempStr = ""
End If
End If
Next
If Len(sTempStr) > 4 then
PadDate = Value
Else
PadDate = sTmpStr & Left("2000",4-Len(sTempStr
End If
Else
PadDate = Value
End If
End If
End Function
Function ValidateDate(Value, sErrMsg)
If Len(Value) <> 10 then
ValidateDate = False
sErrMsg = "Error: Date - Invalid."
Else
If IsNumeric(Mid(Value,1,2)) and IsNumeric(Mid(Value,4,2)) and IsNumeric(Mid(Value,7,4)) then
Value = Mid(Value,1,2) & "/" & Mid(Value,4,2) & "/" & Mid(Value,7,4)
If IsDate(Value) then
ValidateDate = True
sErrMsg = Value
Else
ValidateDate = False
sErrMsg = "Error: Date - Invalid."
End If
Else
ValidateDate = False
sErrMsg = "Error: Date - Invalid."
End If
End If
End Function
Sub OpenDB
Set objCon = Server.CreateObject("ADODB
objCon.Open "PROVIDER=Microsoft.Jet.OL
End Sub
Sub CloseDB
Set objCon = Nothing
End Sub
Function SQL(Value)
SQL = Replace(Value,"'","''")
End Function
Function SetCap(Value)
If Value <> "" Then
sTempStr = ""
sTempStr = sTempStr & UCase(Mid(Value, 1, 1))
For iTempval = 2 To Len(Value)
If Mid(Value, iTempval-1, 1) = " " Then
sTempStr = sTempStr & UCase(Mid(Value, iTempval, 1))
Else
sTempStr = sTempStr + Mid(Value, iTempval, 1)
End If
Next
SetCap = sTempStr
End If
End Function
%>
Firstly - it would be a lot easier if you could store the list of regions in the db. then you could do something like the following...
To get a list of regions...
Set rsReg = Server.CreateObject("ADODB .RecordSet ")
sQuery = "SELECT * FROM Region ORDER BY Region ASC"
rsReg.OPen sQuery, objCon
Within your HTML code...
<select name="f_2">
<%If sForm(2) = "" then%>
<option value="">Please select</option>
<%End If
Do while not rsReg.EOF
If sForm(2) = rsReg("Region") then%>
<option value="<%=rsReg("Region")% >" selected><%=rsReg("Region" )%></optio n>
<%Else%>
<option value="<%=rsReg("Region")% >"><%=rsRe g("Region" )%></optio n>
<%End If
rsReg.MoveNext
Loop%>
</select>
The bit about the db location I don't quite get....
To get a list of regions...
Set rsReg = Server.CreateObject("ADODB
sQuery = "SELECT * FROM Region ORDER BY Region ASC"
rsReg.OPen sQuery, objCon
Within your HTML code...
<select name="f_2">
<%If sForm(2) = "" then%>
<option value="">Please select</option>
<%End If
Do while not rsReg.EOF
If sForm(2) = rsReg("Region") then%>
<option value="<%=rsReg("Region")%
<%Else%>
<option value="<%=rsReg("Region")%
<%End If
rsReg.MoveNext
Loop%>
</select>
The bit about the db location I don't quite get....
ASKER
Mc lord,
I changed my mind for not to dispaly drop down box from database because, not every body will have rights to read database, only 3 people will have access to Meter database.
That is the reason I want to change the code to values in the html form,
Please advice how to get values from dropdown box when form loads without having access to database. When I click on the Meter track folder in U:/Meter Track, I am getting access deneied. The database will be loacated in U:/MeterTrack/Meters.mdb.
THat is the reason, I asked, to change the datasource to connect to Meters.mdb and store the information when user submits the information.
Please............
Pllease help me Mc lord.
Do you want to submit has different question with points, I am ready to do that.please let me know
Thanks
Pallilu
I changed my mind for not to dispaly drop down box from database because, not every body will have rights to read database, only 3 people will have access to Meter database.
That is the reason I want to change the code to values in the html form,
Please advice how to get values from dropdown box when form loads without having access to database. When I click on the Meter track folder in U:/Meter Track, I am getting access deneied. The database will be loacated in U:/MeterTrack/Meters.mdb.
THat is the reason, I asked, to change the datasource to connect to Meters.mdb and store the information when user submits the information.
Please............
Pllease help me Mc lord.
Do you want to submit has different question with points, I am ready to do that.please let me know
Thanks
Pallilu
I'm a little confused.
I take it you are not using a dropdown now for the region - this is now just a textbox where the user enters the region - is this correct?
The mapped drive you have created - is it mapping to a folder on the same machine, a folder on the same machine but on a different drive or folder on a different machine - please confirm the location of the folder 'MeterTrack'.
Confirm the folder name (because you keep changing it) - is it 'Meter Track' or 'MeterTrack'?
Question - why are you storing the db in a different location that the web app?
As for posting another question - I wouldn't say No :)
I take it you are not using a dropdown now for the region - this is now just a textbox where the user enters the region - is this correct?
The mapped drive you have created - is it mapping to a folder on the same machine, a folder on the same machine but on a different drive or folder on a different machine - please confirm the location of the folder 'MeterTrack'.
Confirm the folder name (because you keep changing it) - is it 'Meter Track' or 'MeterTrack'?
Question - why are you storing the db in a different location that the web app?
As for posting another question - I wouldn't say No :)
ASKER
Mc lord, thanks for immediate response, it is extremely urget for me. I was worried that I lost you.
Any way,
No mc lord, it is not a text box, I want the region to be drop down box( The resen i change to display the values from html to dropdown box is ,not everybody will have access to
U:/Meter Track/Meters.mdb. Only 3 people will have access to view the data on the U:Meter Track/Meters.mdb . Can we even do that to disply the values for dropdown box from db?with no rights to folder.pLease let me know..
For database. The 3 supervisors will have access to Meter.mdb database, where the information submitted by field employees should go to the database U:/Meter Track/Meters.mdb. That is the reason I want to change the location of datasource to U:/Meter Track/Meters.mdb.
If i change the datasource to this
Set objCon = Server.CreateObject("ADODB .Connectio n")
objCon.Open "PROVIDER=Microsoft.Jet.OL EDB.4.0;Da ta Source="U:\Phonebk\Meter.m db""
I am getting Expected end of statement.
Pleae help me mc lord
Any way,
No mc lord, it is not a text box, I want the region to be drop down box( The resen i change to display the values from html to dropdown box is ,not everybody will have access to
U:/Meter Track/Meters.mdb. Only 3 people will have access to view the data on the U:Meter Track/Meters.mdb . Can we even do that to disply the values for dropdown box from db?with no rights to folder.pLease let me know..
For database. The 3 supervisors will have access to Meter.mdb database, where the information submitted by field employees should go to the database U:/Meter Track/Meters.mdb. That is the reason I want to change the location of datasource to U:/Meter Track/Meters.mdb.
If i change the datasource to this
Set objCon = Server.CreateObject("ADODB
objCon.Open "PROVIDER=Microsoft.Jet.OL
I am getting Expected end of statement.
Pleae help me mc lord
Ok for the region stuff do something like folowing...
In the ASP code at the top of the page...
-------------------------- ---------- ---------- ---------- -----
Dim sReg(3)
sReg(0) = "Region A"
sReg(1) = "Region B"
sReg(2) = "Region C"
sReg(3) = "Region D"
In the HTML...
-------------------------- ---------- ---------- ---------- ------
<select name="f_2">
<%If sForm(2) = "" then%>
<option value="">Please select</option>
<%End If
For iLp = 0 to UBound(sReg)
If sForm(2) = sReg(iLp) then%>
<option value="<%=sReg(iLp)%>" selected><%=sReg(iLp)%></o ption>
<%Else%>
<option value="<%=sReg(iLp)%>"><%= sReg(iLp)% ></option>
<%End If
Next%>
</select>
The error I think is because you have an extra " on the end of the line...
objCon.Open "PROVIDER=Microsoft.Jet.OL EDB.4.0;Da ta Source="U:\Phonebk\Meter.m db"" <---just here
Also you sill need to confirm the following...
The mapped drive you have created - is it mapping to a folder on the same machine, a folder on the same machine but on a different drive or folder on a different machine - please confirm the location of the folder 'MeterTrack'.
Confirm the folder name (because you keep changing it) - is it 'Meter Track' or 'MeterTrack'?
Question - why are you storing the db in a different location that the web app?
In the ASP code at the top of the page...
--------------------------
Dim sReg(3)
sReg(0) = "Region A"
sReg(1) = "Region B"
sReg(2) = "Region C"
sReg(3) = "Region D"
In the HTML...
--------------------------
<select name="f_2">
<%If sForm(2) = "" then%>
<option value="">Please select</option>
<%End If
For iLp = 0 to UBound(sReg)
If sForm(2) = sReg(iLp) then%>
<option value="<%=sReg(iLp)%>" selected><%=sReg(iLp)%></o
<%Else%>
<option value="<%=sReg(iLp)%>"><%=
<%End If
Next%>
</select>
The error I think is because you have an extra " on the end of the line...
objCon.Open "PROVIDER=Microsoft.Jet.OL
Also you sill need to confirm the following...
The mapped drive you have created - is it mapping to a folder on the same machine, a folder on the same machine but on a different drive or folder on a different machine - please confirm the location of the folder 'MeterTrack'.
Confirm the folder name (because you keep changing it) - is it 'Meter Track' or 'MeterTrack'?
Question - why are you storing the db in a different location that the web app?
Another question - if certain users don't have access to the db why are they allowed to INSERT records (using the form) but not read it?
ASKER
Thenfolder U:/Meter Track/Meters.mdb is a network folder in house. I want to ask you this?
Should all machines must have that folder to insert to the U:/Meter Track/Meters.mdb, if we change our datasource to thsi location.
Then please suggext me, what is the best way to do this kind
Please ehlp me..
Now the folder name is Meter Track
I changed the Datasource to take away the extra quotes, it did not work.please help me.
Pallilu
Should all machines must have that folder to insert to the U:/Meter Track/Meters.mdb, if we change our datasource to thsi location.
Then please suggext me, what is the best way to do this kind
Please ehlp me..
Now the folder name is Meter Track
I changed the Datasource to take away the extra quotes, it did not work.please help me.
Pallilu
ASKER
Only requirement was to enter , like user should enter the values and submit,
And supervisors only 3 people go to that is network drive,U"/Meter Track/Meters.mdb andf check tha data entered by field employees.
And generate some reports and check tha data- only supervisors. employyes do not go to U:network drive
So That is the reason i thought when employees enter the info, that should dubmit to U:/Meter Track/Meters.mdb.
Thanks
pallilu
And supervisors only 3 people go to that is network drive,U"/Meter Track/Meters.mdb andf check tha data entered by field employees.
And generate some reports and check tha data- only supervisors. employyes do not go to U:network drive
So That is the reason i thought when employees enter the info, that should dubmit to U:/Meter Track/Meters.mdb.
Thanks
pallilu
Should be - I didn't notice the extra " inside the string :)
objCon.Open "PROVIDER=Microsoft.Jet.OL EDB.4.0;Da ta Source=U:/Meter Track/Meters.mdb"
Its still not clear where this DB is located...
Is it on the same machine or on a different machine?
Question - why have the db in a different location to the ASP files?
objCon.Open "PROVIDER=Microsoft.Jet.OL
Its still not clear where this DB is located...
Is it on the same machine or on a different machine?
Question - why have the db in a different location to the ASP files?
ASKER
Mc lord, Is not s good practice or not good for giving datasource to network drive, Then How should We perform this then, How will values get stored in the U:/Meter Track/Meters.mdb information enterd by employees. Supervisors will have access to Network drive. Everybody will have access to U: network drive in the department.
But I do not hink i am doing right thing og pointing to U:Drive , What if employe who is entering data does not have access to enter the information to U drive.
But I do not hink i am doing right thing og pointing to U:Drive , What if employe who is entering data does not have access to enter the information to U drive.
ASKER
Pointing the location in the network drive is working with your statement, I am onlu wooried about, What If the machine, that they are using it does not have access to U: network drive.
Am I confusing you with all the questions.
I want to know, wheather ASP page is not a good idea for performing this. Can we do differently to submit the values to U:drive. But I thought we need asp to validate all the information entered by employees right? How will I implement the asp page in the production server. i posted different question for the asp apge implementation in ASp section.
Mc lord Now I am very much worried.
Please give me courage..
Pallilu
Am I confusing you with all the questions.
I want to know, wheather ASP page is not a good idea for performing this. Can we do differently to submit the values to U:drive. But I thought we need asp to validate all the information entered by employees right? How will I implement the asp page in the production server. i posted different question for the asp apge implementation in ASp section.
Mc lord Now I am very much worried.
Please give me courage..
Pallilu
:)
Its still not clear.
I'll ask one question at a time - please try to answer it - currently you keep posting without answering the questions I keep asking.
Question...
Do the ASP page to add meter information work?
You need to take a step back and tackle 1 problem at a time :)
Its still not clear.
I'll ask one question at a time - please try to answer it - currently you keep posting without answering the questions I keep asking.
Question...
Do the ASP page to add meter information work?
You need to take a step back and tackle 1 problem at a time :)
ASKER
Okay sorry for jumping in and out
Yes When I insert the values using my local machine with this link "http://localhost.nicor.com/TCI/Testing.asp?pass=True&empid=12345&date=01/02/2004®=BELLWOOD"
the values inserted to the database. It is working. My problem is for production server.
To answer your question - it is working
pallilu
Yes When I insert the values using my local machine with this link "http://localhost.nicor.com/TCI/Testing.asp?pass=True&empid=12345&date=01/02/2004®=BELLWOOD"
the values inserted to the database. It is working. My problem is for production server.
To answer your question - it is working
pallilu
Ok, next question - I'll ask 2 this time :)
Is the connection string that you are using for the development machine and the production server the same?
Does it work on the production server?
Is the connection string that you are using for the development machine and the production server the same?
Does it work on the production server?
That is the question I am asking you, can I use the same connection string below
Set objCon = Server.CreateObject("ADODB .Connectio n")
objCon.Open "PROVIDER=Microsoft.Jet.OL EDB.4.0;Da ta Source=U:\Phonebk\Meter.md b"
for production and say it will work, i am worried because, Production server will look into the u drive right to insert the values , should I create a new user called prduser or machine name user to connect to U drive and read and insert, how that will work . can you explain me how that works?
2nd question
I do not have rights to Production server. I have not tried yet, once I am done with code, the other department moves code from development server to production server. I think I have to create a new project for this asp page.
Please tell me wheather my statements are clear or not?
Set objCon = Server.CreateObject("ADODB
objCon.Open "PROVIDER=Microsoft.Jet.OL
for production and say it will work, i am worried because, Production server will look into the u drive right to insert the values , should I create a new user called prduser or machine name user to connect to U drive and read and insert, how that will work . can you explain me how that works?
2nd question
I do not have rights to Production server. I have not tried yet, once I am done with code, the other department moves code from development server to production server. I think I have to create a new project for this asp page.
Please tell me wheather my statements are clear or not?
The connection string depends on how you have your local machine and your production machine set up :)
For example the paths on my development machine are C:\Websites\_EE\
The path on my live server is C:\Websites\_EE\
This means I don't have to change my connection string.
Currently you are mentioning a mapped drive and then you say you haven't tried your project on the production server - does this means the production server doesn't have the mapped drive?
I think you are jumping the gun a little.
Also once you project is on the production server you do not need to be concerned with users rights to the machine. Because you are using a web page to enter the data IIS uses the anonymous IIS user account - IUSR_???? and IWAM_???? (can't remember which one it is).
Ultimately in order to iron out the problems you think you have you need to get it onto the production machine otherwise its all guess work and there is no point in guessing because it causes you the worries you are mentioning.
For example the paths on my development machine are C:\Websites\_EE\
The path on my live server is C:\Websites\_EE\
This means I don't have to change my connection string.
Currently you are mentioning a mapped drive and then you say you haven't tried your project on the production server - does this means the production server doesn't have the mapped drive?
I think you are jumping the gun a little.
Also once you project is on the production server you do not need to be concerned with users rights to the machine. Because you are using a web page to enter the data IIS uses the anonymous IIS user account - IUSR_???? and IWAM_???? (can't remember which one it is).
Ultimately in order to iron out the problems you think you have you need to get it onto the production machine otherwise its all guess work and there is no point in guessing because it causes you the worries you are mentioning.
What I need to find out for the production server
1.Does it has U:drive access?
If it is yes for Number 1 , Do I have to request network admin to give access for IUSR to access to U:
Meter Track\Meters.mdb.
Please answer my questions
and please let me know, What I need to ask about production people and Network people.
Thanks a lot for your responses.
1.Does it has U:drive access?
If it is yes for Number 1 , Do I have to request network admin to give access for IUSR to access to U:
Meter Track\Meters.mdb.
Please answer my questions
and please let me know, What I need to ask about production people and Network people.
Thanks a lot for your responses.
Surely if you are setting up the app you can create what ever drives you think you need - why do you need to create a mapped drive - can't you just have the db with you ASP pages?
When your employees are accessing your your web page no permissions need to be set up for those users.
I think this line of questioning should end until you have tested you app on the production server - doing this will highlight what action you need to take.
When your employees are accessing your your web page no permissions need to be set up for those users.
I think this line of questioning should end until you have tested you app on the production server - doing this will highlight what action you need to take.
Lord Mc Fly
I have one more question.
My company is very particular about following standards
So I need to comment all my code in the asp page
In the code I have Function Setcap(value)
can you please explain what that function is used for in the code.
and aslo Used sTempStr,stmpstr, itempval, itmpval, can you give breif idea of why the variable are declared in the code. like this...
Dim sTempstr 'Temporary variable to hold the date value
If you can please write to me
Thanks
pallilu
I have one more question.
My company is very particular about following standards
So I need to comment all my code in the asp page
In the code I have Function Setcap(value)
can you please explain what that function is used for in the code.
and aslo Used sTempStr,stmpstr, itempval, itmpval, can you give breif idea of why the variable are declared in the code. like this...
Dim sTempstr 'Temporary variable to hold the date value
If you can please write to me
Thanks
pallilu
Captialises the first letter of each word, so....
this is a sentence becomes This Is A Sentence
It means that the Region field is always tidy - you can remove it if you like but it helps to maintain consistency, i.e. words will always start with a capital.
Function SetCap(Value)
If Value <> "" Then
sTempStr = ""
sTempStr = sTempStr & UCase(Mid(Value, 1, 1))
For iTempval = 2 To Len(Value)
If Mid(Value, iTempval-1, 1) = " " Then
sTempStr = sTempStr & UCase(Mid(Value, iTempval, 1))
Else
sTempStr = sTempStr + Mid(Value, iTempval, 1)
End If
Next
SetCap = sTempStr
End If
End Function
this is a sentence becomes This Is A Sentence
It means that the Region field is always tidy - you can remove it if you like but it helps to maintain consistency, i.e. words will always start with a capital.
Function SetCap(Value)
If Value <> "" Then
sTempStr = ""
sTempStr = sTempStr & UCase(Mid(Value, 1, 1))
For iTempval = 2 To Len(Value)
If Mid(Value, iTempval-1, 1) = " " Then
sTempStr = sTempStr & UCase(Mid(Value, iTempval, 1))
Else
sTempStr = sTempStr + Mid(Value, iTempval, 1)
End If
Next
SetCap = sTempStr
End If
End Function
The following...
Dim sTempStr, sTmpStr, iTempVal, iTmpVal
Some are used in the functions I provided - as standard I always put the vars in - gives me temp variable if a need them :)
Variables used by function - if functions where kept...
Dim sTempStr, sTmpStr, iTempVal
Hope that clears things up.
Dim sTempStr, sTmpStr, iTempVal, iTmpVal
Some are used in the functions I provided - as standard I always put the vars in - gives me temp variable if a need them :)
Variables used by function - if functions where kept...
Dim sTempStr, sTmpStr, iTempVal
Hope that clears things up.
ASKER
Lord Mc Fly Are you still here,
I need your help , i also posted the the question in different name,
I am putting application in production tomorrow. and now it is not working in development server
Localhost connecting to U:drive in my machine is working fine.
Admin also gave rights to development server to access to U:drive\Meter Track
Then also, i am getting message
Microsoft JET Database Engine (0x80004005)
'U:\Meter Track\Meter.mdb' is not a valid path. Make sure that the path name is spelled correctly and that you are connected to the server on which the file resides.
/MeterTracking/MeterTracki ng.asp, line 331
Please help me Mc Lord, What to do in this type of Situtation
I am very tensed now, I do not know what to do
Pallilu
I need your help , i also posted the the question in different name,
I am putting application in production tomorrow. and now it is not working in development server
Localhost connecting to U:drive in my machine is working fine.
Admin also gave rights to development server to access to U:drive\Meter Track
Then also, i am getting message
Microsoft JET Database Engine (0x80004005)
'U:\Meter Track\Meter.mdb' is not a valid path. Make sure that the path name is spelled correctly and that you are connected to the server on which the file resides.
/MeterTracking/MeterTracki
Please help me Mc Lord, What to do in this type of Situtation
I am very tensed now, I do not know what to do
Pallilu
Confirm the following...
Dev Machine has a mapped drive U:\Meter Track
Prod Machine has a mapped drive U:\Meter Track
You might want to try U:\Meter.mdb as the map might be to the 'Meter Track' folder which means the name of the folder isn't needed.
As for the question being posted elsewhere I don't know which name I should be looking for :)
Dev Machine has a mapped drive U:\Meter Track
Prod Machine has a mapped drive U:\Meter Track
You might want to try U:\Meter.mdb as the map might be to the 'Meter Track' folder which means the name of the folder isn't needed.
As for the question being posted elsewhere I don't know which name I should be looking for :)
ASKER
Lord Mc fly
I need your Help
I changed to connect to SQL server dtabase now,
and I am in the process of chnaging the drop down code with array value
Please help me Proviously I had Recordset, Noe I need av array value
The array name is avRegions
<select name="f_2">
<%If sForm(2) = "" then%>
<option value="">Please select</option>
<%End If
for nloopvar = 0 to ubound(avRegions,2)
If nloopvar = 0 then
Response.Write(chr(13)&chr (9) & "<option value="""&TRIM(cstr(avRegi ons(1,nloo pvar)))&"" " selected>" & trim(cstr(avRegions(1,nloo pvar))) & "</option>")
else
Response.Write(chr(13)&chr (9) & "<option value="""& trim(cstr(avRegions(1,nloo pvar)))&"" ">" & trim(cstr(avRegions(1,nloo pvar))) & "</option>")
end if
next
%>
</select>
Previously you helped me with this code
Do while not rsRegions.EOF
<select name="f_2">
<%If sForm(2) = "" then%>
<option value="">Please select</option>
<%End If
If sForm(2) = rsRegions("Region") then%>
<option value="<%=rsRegions("Regio n")%>" selected><%=rsRegions("Reg ion")%></o ption>
<%Else%>
<option value="<%=rsRegions("Regio n")%>"><%= rsRegions( "Region")% ></option>
<%End If
Can you plaese change the code to go through Array value
array name is avRegions
Please MC Lord.....it is urgent..
rsRegions.MoveNext
Loop%>
</select>
I need your Help
I changed to connect to SQL server dtabase now,
and I am in the process of chnaging the drop down code with array value
Please help me Proviously I had Recordset, Noe I need av array value
The array name is avRegions
<select name="f_2">
<%If sForm(2) = "" then%>
<option value="">Please select</option>
<%End If
for nloopvar = 0 to ubound(avRegions,2)
If nloopvar = 0 then
Response.Write(chr(13)&chr
else
Response.Write(chr(13)&chr
end if
next
%>
</select>
Previously you helped me with this code
Do while not rsRegions.EOF
<select name="f_2">
<%If sForm(2) = "" then%>
<option value="">Please select</option>
<%End If
If sForm(2) = rsRegions("Region") then%>
<option value="<%=rsRegions("Regio
<%Else%>
<option value="<%=rsRegions("Regio
<%End If
Can you plaese change the code to go through Array value
array name is avRegions
Please MC Lord.....it is urgent..
rsRegions.MoveNext
Loop%>
</select>
Now, I'm not sure of the structure of the array - it looks a little strange, you have a multi-dimensional array which means you are holding more than 1 peice of information for each Region - can you confirm this.
However I submit the following which works on the assumption you only hold one value for each region - i.e. the name of the region...
<select name="f_2">
<%If sForm(2) = "" then%>
<option value="">Please select</option>
<%End If
For nloopvar = 0 to UBound(avRegions)
If sForm(2) = avRegions(nloopvar) then%>
<option value="<%=Trim(avRegions(n loopvar))% >" selected><%=Trim(avRegions (nloopvar) )%></optio n>
<%Else%>
<option value="<%=Trim(avRegions(n loopvar))% >"><%=Trim (avRegions (nloopvar) )%></optio n>
<%End If
Next%>
</select>
However I submit the following which works on the assumption you only hold one value for each region - i.e. the name of the region...
<select name="f_2">
<%If sForm(2) = "" then%>
<option value="">Please select</option>
<%End If
For nloopvar = 0 to UBound(avRegions)
If sForm(2) = avRegions(nloopvar) then%>
<option value="<%=Trim(avRegions(n
<%Else%>
<option value="<%=Trim(avRegions(n
<%End If
Next%>
</select>
ASKER
Mc Lord
Thanks for your imeediate response
With the code you provided, i am not getting any valures for the dropdown box, Please help me with the code...
For multi dimensional, I just got sample from other web pages,
Please let me know, where we are doing wrong in displying. I am not geeting any syntax error, only the values are not getting displyed
Thanks
Thanks for your imeediate response
With the code you provided, i am not getting any valures for the dropdown box, Please help me with the code...
For multi dimensional, I just got sample from other web pages,
Please let me know, where we are doing wrong in displying. I am not geeting any syntax error, only the values are not getting displyed
Thanks
Can you include the code where you put the information into the array - cheers.
ASKER
Lord Mc Fly
I am very sorry
to ask you this, Thsi is the final time I am going to ask you for this
Finally I changed my mind to diaply drop down box values from the form
This is final....
Can you pleae, I hate to ask you this, but I need it desperaetey...
Can you please change the code to display the values for drodown box, for second load, for any error messages, the drop down value is getting lost,
Please MC lord
<SELECT name="f_2" value="<%=sForm(2)%>">
<OPTION value =""></OPTION>
<OPTION value ="BELLWOOD">BELLWOOD</OPTI ON>
<OPTION value ="GLEN ELLYN">GLEN ELLYN</OPTION>
</SELECT>
What do I need to change this, to have the selected value for any error message or 2nd load.
Please.. Final time
I am very sorry
to ask you this, Thsi is the final time I am going to ask you for this
Finally I changed my mind to diaply drop down box values from the form
This is final....
Can you pleae, I hate to ask you this, but I need it desperaetey...
Can you please change the code to display the values for drodown box, for second load, for any error messages, the drop down value is getting lost,
Please MC lord
<SELECT name="f_2" value="<%=sForm(2)%>">
<OPTION value =""></OPTION>
<OPTION value ="BELLWOOD">BELLWOOD</OPTI
<OPTION value ="GLEN ELLYN">GLEN ELLYN</OPTION>
</SELECT>
What do I need to change this, to have the selected value for any error message or 2nd load.
Please.. Final time
Can't be done.
Use the method I suggested earlier in the thead...
In the ASP code at the top of the page...
-------------------------- ---------- ---------- ---------- -----
Dim sReg(3)
sReg(0) = "Bellwood"
sReg(1) = "Glen Ellyn"
sReg(2) = "Region C"
sReg(3) = "Region D"
In the HTML...
-------------------------- ---------- ---------- ---------- ------
<select name="f_2">
<%If sForm(2) = "" then%>
<option value="">Please select</option>
<%End If
For iLp = 0 to UBound(sReg)
If sForm(2) = sReg(iLp) then%>
<option value="<%=sReg(iLp)%>" selected><%=sReg(iLp)%></o ption>
<%Else%>
<option value="<%=sReg(iLp)%>"><%= sReg(iLp)% ></option>
<%End If
Next%>
</select>
:)
Use the method I suggested earlier in the thead...
In the ASP code at the top of the page...
--------------------------
Dim sReg(3)
sReg(0) = "Bellwood"
sReg(1) = "Glen Ellyn"
sReg(2) = "Region C"
sReg(3) = "Region D"
In the HTML...
--------------------------
<select name="f_2">
<%If sForm(2) = "" then%>
<option value="">Please select</option>
<%End If
For iLp = 0 to UBound(sReg)
If sForm(2) = sReg(iLp) then%>
<option value="<%=sReg(iLp)%>" selected><%=sReg(iLp)%></o
<%Else%>
<option value="<%=sReg(iLp)%>"><%=
<%End If
Next%>
</select>
:)
Where was that other question - I never did find it :(
ASKER
With Mike Hall12 user ID
Under ASP . Please post the answer there so that I can Give points to you
Actually this questions belongs there, I extended my project requirements and posted.
Thanks
Pallilu
Under ASP . Please post the answer there so that I can Give points to you
Actually this questions belongs there, I extended my project requirements and posted.
Thanks
Pallilu
I think posting to that question would be inappropriate :)
I won't worry about the extra points :)
I won't worry about the extra points :)
ASKER
Thanks a lot for your help Mc Lord, I asked to shif t 1 day for implementation. If you did not help, I would have been in deep trouble.
ASKER
Mc Lord I need your help again to figure out Why it is inserting only one record , even if I put 2 or 3 meter information, it is inserting only first record, Please tell me where I am doing wrong.
I tokk out from the loop even then it is inserting 1 record for employee ID
33333 02/03/2004 Glen Ellyn 0987654 OUT
It should insert
33333 02/03/2004 Glen Ellyn 0987654 OUT
33333 02/03/2004 Glen Ellyn 5678899 IN
33333 02/03/2004 Glen Ellyn 4567893 IN
Please ehlp me, If you can
Thanks alot for your help.
Pallilu
I tokk out from the loop even then it is inserting 1 record for employee ID
33333 02/03/2004 Glen Ellyn 0987654 OUT
It should insert
33333 02/03/2004 Glen Ellyn 0987654 OUT
33333 02/03/2004 Glen Ellyn 5678899 IN
33333 02/03/2004 Glen Ellyn 4567893 IN
Please ehlp me, If you can
Thanks alot for your help.
Pallilu
ASKER
Below is the code, i have
<%@ Language=VBScript %>
<!--#include file="resources\incConstan ts.asp"-->
<%
'************************* ********** ********** ********** ********** *********
'*
'* ASP Name: MeterTracking.asp
'* Description: MeterTracking form is used for Fied Employees to enter the Meter Info
'* Date Created:04/20/04
'* Author: Pallilu
'*
'************************* ********** ********** ********** ********** ******
'Function / Sub Variables
Dim objCon 'Used for database connection
Dim sTempStr 'Temporary variable to hold the date values
Dim sTmpStr 'Temporary variable to hold the date values
Dim iTempVal 'Temporary variable to hold the date values
Dim iTmpVal 'Temporary variable to hold the date values
'Page Variables
Dim sForm(2) 'Variable to hold the form values
Dim sData(9,1) 'Variable to hold the Meter data values
Dim sErrMsg 'Variable to hold the error messages
Dim sQuery 'Variable to hold the query value
Dim iLp 'Variable for looping the Meter Info
Dim iLoop 'Variable for looping the Meter Info
Dim bIsMeter 'Variable to check the flag for MeterInfo
Dim sRegions 'Variable to get the region info
Dim rsRegions 'Variable to loop the regions
Dim sEmployeeID 'Variable used to hold the employeeId of the Employee
Dim sMeterDate 'Variable used to hold the MeterDate for the Meter
Dim sRegion 'Variable used to hold the region for the Meter
Dim sMeterSerialNo 'Variable used to hold the Meter SerialNo for the Meter
Dim nAutoID 'Variable used to hold the AutoID
Dim sStatus 'Variable used to hold the status IN/OUT for the Meter
Dim sReg(1) 'Variable to hold the region value
'************************* ********** ********** *******
' Create/Format Input Dictionary to PageController *
'************************* ********** ********** *******
Set oInputDict = Server.CreateObject("Scrip ting.Dicti onary")
Set oInputDict = InitializeInput(cgFORMAT_A S_DICTIONA RY, cgFORMAT_AS_DICTIONARY)
'************************* ********** ********** ********** ***
' Create/Format Output Dictionary from PageController *
'************************* ********** ********** ********** ***
Set oOutPutDict = Server.CreateObject("Scrip ting.Dicti onary")
'Load IN/OUT Deafult
For iLp = 0 to 9
sData(iLp,1) = "OUT"
Next
sReg(0) = "Bellwood"
sReg(1) = "Glen Ellyn"
'Get Passed Back Form Data After INSERT
If CBool(Request.QueryString( "pass")) = True then
sForm(0) = Request.QueryString("empid ")
sForm(1) = Request.QueryString("date" )
sForm(2) = Request.QueryString("reg")
End If
'Form Has Been Submitted
If Request.Form("Action") = "Add" then
sErrMsg = ""
'Collect Up The General Info
For iLp = 0 to 2
sForm(iLp) = Trim(Request.Form("f_"&iLp ))
Next
'Collect Up The Meter Info
For iLp = 0 to 9
For iLoop = 0 to 1
sData(iLp,iLoop) = Trim(Request.Form("m_"&iLo op&"_"&iLp ))
Next
Next
'Validation of form with proper values
If sErrMsg = "" then
'validation for Employee ID
If (sForm(0) = "") or (sForm(0) = "99999") or not (IsNumeric(sForm(0)))or (Len(sForm(0)) <> 5) then
If sForm(0) = "" then
sErrMsg = "Error: Employee ID - Required field."
Elseif sForm(0) = "99999" or not IsNumeric(sForm(0))or (Len(sForm(0)) <> 5) then
sErrMsg = "Error: Employee ID - Invalid Value."
End If
Else
'validation for Date
If sForm(1) = "" then
sErrMsg = "Error: Date - Required Field."
Else
sForm(1) = PadDate(sForm(1))
If ValidateDate(sForm(1),sErr Msg) = True then
sForm(1) = sErrMsg
sErrMsg = ""
'validation for Region
If sForm(2) = "" then
sErrMsg = "Error: Region - Required Field."
Else
sForm(2) = SetCap(sForm(2))
'validation for Meter Info
bIsMeter = False
'If meter details yes, check for valid Meter info
For iLp = 0 to 9
If sData(iLp,0) <> "" then
If Left(sData(iLp,0),1) = "7" then
sErrMsg = "Error: Meter No (" & sData(iLp,0) & ") - Can't Start With 7."
Else
If Len(sData(iLp,0)) <> 7 then
sErrMsg = "Error: Meter No (" & sData(iLp,0) & ") - Wrong Length."
Else
bIsMeter = True
End If
End If
If sErrMsg <> "" then
iLp = 9
End If
End If
Next
'Checking for Meter Details
If sErrMsg = "" then
'All Ok - INSERT Details into DB
If bIsMeter = False then
sErrMsg = "Error: Meter No Details - Required."
Else
If sErrMsg = "" then
For iLp = 0 to 9
If sData(iLp,0) <> "" then
sEmployeeID = SQL(sForm(0))
sMeterDate = sForm(1)
sRegion = SQL(sForm(2))
sMeterSerialNo = SQL(sData(iLp,0))
sStatus = sData(iLp,1)
'Add the values to input dictionary
oInputDict.Add "sEmployeeID", sEmployeeID
oInputDict.Add "sMeterDate", sMeterDate
oInputDict.Add "sRegion", sRegion
oInputDict.Add "sMeterSerialNo", sMeterSerialNo
oInputDict.Add "sStatus", sStatus
End If
Next
'************************* ********** ********** ********** ***
'Call the Page controller.
'************************* ********** ********** ********** ***
Set oPC = Server.CreateObject ("CmpMTCTRL.CMTCTRL")
lPCResponseCode = oPC.ProcessPage(oInputDict , oOutputDict, sRedirectURL)
Response.Redirect "MeterTracking.asp?pass=Tr ue&empid=" & sForm(0) & "&date=" & sForm(1) & "®=" & sForm(2)
End If
End If
End If
End If
End If
End If
End If
End If
End If
CloseDB
%>
<html>
<head>
<title>Meter Information</title>
</head>
<body>
<table width="500" cellspacing="1" cellpadding="0" border="0" bgcolor="#000000" align=center>
<form name="Reading" method="post" action="MeterTracking.asp" >
<tr bgcolor="#FFFFFF">
<td>
<table width="500" cellspacing="0" cellpadding="2" border="0">
<tr>
<td height="30"><b>M E T E R I N F O R M A T I O N</b></td>
</tr>
</table>
<td>
</tr>
<%If sErrMsg <> "" then%>
<tr bgcolor="#FFFFFF">
<td>
<table width="500" cellspacing="0" cellpadding="2" border="0">
<tr>
<td height="30"><font color="#FF0000"><%=sErrMsg %></font>
</td>
</tr>
</table>
</td>
</tr>
<%End If%>
<%If CBool(Request.QueryString( "pass")) = True then%>
<tr bgcolor="#FFFFFF">
<td>
<table width="500" cellspacing="0" cellpadding="2" border="0">
<tr>
<td height="30">Notice: Info Successfully inserted into DB.
</td>
</tr>
</table>
</td>
</tr>
<%End If%>
<tr bgcolor="#FFFFFF">
<td>
<table width="500" cellspacing="0" cellpadding="2" border="0">
<tr>
<td colspan="2" height="30"><b>General Details:</b></td>
</tr>
<tr>
<td width="100" height="25">*Employee ID:
</td>
<td width="400">
<input type="text" name="f_0" size="5" maxlength="5" value="<%=sForm(0)%>">
</td>
</tr>
<tr>
<td height="25">*Date:
</td>
<td>
<input type="text" name="f_1" size="10" maxlength="10" value="<%=sForm(1)%>">(Ex- 01/01/2004 )
</td>
</tr>
<tr>
<td height="25">*Region:
</td>
<td>
<select name="f_2">
<%If sForm(2) = "" then%>
<option value="">Please select</option>
<%End If
For iLp = 0 to UBound(sReg)
If sForm(2) = sReg(iLp) then%>
<option value="<%=sReg(iLp)%>" selected><%=sReg(iLp)%></o ption>
<%Else%>
<option value="<%=sReg(iLp)%>"><%= sReg(iLp)% ></option>
<%End If
Next%>
</select>
</td>
</tr>
</table>
</td>
</tr>
<tr bgcolor="#FFFFFF">
<td>
<table width="500" cellspacing="0" cellpadding="2" border="0">
<tr>
<td colspan="4" height="30"><b>Meter Numbers:</b>
</td>
</tr>
<%For iLp = 0 to 9%>
<tr>
<td width="100" height="25">Meter No:
</td>
<td width="125">
<input type="text" name="m_0_<%=iLp%>" size="6" maxlength="7" value="<%=sData(iLp,0)%>"" >(7 Digits)
</td>
<td width="50">Status:
</td>
<td width="225">
<input type="radio" name="m_1_<%=iLp%>" value="OUT" <%If sData(iLp,1) = "OUT" then%>checked<%End If%>> OUT
<input type="radio" name="m_1_<%=iLp%>" value="IN" <%If sData(iLp,1) = "IN" then%>checked<%End If%>> IN
</td>
</tr>
<%Next%>
</table>
</td>
</tr>
<tr bgcolor="#FFFFFF">
<td>
<table width="500" cellspacing="0" cellpadding="2" border="0">
<tr>
<td height="30" align="center">
<input type="hidden" name="Action" value="Add">
<input type="submit" name="Button" value="Submit">
<input id=reset name=reset type=reset value=Reset></TD>
</td>
</tr>
</table>
</td>
</tr>
</form>
</table>
</body>
</html>
<%
'Function for Date value
Function PadDate(Value)
If Len(Value) = 0 then
PadDate = Value
Else
If IsDate(Value) then
sTmpStr = ""
sTempStr = ""
iTempVal = 0
For iLp = 1 to Len(Value)
If IsNumeric(Mid(Value,iLp,1) ) then
sTempStr = sTempStr & Mid(Value,iLp,1)
Else
If Len(sTempStr) > 2 then
PadDate = Value
Else
sTempStr = Left("00",2-Len(sTempStr)) & sTempStr & "/"
sTmpStr = sTmpStr & sTempStr
sTempStr = ""
End If
End If
Next
If Len(sTempStr) > 4 then
PadDate = Value
Else
PadDate = sTmpStr & Left("2000",4-Len(sTempStr )) & sTempStr
End If
Else
PadDate = Value
End If
End If
End Function
'Function for validating Date value entered by user
Function ValidateDate(Value, sErrMsg)
If Len(Value) <> 10 then
ValidateDate = False
sErrMsg = "Error: Date - Invalid."
Else
If IsNumeric(Mid(Value,1,2)) and IsNumeric(Mid(Value,4,2)) and IsNumeric(Mid(Value,7,4)) then
Value = Mid(Value,1,2) & "/" & Mid(Value,4,2) & "/" & Mid(Value,7,4)
If IsDate(Value) then
ValidateDate = True
sErrMsg = Value
Else
ValidateDate = False
sErrMsg = "Error: Date - Invalid."
End If
Else
ValidateDate = False
sErrMsg = "Error: Date - Invalid."
End If
End If
End Function
'Function to replace quotes
Function SQL(Value)
SQL = Replace(Value,"'","''")
End Function
'Function used for capitilizing the values
Function SetCap(Value)
If Value <> "" Then
sTempStr = ""
sTempStr = sTempStr & UCase(Mid(Value, 1, 1))
For iTempval = 2 To Len(Value)
If Mid(Value, iTempval-1, 1) = " " Then
sTempStr = sTempStr & UCase(Mid(Value, iTempval, 1))
Else
sTempStr = sTempStr + Mid(Value, iTempval, 1)
End If
Next
SetCap = sTempStr
End If
End Function
%>
<%@ Language=VBScript %>
<!--#include file="resources\incConstan
<%
'*************************
'*
'* ASP Name: MeterTracking.asp
'* Description: MeterTracking form is used for Fied Employees to enter the Meter Info
'* Date Created:04/20/04
'* Author: Pallilu
'*
'*************************
'Function / Sub Variables
Dim objCon 'Used for database connection
Dim sTempStr 'Temporary variable to hold the date values
Dim sTmpStr 'Temporary variable to hold the date values
Dim iTempVal 'Temporary variable to hold the date values
Dim iTmpVal 'Temporary variable to hold the date values
'Page Variables
Dim sForm(2) 'Variable to hold the form values
Dim sData(9,1) 'Variable to hold the Meter data values
Dim sErrMsg 'Variable to hold the error messages
Dim sQuery 'Variable to hold the query value
Dim iLp 'Variable for looping the Meter Info
Dim iLoop 'Variable for looping the Meter Info
Dim bIsMeter 'Variable to check the flag for MeterInfo
Dim sRegions 'Variable to get the region info
Dim rsRegions 'Variable to loop the regions
Dim sEmployeeID 'Variable used to hold the employeeId of the Employee
Dim sMeterDate 'Variable used to hold the MeterDate for the Meter
Dim sRegion 'Variable used to hold the region for the Meter
Dim sMeterSerialNo 'Variable used to hold the Meter SerialNo for the Meter
Dim nAutoID 'Variable used to hold the AutoID
Dim sStatus 'Variable used to hold the status IN/OUT for the Meter
Dim sReg(1) 'Variable to hold the region value
'*************************
' Create/Format Input Dictionary to PageController *
'*************************
Set oInputDict = Server.CreateObject("Scrip
Set oInputDict = InitializeInput(cgFORMAT_A
'*************************
' Create/Format Output Dictionary from PageController *
'*************************
Set oOutPutDict = Server.CreateObject("Scrip
'Load IN/OUT Deafult
For iLp = 0 to 9
sData(iLp,1) = "OUT"
Next
sReg(0) = "Bellwood"
sReg(1) = "Glen Ellyn"
'Get Passed Back Form Data After INSERT
If CBool(Request.QueryString(
sForm(0) = Request.QueryString("empid
sForm(1) = Request.QueryString("date"
sForm(2) = Request.QueryString("reg")
End If
'Form Has Been Submitted
If Request.Form("Action") = "Add" then
sErrMsg = ""
'Collect Up The General Info
For iLp = 0 to 2
sForm(iLp) = Trim(Request.Form("f_"&iLp
Next
'Collect Up The Meter Info
For iLp = 0 to 9
For iLoop = 0 to 1
sData(iLp,iLoop) = Trim(Request.Form("m_"&iLo
Next
Next
'Validation of form with proper values
If sErrMsg = "" then
'validation for Employee ID
If (sForm(0) = "") or (sForm(0) = "99999") or not (IsNumeric(sForm(0)))or (Len(sForm(0)) <> 5) then
If sForm(0) = "" then
sErrMsg = "Error: Employee ID - Required field."
Elseif sForm(0) = "99999" or not IsNumeric(sForm(0))or (Len(sForm(0)) <> 5) then
sErrMsg = "Error: Employee ID - Invalid Value."
End If
Else
'validation for Date
If sForm(1) = "" then
sErrMsg = "Error: Date - Required Field."
Else
sForm(1) = PadDate(sForm(1))
If ValidateDate(sForm(1),sErr
sForm(1) = sErrMsg
sErrMsg = ""
'validation for Region
If sForm(2) = "" then
sErrMsg = "Error: Region - Required Field."
Else
sForm(2) = SetCap(sForm(2))
'validation for Meter Info
bIsMeter = False
'If meter details yes, check for valid Meter info
For iLp = 0 to 9
If sData(iLp,0) <> "" then
If Left(sData(iLp,0),1) = "7" then
sErrMsg = "Error: Meter No (" & sData(iLp,0) & ") - Can't Start With 7."
Else
If Len(sData(iLp,0)) <> 7 then
sErrMsg = "Error: Meter No (" & sData(iLp,0) & ") - Wrong Length."
Else
bIsMeter = True
End If
End If
If sErrMsg <> "" then
iLp = 9
End If
End If
Next
'Checking for Meter Details
If sErrMsg = "" then
'All Ok - INSERT Details into DB
If bIsMeter = False then
sErrMsg = "Error: Meter No Details - Required."
Else
If sErrMsg = "" then
For iLp = 0 to 9
If sData(iLp,0) <> "" then
sEmployeeID = SQL(sForm(0))
sMeterDate = sForm(1)
sRegion = SQL(sForm(2))
sMeterSerialNo = SQL(sData(iLp,0))
sStatus = sData(iLp,1)
'Add the values to input dictionary
oInputDict.Add "sEmployeeID", sEmployeeID
oInputDict.Add "sMeterDate", sMeterDate
oInputDict.Add "sRegion", sRegion
oInputDict.Add "sMeterSerialNo", sMeterSerialNo
oInputDict.Add "sStatus", sStatus
End If
Next
'*************************
'Call the Page controller.
'*************************
Set oPC = Server.CreateObject ("CmpMTCTRL.CMTCTRL")
lPCResponseCode = oPC.ProcessPage(oInputDict
Response.Redirect "MeterTracking.asp?pass=Tr
End If
End If
End If
End If
End If
End If
End If
End If
End If
CloseDB
%>
<html>
<head>
<title>Meter Information</title>
</head>
<body>
<table width="500" cellspacing="1" cellpadding="0" border="0" bgcolor="#000000" align=center>
<form name="Reading" method="post" action="MeterTracking.asp"
<tr bgcolor="#FFFFFF">
<td>
<table width="500" cellspacing="0" cellpadding="2" border="0">
<tr>
<td height="30"><b>M E T E R I N F O R M A T I O N</b></td>
</tr>
</table>
<td>
</tr>
<%If sErrMsg <> "" then%>
<tr bgcolor="#FFFFFF">
<td>
<table width="500" cellspacing="0" cellpadding="2" border="0">
<tr>
<td height="30"><font color="#FF0000"><%=sErrMsg
</td>
</tr>
</table>
</td>
</tr>
<%End If%>
<%If CBool(Request.QueryString(
<tr bgcolor="#FFFFFF">
<td>
<table width="500" cellspacing="0" cellpadding="2" border="0">
<tr>
<td height="30">Notice: Info Successfully inserted into DB.
</td>
</tr>
</table>
</td>
</tr>
<%End If%>
<tr bgcolor="#FFFFFF">
<td>
<table width="500" cellspacing="0" cellpadding="2" border="0">
<tr>
<td colspan="2" height="30"><b>General Details:</b></td>
</tr>
<tr>
<td width="100" height="25">*Employee ID:
</td>
<td width="400">
<input type="text" name="f_0" size="5" maxlength="5" value="<%=sForm(0)%>">
</td>
</tr>
<tr>
<td height="25">*Date:
</td>
<td>
<input type="text" name="f_1" size="10" maxlength="10" value="<%=sForm(1)%>">(Ex-
</td>
</tr>
<tr>
<td height="25">*Region:
</td>
<td>
<select name="f_2">
<%If sForm(2) = "" then%>
<option value="">Please select</option>
<%End If
For iLp = 0 to UBound(sReg)
If sForm(2) = sReg(iLp) then%>
<option value="<%=sReg(iLp)%>" selected><%=sReg(iLp)%></o
<%Else%>
<option value="<%=sReg(iLp)%>"><%=
<%End If
Next%>
</select>
</td>
</tr>
</table>
</td>
</tr>
<tr bgcolor="#FFFFFF">
<td>
<table width="500" cellspacing="0" cellpadding="2" border="0">
<tr>
<td colspan="4" height="30"><b>Meter Numbers:</b>
</td>
</tr>
<%For iLp = 0 to 9%>
<tr>
<td width="100" height="25">Meter No:
</td>
<td width="125">
<input type="text" name="m_0_<%=iLp%>" size="6" maxlength="7" value="<%=sData(iLp,0)%>""
</td>
<td width="50">Status:
</td>
<td width="225">
<input type="radio" name="m_1_<%=iLp%>" value="OUT" <%If sData(iLp,1) = "OUT" then%>checked<%End If%>> OUT
<input type="radio" name="m_1_<%=iLp%>" value="IN" <%If sData(iLp,1) = "IN" then%>checked<%End If%>> IN
</td>
</tr>
<%Next%>
</table>
</td>
</tr>
<tr bgcolor="#FFFFFF">
<td>
<table width="500" cellspacing="0" cellpadding="2" border="0">
<tr>
<td height="30" align="center">
<input type="hidden" name="Action" value="Add">
<input type="submit" name="Button" value="Submit">
<input id=reset name=reset type=reset value=Reset></TD>
</td>
</tr>
</table>
</td>
</tr>
</form>
</table>
</body>
</html>
<%
'Function for Date value
Function PadDate(Value)
If Len(Value) = 0 then
PadDate = Value
Else
If IsDate(Value) then
sTmpStr = ""
sTempStr = ""
iTempVal = 0
For iLp = 1 to Len(Value)
If IsNumeric(Mid(Value,iLp,1)
sTempStr = sTempStr & Mid(Value,iLp,1)
Else
If Len(sTempStr) > 2 then
PadDate = Value
Else
sTempStr = Left("00",2-Len(sTempStr))
sTmpStr = sTmpStr & sTempStr
sTempStr = ""
End If
End If
Next
If Len(sTempStr) > 4 then
PadDate = Value
Else
PadDate = sTmpStr & Left("2000",4-Len(sTempStr
End If
Else
PadDate = Value
End If
End If
End Function
'Function for validating Date value entered by user
Function ValidateDate(Value, sErrMsg)
If Len(Value) <> 10 then
ValidateDate = False
sErrMsg = "Error: Date - Invalid."
Else
If IsNumeric(Mid(Value,1,2)) and IsNumeric(Mid(Value,4,2)) and IsNumeric(Mid(Value,7,4)) then
Value = Mid(Value,1,2) & "/" & Mid(Value,4,2) & "/" & Mid(Value,7,4)
If IsDate(Value) then
ValidateDate = True
sErrMsg = Value
Else
ValidateDate = False
sErrMsg = "Error: Date - Invalid."
End If
Else
ValidateDate = False
sErrMsg = "Error: Date - Invalid."
End If
End If
End Function
'Function to replace quotes
Function SQL(Value)
SQL = Replace(Value,"'","''")
End Function
'Function used for capitilizing the values
Function SetCap(Value)
If Value <> "" Then
sTempStr = ""
sTempStr = sTempStr & UCase(Mid(Value, 1, 1))
For iTempval = 2 To Len(Value)
If Mid(Value, iTempval-1, 1) = " " Then
sTempStr = sTempStr & UCase(Mid(Value, iTempval, 1))
Else
sTempStr = sTempStr + Mid(Value, iTempval, 1)
End If
Next
SetCap = sTempStr
End If
End Function
%>
ASKER
Mc Lord, I changed the code to move process page code before Endif, Where should I access this now
Below is the one I changed, Even then it is inserting only 1 record.
If sErrMsg = "" then
For iLp = 0 to 9
If sData(iLp,0) <> "" then
sEmployeeID = SQL(sForm(0))
sMeterDate = sForm(1)
sRegion = SQL(sForm(2))
sMeterSerialNo = SQL(sData(iLp,0))
sStatus = sData(iLp,1)
'Add the values to input dictionary
oInputDict.Add "sEmployeeID", sEmployeeID
oInputDict.Add "sMeterDate", sMeterDate
oInputDict.Add "sRegion", sRegion
oInputDict.Add "sMeterSerialNo", sMeterSerialNo
oInputDict.Add "sStatus", sStatus
'************************* ********** ********** ********** ***
'Call the Page controller.
'************************* ********** ********** ********** ***
Set oPC = Server.CreateObject ("CmpMTCTRL.CMTCTRL")
lPCResponseCode = oPC.ProcessPage(oInputDict , oOutputDict, sRedirectURL)
End If
Next
Response.Redirect "MeterTracking.asp?pass=Tr ue&empid=" & sForm(0) & "&date=" & sForm(1) & "®=" & sForm(2)
End If
Below is the one I changed, Even then it is inserting only 1 record.
If sErrMsg = "" then
For iLp = 0 to 9
If sData(iLp,0) <> "" then
sEmployeeID = SQL(sForm(0))
sMeterDate = sForm(1)
sRegion = SQL(sForm(2))
sMeterSerialNo = SQL(sData(iLp,0))
sStatus = sData(iLp,1)
'Add the values to input dictionary
oInputDict.Add "sEmployeeID", sEmployeeID
oInputDict.Add "sMeterDate", sMeterDate
oInputDict.Add "sRegion", sRegion
oInputDict.Add "sMeterSerialNo", sMeterSerialNo
oInputDict.Add "sStatus", sStatus
'*************************
'Call the Page controller.
'*************************
Set oPC = Server.CreateObject ("CmpMTCTRL.CMTCTRL")
lPCResponseCode = oPC.ProcessPage(oInputDict
End If
Next
Response.Redirect "MeterTracking.asp?pass=Tr
End If
ASKER
Mc Lord Please
When I try to debug the code with VB code, I am getting error while inserting the second record THe error
The Object variable or with Block Varaible not set
Can you help me resolve this issue
Pallilu
When I try to debug the code with VB code, I am getting error while inserting the second record THe error
The Object variable or with Block Varaible not set
Can you help me resolve this issue
Pallilu
Unfortunately I'm not familiar with the technique you are using to INSERT / add the record so I am unable to help with the problem that you are having.
What was wrong with using the regular INSERT.
I don't know what to suggest, sorry.
What was wrong with using the regular INSERT.
I don't know what to suggest, sorry.
ASKER
Lord McFly
I have one question regarding this post. I am enhancing this form to make the drop down list a from the database values with the array value.
Please suggest me wheather we can do this with this post.
Below is the code I want to use for drop down box
<select name="f_2">
<%If sForm(2) = "" then%>
<option value="">Please select</option>
<%End If
For nLp = 0 to UBound(sReg)
If sForm(2) = sReg(nLp) then%>
<option value="<%=sReg(nLp)%>" selected><%=sReg(nLp)%></o ption>
<%Else%>
<option value="<%=sReg(nLp)%>"><%= sReg(nLp)% ></option>
<%End If
Next%>
</select>
How should i begin the execute command for dropdown values
I have Open DB ststement after that I addded these lines
sRegions = "Select Regions from Region"
sReg() = objCon.Execute(sRegions)
Response.Write sReg(1)
Response.End
I am not getting anything when I view in browser.
Please help me, if you can.
Thanks
Pallilu
I have one question regarding this post. I am enhancing this form to make the drop down list a from the database values with the array value.
Please suggest me wheather we can do this with this post.
Below is the code I want to use for drop down box
<select name="f_2">
<%If sForm(2) = "" then%>
<option value="">Please select</option>
<%End If
For nLp = 0 to UBound(sReg)
If sForm(2) = sReg(nLp) then%>
<option value="<%=sReg(nLp)%>" selected><%=sReg(nLp)%></o
<%Else%>
<option value="<%=sReg(nLp)%>"><%=
<%End If
Next%>
</select>
How should i begin the execute command for dropdown values
I have Open DB ststement after that I addded these lines
sRegions = "Select Regions from Region"
sReg() = objCon.Execute(sRegions)
Response.Write sReg(1)
Response.End
I am not getting anything when I view in browser.
Please help me, if you can.
Thanks
Pallilu