Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

ASP or ActiveX control

Status
Not open for further replies.

sgore

Programmer
Jul 22, 2001
30
CA
I don't know if this can be done using ASP.

1. I need a page that comes up with a control box or text area that is pre-populated with information from a data base. For example:
------------------------------
field1 field2 field3 field4
...
...
...
field1 field2 field3 field4

<submit button>

This to be repeated until all information is gathered.

2. I need to be able to highlight one of those rows and press a button. Once the button is pressed those field items will then be populated in an update page, where the values can be changed.

Does anyone know if this can be done using ASP? or do I need to use some sort of activeX control??
 
Sure, you can definitely do that in ASP.

There are a few ways you can display the list of records to be selected. Look at these two examples and let me know which one best fits your needs. It'll be easier to provide you with some detailed help knowing which one works better for you ??

Example #1 - Radio Button Selection

<html>
<body>
<form>
<input type=&quot;radio&quot; name=&quot;recselect&quot; value=&quot;recid&quot;> Joe Smith President 21 Yrs Old<br>
<input type=&quot;radio&quot; name=&quot;recselect&quot; value=&quot;recid&quot;> John Doe CEO 24 Yrs Old<br>
<input type=&quot;radio&quot; name=&quot;recselect&quot; value=&quot;recid&quot;> Jack Perry Chairman 31 Yrs Old<br><br>
List rest of the records here ..<br><br>
<input type=&quot;submit&quot; value=&quot;Submit&quot;>
</form>
</body>
</html>



Example #2 - List Box Selection

<html>
<body>
<form>
<select size=&quot;10&quot; name=&quot;recselect&quot;>
<option value=&quot;recid&quot;>Joe Smith President 21 Yrs Old</option>
<option value=&quot;recid&quot;>John Doe CEO 24 Yrs Old</option>
<option value=&quot;recid&quot;>Jack Perry Chairman 31 Yrs Old</option>
<option value=&quot;&quot;></option>
<option value=&quot;&quot;>List rest of records here..</option>
</select><br><br>

<input type=&quot;submit&quot; value=&quot;Submit&quot;>
</form>
</body>
</html>


:)

ToddWW
 
The list box method would be a better solution in my case.

I am generating a list of games to be played with (date, time, location and opponent). My date field is broken up into (month, day, year) three seperate fields.
 
OK. Just a few more questions that will help me explain how we can identify the record that was selected to the next page.


Do you have a gameID field in your table that contains a unique ID number for each record ??

If the answer to the above is yes...

What is that field name ??




If the answer to the above was no, answer the rest of these questions.

What database are you using ??

How are these records initially Added to the database ??

Currently, what is unique about each record ?? For example, could you possibly have two different game records with the same date and time values ??


Answer those and I can give you some great tips and code to accomplish what you need.

ToddWW :)
 
I do not have a game id.

I am using a microsoft access database.

I use a standard sql insert statement. Here is the sql I used to insert into the table.

conntemp.Execute(&quot;insert into games (g_year, g_month, g_day, g_time, team, opponent, location, type) values ('&quot; & game_year & &quot;', '&quot; & game_month & &quot;', '&quot; & game_day & &quot;', '&quot; & game_time & &quot;', '&quot; & game_team & &quot;', '&quot; & game_opponent & &quot;', '&quot; & game_location & &quot;', '&quot; & game_type & &quot;')&quot;)

I forgot to mention the field type. type = v ( varsity ) jv (jr varsity)

I use an autonumber to give each entry a unique identifier.

There is a chance that their can be a game on the same date and time (Varsity and Jr Varsity), however their location would be different.

Anything else that will help?
 
OK, perfect. It will just take me a minute to put something together for you. In the meantime, reply back with the fieldname for the autonumber.

ToddWW :)
 
the fieldname for the autonumber is &quot;id&quot;

Thanks,
Scott
 
OK. Let's start with this entire page, then you can cut / paste / crop and edit into your own layout once you see it working.

You'll want to start by copying this entire page into a test page and running it. But read the notes below because you need to provide some values before it will work.


Important Notes ..

#1: The submit button calls a JavaScript function that currently does nothing. But you can put validation in this function to prevent submittal on conditional statments.

#2: The action value in the form tag needs to be set properly to the page that you want to submit the information to.

#3: I figured that with all the data you want to display in the list box for each record, that it could potentially get wider than you want. Therefore, I wrote a little method that allows you to limit the amount of characters displayed for opponents and locations. All you have to do is set the variables.

#4: You must set the strProvider string to your current connection string or DSN name.

#5: The value of each option is set to the unique id field in your table. We're going to get that value on the next page using the Request.Form(&quot;gamelist&quot;) method and build an SQL query to select that record from the table and populate a form and fields that you can edit, change and update the database with.

#6: You can copy the page directly into an ASP page, including the comments. I should have tagged all of the comments correctly so the page will still run.

#7: Check the field names that I am referencing. Where ever you see objRSt(&quot;somefield&quot;), make sure the field name is correct.

#8: It's untested .. I won't be surprised if you throw an error or two. If you get stuck, just let me know.

#9: I don't usually spend this much time replying to a post, and I can see that this thread could get very lengthly. You can email me with questions that you don't feel will be helpful to other readers at todd@fuelaccess.com

#10: I'm probably covering some things that you are already familiar with. Feel free to replace any portion of my examples with solutions you already have in place.


<%@ Language=VBScript %>
<% Option Explicit %>

<html>
<head>
<script Language=&quot;JavaScript&quot;>
<!--
function checkForm(form_ref) {
//ANY VALIDATION FOR THIS FORM CAN GO HERE
}
//-->
</script>
</head>
<body>
<form name=&quot;games&quot; method=&quot;post&quot; action=&quot;nextpage.asp&quot; onSubmit=&quot;checkForm(this);&quot;>

<%
dim m
dim objRst
dim strProvider
dim strSQL
dim opponent
dim maxoppchars
dim location
dim maxlocchars

'SET MAXIMUM AMOUNT OF CHARACTERS TO DISPLAY IN LISTBOX FOR OPPONENT AND LOCATION
'SET TO 999 TO DISPLAY ALL CHARACTERS
maxoppchars = 10
maxlocchars = 10

strProvider =
'your database connection string or dsn

'CREATE THE RECORDSET
Set objRst = Server.CreateObject(&quot;ADODB.recordset&quot;)
objRst.CursorLocation = 3
strSQL = &quot;SELECT * FROM games&quot;
objRst.Open strSQL, strProvider
set objRst.ActiveConnection = Nothing
%>

<select size=&quot;10&quot; name=&quot;gamelist&quot;>
<%
IF NOT objRst.EOF THEN
m = &quot; selected &quot;

WHILE NOT objRst.EOF
' LOOP FOR EACH RECORD
opponent = Trim(objRst(&quot;opponent&quot;))
IF Len(opponent) > maxoppchars THEN
opponent = Left(opponent,maxoppchars) & &quot;..&quot;
END IF
location = Trim(objRst(&quot;location&quot;))
IF Len(location) > maxlocchars THEN
location = Left(location,maxlocchars) & &quot;..&quot;
END IF
%>
<option<%=m%>value=&quot;<%=objRst(&quot;id&quot;)%>&quot;><%=objRst(&quot;month&quot;)%>/<%=objRst(&quot;day&quot;)%>/<%=objRst(&quot;year&quot;)%> - <%=objRst(&quot;time&quot;)%> - <%=location%> - <%=opponent%></option>
<%
objRst.MoveNext
m = &quot; &quot;
WEND

ELSE
' IF NO RECORDS ARE FOUND
%>
<option value=&quot;&quot;>No Records Found ..</option>
<%
END IF
set objRst = Nothing
%>
</select><br><br>
<input type=&quot;submit&quot; value=&quot;Submit&quot;>
</form>
</body>
</html>


ToddWW :)
 
Let me know when you're ready for page 2. That will be much easier to explain, if you need the help.

ToddWW :)
 
Todd,

That worked great...:) Can you go on to page 2?


 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top