a webmaster learning community
     Home    Register     Search      Help      Login    
FrontPage Alternative
Sponsors

Hosting from $3.99 per month!

Shopping Cart Software
Ecommerce software integrated into Frontpage, Dreamweaver and Golive templates. No monthly fees and available in ASP and PHP versions. dd

Website Templates
We also have a wide selection of Dreamweaver, Expression Web and Frontpage templates as well as webmaster tools and CSS layouts.

Frontpage website templates
Creative Website Templates for FrontPage, Dreamweaver, Flash, SwishMax

Search Forums
 

Advanced search
Recent Posts

 Todays Posts
 Most Active posts
 Posts since last visit
 My Recent Posts
 Mark posts read

 

Database Results within Database Results

 
View related threads: (in this forum | in all forums)

Logged in as: Guest
Users viewing this topic: none
Printable Version 

All Forums >> Web Development >> ASP and Database >> Database Results within Database Results
Page: [1]
 
Ruff

 

Posts: 132
Joined: 2/12/2004
From: Malta
Status: offline

 
Database Results within Database Results - 2/25/2005 12:25:15   
Win200 - FP2000 - ACCESS 2000

I have a page which displays database results using DRW. The fields are shown as "Text Fields" - One or more fields would need to be edited but I would like to restrict the user to specific text and not free text to make sure I can run a search and find all the records I am searching for.

I deleted one of the text field results and used an "include page" command to insert a database result with a drop down menu which populates the field from the same database using DRW and the page is created correctly.

The page fails. Is there a way I can insert an include page within a database result?



_____________________________

Tell me and I will forget. Involve me and I will understand.
cliffdeen

 

Posts: 155
Joined: 4/12/2004
From: Mckinney, TX
Status: offline

 
RE: Database Results within Database Results - 2/25/2005 13:14:15   
You can, but you have to pass the value on as a variable outside the DRW and then use that as a pickup value for the include page. One thing you might try that I have used in the past is to: create your form. Retrieve via DRW the values that you do NOT want edited. These are basically just display fields. If you need to post back to the db, using one of these field values as the Where postit='::postit::' then set it up as fieldVal text box and going to the html code, within that line that shows the text box - place the word - readonly. This will prevent them from editing the field. As for drop down boxes - you can do it two ways - one use a statement that retrieves the value from the db in a input type drop-down box based on your original drop down box choices like this:
<option <%if FP_FieldHTML(fp_rs,"desktop")="" Then%>selected<%end if%> value="">Not Defined Yet</option>
<option <%if FP_FieldHTML(fp_rs,"desktop")="Tool" Then%>selected<%end if%> value="Tool">Tool</option>.
This will retrieve and select the value that was stored, along with giving the user the option to select a different value for updating.

Or you can do a little javascript that allows the updating of the field from pop-up window - you would insert the readonly statement on the main page and then call the pop-up for populating the field.

sample code below:
<HTML>
<HEAD>
<SCRIPT LANGUAGE="JavaScript"><!--
myPopup = '';

function openPopup(url) {
myPopup = window.open(url,'popupWindow','width=640,height=480');
if (!myPopup.opener)
myPopup.opener = self;
}
//--></SCRIPT>
</HEAD>
<BODY>
<FORM>
<INPUT TYPE="BUTTON" VALUE="Open Popup" onClick="openPopup('popupPage.html')">
</FORM>

<FORM NAME="hiddenForm" ACTION="nextPage.html">
<INPUT TYPE="HIDDEN" NAME="myTextField">
</FORM>

</BODY>
</HTML>


In the popupPage.html:

<HTML>
<HEAD>
<SCRIPT LANGUAGE="JavaScript"><!--
function copyForm() {
opener.document.hiddenForm.myTextField.value = document.popupForm.myTextField.value;
opener.document.hiddenForm.submit();
window.close();
return false;
}
//--></SCRIPT>
</HEAD>
<BODY>
<FORM NAME="popupForm" onSubmit="return copyForm()">
<INPUT TYPE="TEXT" NAME="myTextField">
<INPUT TYPE="BUTTON" VALUE="Submit" onClick="copyForm()">
</FORM>
</BODY>
</HTML>


good luck

(in reply to Ruff)
Ruff

 

Posts: 132
Joined: 2/12/2004
From: Malta
Status: offline

 
RE: Database Results within Database Results - 2/25/2005 15:57:34   
Let me rephrase myself.

With DRW I created a form with text fields pre populated from the results of the search from my database. You know, the default DRW creates when you choose "List - one field per item" and then you select Text Fields"for list options.

I don't mind any of the fields being changed, but I need to have one of the fields with specific text only. eg: Status should read Good, Faulty or Missing only, as I run reports depending on this field and it someone typed in Goood by mistake, then that record will never by found.

Since it is not possible to insert a DRW within an existing DRW, I created the DRW on a new page which I "include" instead of the field "Status" in the original form.

You might say its too much work just for Good, Faulty and Missing, but there are cases where I have selection of 20 to 30 different words which I can add and remove from an Admin form, depending on the current needs without having to go directly into the ASP code to add or remove code.

_____________________________

Tell me and I will forget. Involve me and I will understand.

(in reply to cliffdeen)
rdouglass

 

Posts: 9280
From: Biddeford, ME USA
Status: offline

 
RE: Database Results within Database Results - 2/25/2005 16:26:37   
No, you cannot do a DRW inside a DRW. However, I do a lot with Functions. One comes to mind like this. If you're feeling adventurous, try this:

Put this code somewhere ABOVE your DWR:

<%
FUNCTION dropDownMenu(tableName,fieldToShow,formFieldName)
myDSN ="Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & Server.Mappath("\fpdb\myDatabase.mdb")
mySQL = "SELECT " & fieldToShow & " FROM " & tableName
set conntemp=server.createobject("adodb.connection")
conntemp.open myDSN
set rstemp=conntemp.execute(mySQL)
IF rstemp.eof THEN
response.write "No records matched<br>"
response.write mySQL & "<br>So cannot make menu."
Call CloseAll
ELSE
arrTemp=rstemp.getrows
Call CloseAll
Response.write("<select size='1' name='" & formFieldName & "'>" & VbCrLf)
FOR i = 0 TO ubound(arrTemp,2)
Response.write("<option>" & arrTemp(1,i) & "</option>" & VbCrLf)
NEXT
Response.write("</select>" & VbCrLf)
END IF
END FUNCTION

SUB CloseAll
rstemp.close
set rstemp=nothing
conntemp.close
set conntemp=nothing
END SUB
%>

Change the name of the database in the myDSN line. Now inside your DRW, wherever you want the dropdown to show, put this code:

<%=dropDownMenu(tableName,fieldToShow,formFieldName)%>

where "tableName" is the table in the DB you'll be grabbing the dropdown values from, "fieldToShow" is the name of the field in the table you want to use and "formFieldName" is the name that will be given to the <select> element.

So for instance, the line might look something like this:

<%=dropDownMenu("myClientTypeTable","clientType","ClientType")%>

and the resultant code might come out looking like like:

<select size="1" name="ClientType">
<option>Type1</option>
<option>Type2</option>
</select>

Keep in mind that the table you're pulling the dropdown values from does NOT have to be the same table you're writing the value back into. Ideal for keeping DB's normalized and controlling text entries like you want to do.

Like I said, if you're feeling adventurous.:) This method always seems to work well for me if I only want to do it a few times per page. However, if you're doing a hundred of these per page, let me know - there are more efficient ways for that scenario.

Hope it helps.

_____________________________

Don't take you're eye off your final destination.

ASP Checkbox Function Tutorial.

(in reply to Ruff)
Ruff

 

Posts: 132
Joined: 2/12/2004
From: Malta
Status: offline

 
RE: Database Results within Database Results - 2/27/2005 16:07:32   
I tried your method but I ended up with the same problem I had the other time, however, me being who I am, went on trying something new to me and managed to do it. I wanna share what I did:

<tr>
<td width="100"><b>FST</b></td>
<td width="281"><select name="FST" size="1">
<option><%=FP_FieldHTML(fp_rs,"FST")%></option> 
<%
Set objConn = Server.CreateObject("ADODB.Connection")
objConn.Open Application("Hardware_ConnectionString")
Server.ScriptTimeOut = 600
Set rsObj = objConn.Execute ("SELECT FST, FST_Active FROM Details WHERE FST <> '' AND FST_Active = 1 ORDER BY FST")
Do until rsObj.EOF
Response.Write "<option>" & rsObj("FST") & "</option>"
rsObj.MoveNext
loop
rsObj.Close
%>
</select>
</tr>

It simply reads the column I want in the database and lists it in a drop done menu within a DRW :)

Why didn't I think of that before?

Thanks.

_____________________________

Tell me and I will forget. Involve me and I will understand.

(in reply to rdouglass)
Page:   [1]
OutFront Discoveries

All Forums >> Web Development >> ASP and Database >> Database Results within Database Results
Page: [1]
Jump to: 1





New Messages No New Messages
Hot Topic w/ New Messages Hot Topic w/o New Messages
Locked w/ New Messages Locked w/o New Messages
 Post New Thread
 Reply to Message
 Post New Poll
 Submit Vote
 Delete My Own Post
 Delete My Own Thread
 Rate Posts