|
| |
|
|
jvcnacho
Posts: 25 Joined: 12/28/2006 Status: offline
|
Radio buttons from database - 2/9/2007 11:41:25
Hello, I have a database which has organizations and people associated to those organizations. I would like to be able to designate one of the people associated with an organization as a "primary contact." I would like to generate a list of the people and then have a radio button next to each. The radio button next to the primary contact would be selected. If the user selected a different primary contact it could be saved, and if there was only one person associated with the organization, they would be defaulted as primary contact. Has anyone built a form like this? Thanks
|
|
|
|
rdouglass
Posts: 9224 From: Biddeford, ME USA Status: offline
|
RE: Radio buttons from database - 2/9/2007 13:19:08
Built 'em many times. How exactly are you connecting to the DB? Are you using the DRW? Also, are you comfortable with ASP coding?
_____________________________
Don't take you're eye off your final destination. ASP Checkbox Function Tutorial.
|
|
|
|
jvcnacho
Posts: 25 Joined: 12/28/2006 Status: offline
|
RE: Radio buttons from database - 2/9/2007 14:27:02
I have an MS Access 2003 database, and I use the Database Results Wizard. Occasionally I use small tweaks to get line numbers, alternating colors, default list boxes. I'm a rookie, but I'm willing to try. What do you recommend?
|
|
|
|
rdouglass
Posts: 9224 From: Biddeford, ME USA Status: offline
|
RE: Radio buttons from database - 2/9/2007 14:39:53
Well, we should be able to do it with the DRW. What I would suggest is to build a DRW that lists all the contacts and in the order you want them. If you will be using ID's in addition to names, be sure and get them in there as well. Put *only* the info that you want in the radio buttons in the DRW. Next, put it on a Spooky Diet: http://www.outfront.net/spooky/adv_drw_diet.htm Test that the Dieted DRW still works. Finally post the dieted DRW code here and I'll show you how to change this DRW into radio buttons.
_____________________________
Don't take you're eye off your final destination. ASP Checkbox Function Tutorial.
|
|
|
|
jvcnacho
Posts: 25 Joined: 12/28/2006 Status: offline
|
RE: Radio buttons from database - 2/9/2007 16:07:14
Hello, Here's my table. I like the diet. I didn't think I could do that. The "order by"'s aren't necessary...I put them in to make it make sense to me. Currently the Primary_Contact field is a Yes/No data type, but it could be something else if that would help. I haven't been able to get the -1 and 0 stuff correct. Thanks in advance for any help you can provide. <table>
<tbody>
<!--#include file="_fpclass/fpdblib.inc"-->
<% if 0 then %>
<SCRIPT Language="JavaScript">
document.write("<div style='background: yellow; color: black;'>The Database Results component on this page is unable to display database content. The page must have a filename ending in '.asp', and the web must be hosted on a server that supports Active Server Pages.</div>");
</SCRIPT>
<% end if %>
<%
fp_sQry="SELECT * FROM qryPrimaryContact ORDER BY Alias ASC,Primary_Contact ASC,Last ASC"
fp_sDefault=""
fp_sNoRecords="<tr><td colspan=7 align=""LEFT"" width=""100%"">No records returned.</td></tr>"
fp_sDataConn="tracker"
fp_iMaxRecords=0
fp_iCommandType=1
fp_iPageSize=0
fp_fTableFormat=True
fp_fMenuFormat=False
fp_sMenuChoice=""
fp_sMenuValue=""
fp_sColTypes="&PeopleID=3&FullName=202&AliasID=3&First=202&Last=202&Alias=202&Primary_Contact=11&"
fp_iDisplayCols=7
fp_fCustomQuery=False
BOTID=0
fp_iRegion=BOTID
%>
<!--#include file="_fpclass/fpdbrgn1.inc"-->
<tr>
<td>
<%=FP_FieldVal(fp_rs,"PeopleID")%></td>
<td>
<%=FP_FieldVal(fp_rs,"FullName")%></td>
<td>
<%=FP_FieldVal(fp_rs,"AliasID")%></td>
<td>
<%=FP_FieldVal(fp_rs,"First")%></td>
<td>
<%=FP_FieldVal(fp_rs,"Last")%></td>
<td>
<%=FP_FieldVal(fp_rs,"Alias")%></td>
<td>
<%=FP_FieldVal(fp_rs,"Primary_Contact")%></td>
</tr>
<!--#include file="_fpclass/fpdbrgn2.inc"-->
</tbody>
</table>
< Message edited by rdouglass -- 2/12/2007 9:05:50 >
|
|
|
|
rdouglass
Posts: 9224 From: Biddeford, ME USA Status: offline
|
RE: Radio buttons from database - 2/9/2007 16:22:14
OK. So what info do you want to show and what info needs to be the value of the radio?
_____________________________
Don't take you're eye off your final destination. ASP Checkbox Function Tutorial.
|
|
|
|
jvcnacho
Posts: 25 Joined: 12/28/2006 Status: offline
|
RE: Radio buttons from database - 2/12/2007 8:58:22
The people would be grouped by AliasID. There would be one Primary_Contact per AliasID. I imagined a screen with Alias (I'm not sure if AliasID is needed, but it is stored in the tblPeople.) Primary Contact Radio Button( ) FullName 1 (order by Last, First) Primary Contact Radio Button(.) FullName 2 Primary Contact Radio Button( ) FullName 3 <Submit> button A user would click the radio button next to the Primary_Contact, if there wasn't only one, and click save(submit). This would update the user. Please let me know if I can provide more information.
|
|
|
|
rdouglass
Posts: 9224 From: Biddeford, ME USA Status: offline
|
RE: Radio buttons from database - 2/12/2007 9:22:39
Try this code:
<table>
<tbody>
<!--#include file="_fpclass/fpdblib.inc"-->
<% if 0 then %>
<SCRIPT Language="JavaScript">
document.write("<div style='background: yellow; color: black;'>The Database Results component on this page is unable to display database content. The page must have a filename ending in '.asp', and the web must be hosted on a server that supports Active Server Pages.</div>");
</SCRIPT>
<% end if %>
<%
fp_sQry="SELECT * FROM qryPrimaryContact ORDER BY Alias ASC,Primary_Contact ASC,Last ASC"
fp_sDefault=""
fp_sNoRecords="<tr><td colspan=7 align=""LEFT"" width=""100%"">No records returned.</td></tr>"
fp_sDataConn="tracker"
fp_iMaxRecords=0
fp_iCommandType=1
fp_iPageSize=0
fp_fTableFormat=True
fp_fMenuFormat=False
fp_sMenuChoice=""
fp_sMenuValue=""
fp_sColTypes="&PeopleID=3&FullName=202&AliasID=3&First=202&Last=202&Alias=202&Primary_Contact=11&"
fp_iDisplayCols=7
fp_fCustomQuery=False
BOTID=0
fp_iRegion=BOTID
%>
<!--#include file="_fpclass/fpdbrgn1.inc"-->
<input type="radio" name="PeopleID" value="<%=FP_FieldVal(fp_rs,"PeopleID")%>"><%=FP_FieldVal(fp_rs,"FullName")%><br>
<!--#include file="_fpclass/fpdbrgn2.inc"-->
This will give you a column of radio buttons with the PeopleID as the 'passed' value when you post the form and it will display the 'FullName' beside them. Does that get you where you want to be?
_____________________________
Don't take you're eye off your final destination. ASP Checkbox Function Tutorial.
|
|
|
|
jvcnacho
Posts: 25 Joined: 12/28/2006 Status: offline
|
RE: Radio buttons from database - 2/12/2007 9:41:09
This definitely moves me in the right direction. Would I change this code to have the values for "primary_contact" drive whether the radio button is selected for a given person or not? now <input type="radio" name="PeopleID" value="<%=FP_FieldVal(fp_rs,"PeopleID")%>"><%=FP_FieldVal(fp_rs,"FullName")%> with change <input type="radio" name="PeopleID" value="<%=FP_FieldVal(fp_rs,"Primary_Contact")%>"><%=FP_FieldVal(fp_rs,"FullName")%> Thanks.
|
|
|
|
rdouglass
Posts: 9224 From: Biddeford, ME USA Status: offline
|
RE: Radio buttons from database - 2/12/2007 10:22:56
What is put in the value="" section is what you want to pass from the form. Whatever that value is will be picked up by any Request.form("PeopleID") or ::PeopleID:: in any DRW's. If you want it to be a different field value, I'd suggest changing the name parameter as well. For instance, if you want the primary_contact being passed, I'd suggest changing the radio name as well to look something like this: <input type="radio" name="Primary_Contact" value="<%=FP_FieldVal(fp_rs,"Primary_Contact")%>"><%=FP_FieldVal(fp_rs,"FullName")%> See what I did? Hope it helps.
_____________________________
Don't take you're eye off your final destination. ASP Checkbox Function Tutorial.
|
|
|
|
jvcnacho
Posts: 25 Joined: 12/28/2006 Status: offline
|
RE: Radio buttons from database - 2/12/2007 11:50:16
I guess I need to send two pieces of data to from the form. I need to send the PeopleID and the Primary Contact for each person in the results. I have worked with option boxes form this forum with this sort of syntax: <%if request.querystring("Status") = fp_fieldhtml(fp_rs,"Status") then response.write "selected"%>> Is there a way to do this with radio buttons, and how might the form be set up? Thanks.
|
|
|
|
jvcnacho
Posts: 25 Joined: 12/28/2006 Status: offline
|
RE: Radio buttons from database - 2/12/2007 12:00:52
Also is there a way for me to post a screenshot of what my form looks like so you can see what I'm up to? Thanks
|
|
|
|
jvcnacho
Posts: 25 Joined: 12/28/2006 Status: offline
|
RE: Radio buttons from database - 2/12/2007 12:19:57
Would I click on the image icon above? How would I do this?
|
|
|
|
rdouglass
Posts: 9224 From: Biddeford, ME USA Status: offline
|
RE: Radio buttons from database - 2/12/2007 12:42:31
quote:
I guess I need to send two pieces of data to from the form. You won't be able to do that easily with the DRW. It can be done but it requires a little ASP. Let's first get the 2 values we need in the 'value' section of the radio button. We can do this like so: <input type="radio" name="radioOne" value="<%=FP_FieldVal(fp_rs,"PeoleID")%>,<%=FP_FieldVal(fp_rs,"Primary_Contact")%>"><%=FP_FieldVal(fp_rs,"FullName")%> And to pre-select it, we can add another piece to it: <input type="radio" name="radioOne" value="<%=FP_FieldVal(fp_rs,"PeoleID")%>,<%=FP_FieldVal(fp_rs,"Primary_Contact")%>"<%if request.querystring("PeopleID") = fp_field(fp_rs,"PeopleID") then response.write " selected"%>><%=FP_FieldVal(fp_rs,"FullName")%> That would be assuming you're passing the PoepleID in the querystring. Now that *should* get both your values in the 'value' section of the radio button. Try that and see if that does those 2 things (both values and pre-selects). If that works, we can move on to 'splitting' those values in preparation to write to the database. If the above is working, the next thing would be to post the DRW (or whatever code your'e using) that writes to the database. Then I'll show you how to alter that.
_____________________________
Don't take you're eye off your final destination. ASP Checkbox Function Tutorial.
|
|
|
|
jvcnacho
Posts: 25 Joined: 12/28/2006 Status: offline
|
RE: Radio buttons from database - 2/12/2007 13:07:35
It works as before, but no radio buttons are selected. Does it matter whether it is "selected" or "checked?"
|
|
|
|
jvcnacho
Posts: 25 Joined: 12/28/2006 Status: offline
|
RE: Radio buttons from database - 2/12/2007 14:46:02
So now I have: <input type="radio" name="radioOne" value="<%=FP_FieldVal(fp_rs,"PeopleID")%>,<%=FP_FieldVal(fp_rs,"Primary_Contact")%>" <%if request.querystring("Primary_Contact") = fp_fieldval(fp_rs,"Primary_Contact") then response.write " checked"%>><%=FP_FieldVal(fp_rs,"FullName")%> The radio buttons appear just fine, but the primary_contact does not appear checked. Any thoughts?
|
|
|
|
rdouglass
Posts: 9224 From: Biddeford, ME USA Status: offline
|
RE: Radio buttons from database - 2/12/2007 14:47:31
Do you have a URL I could look at? Is there a primary_contact in the querystring?
_____________________________
Don't take you're eye off your final destination. ASP Checkbox Function Tutorial.
|
|
|
|
jvcnacho
Posts: 25 Joined: 12/28/2006 Status: offline
|
RE: Radio buttons from database - 2/12/2007 15:00:19
If you go to student.neric.org/test5 jbronson/password. Then click on the green "people" link at the top. Then click on the "Organizations and their People" on the left. Then click on COHOES CITY SCHOOL DISTRICT to see contacts. Thanks
|
|
|
|
rdouglass
Posts: 9224 From: Biddeford, ME USA Status: offline
|
RE: Radio buttons from database - 2/12/2007 15:13:26
I see no Primary_Contact in any of those link querystrings. Do by chance the AliasID match up with the PeopleID? If so, make the IF...THEN code like this: <%if request.querystring("AliasID") = fp_field(fp_rs,"PeopleID") then response.write " checked"%> If that is not the case, then what part of the querystring is supposed to match what field?? And I'm also going to make a recommendation not to use fp_FieldVal when doing compares but rather just fp_Field....
< Message edited by rdouglass -- 2/12/2007 15:19:08 >
_____________________________
Don't take you're eye off your final destination. ASP Checkbox Function Tutorial.
|
|
|
|
jvcnacho
Posts: 25 Joined: 12/28/2006 Status: offline
|
RE: Radio buttons from database - 2/12/2007 15:19:50
That seems to fix the radio button being selected issue. It now reads, <input type="radio" name="radioOne" value="<%=FP_Field(fp_rs,"PeopleID")%>,<%=FP_Field(fp_rs,"Primary_Contact")%>" <%if request.querystring("Primary_Contact") = FP_Field(fp_rs,"Primary_Contact") then response.write " checked"%>> <%=FP_Field(fp_rs,"FullName")%> I noticed that it was selecting one person, but not the person who is in the table with a yes next to them as the primary contact. Could you show me how to separate the values?
|
|
|
|
rdouglass
Posts: 9224 From: Biddeford, ME USA Status: offline
|
RE: Radio buttons from database - 2/12/2007 15:28:57
quote:
Could you show me how to separate the values? The way I like to do it is to use the 'split' VBScript command and put the individual items in an array. This code: <%myArray = split(request.form("radioOne"),",")%> will put each item into an element of an array. Now if you want to display or use the PeopleID, you'd use this code: <%=myArray(0)%> and to display or use the Primary_Contact, you'd use: <%=myArray(1)%> In theory, we could do that with a number of field values but we want to be a little careful. If there are commas in the value "Primary_Contact", we may need to adjust the code a little and use a different value separator other than a comma. Many times a pipe works great ( | ). So if we need to use the pipe, one small adjustment to our radio button script: value="<%=FP_Field(fp_rs,"PeopleID")%>|<%=FP_Field(fp_rs,"Primary_Contact")%>" (see it?) and 1 adjustment to our 'split' code: <%myArray = split(request.form("radioOne"),""")%> (see that one?) should take care of it if there are commas in the values we want to use. Is that getting you closer?
_____________________________
Don't take you're eye off your final destination. ASP Checkbox Function Tutorial.
|
|
|
|
jvcnacho
Posts: 25 Joined: 12/28/2006 Status: offline
|
RE: Radio buttons from database - 2/12/2007 15:36:11
I'll work on that. Could you comment on why only the last radio button is selected, and the only button in a single list is not selected? It seems like I'm getting closer.
|
|
|
|
rdouglass
Posts: 9224 From: Biddeford, ME USA Status: offline
|
RE: Radio buttons from database - 2/12/2007 15:57:07
quote:
Could you comment on why only the last radio button is selected, and the only button in a single list is not selected? It seems like I'm getting closer. Probably because you're not passing the proper value. Let's get the correct value being sent so we can compare properly. Then we'll work on the 'checked' property. All bet's are off if we're not passing the correct data.
_____________________________
Don't take you're eye off your final destination. ASP Checkbox Function Tutorial.
|
|
|
|
jvcnacho
Posts: 25 Joined: 12/28/2006 Status: offline
|
RE: Radio buttons from database - 2/13/2007 8:38:31
I think I may be in over my head. I haven't been able to get this array code to work. Here's my latest effort: <input type="radio" name="radioOne" value="<%=FP_Field(fp_rs,"PeopleID")%>|<%=FP_Field(fp_rs,"Primary_Contact")%>" <%if request.querystring("Primary_Contact") = FP_Field(fp_rs,"Primary_Contact") then response.write " checked"%>> <%=FP_Field(fp_rs,"FullName")%> <!--#include file="_fpclass/fpdbrgn2.inc"--> </tbody> </table> <p><input type="submit" value="Save" name="Save"></p> </form> <%myArray = split(request.form("radioOne"),"|")%> <input type="text" name="Array0" value="<%=myArray(0)%>" size="10"> <input type="text" name="Array1" value="<%=myArray(1)%>" size="10">
|
|
|
|
rdouglass
Posts: 9224 From: Biddeford, ME USA Status: offline
|
RE: Radio buttons from database - 2/13/2007 8:44:51
quote:
I haven't been able to get this array code to work. That code goes on the page you're posting to. Sorry, I should have been more clear. Is the form posting to itself? If so, we need to allow for the 'first entry' into the page. First time there, there will be no Request.form("radioOne"). Can you post the whole page code here if so? See, that array stuff is collecting the form field data but it's not there until it is posted.
_____________________________
Don't take you're eye off your final destination. ASP Checkbox Function Tutorial.
|
|
|
|
jvcnacho
Posts: 25 Joined: 12/28/2006 Status: offline
|
RE: Radio buttons from database - 2/13/2007 9:40:29
My plan to move the data around is to do the following: First collect the AliasID (identifying the organization) and the PeopleID (identifying the person who should be the primary contact. Second send this information to a second page with two update SQL drw regions. Third the first drw would update all tblpeople.primary_contact fields to null where AliasID = (the one we collected). Fourth the second drw would update the tblpeople.primary contact field to -1 where the tblpeople.peopleID = (the one we collected). Does this sound like a good approach? Here's the code: <body> <form method="POST" action="prim_cont_drw_rd.asp"> <table> <tbody> <!--#include file="_fpclass/fpdblib.inc"--> <% if 0 then %> <SCRIPT Language="JavaScript"> document.write("<div style='background: yellow; color: black;'>The Database Results component on this page is unable to display database content. The page must have a filename ending in '.asp', and the web must be hosted on a server that supports Active Server Pages.</div>"); </SCRIPT> <% end if %> <!--#include file="_fpclass/fpdbrgn1.inc"--> <input type="radio" name="radioOne" value="<%=FP_Field(fp_rs,"PeopleID")%>|<%=FP_Field(fp_rs,"Primary_Contact")%>" <%if request.querystring("Primary_Contact") = FP_Field(fp_rs,"Primary_Contact") then response.write " checked"%>> <%=FP_Field(fp_rs,"FullName")%> <!--#include file="_fpclass/fpdbrgn2.inc"--> </tbody> </table> <p><input type="submit" value="Save" name="Save"></p> </form> </body>
|
|
|
|
rdouglass
Posts: 9224 From: Biddeford, ME USA Status: offline
|
RE: Radio buttons from database - 2/13/2007 9:55:58
Well, I hope I didn't mess things up. Let me try to clarify things a little regarding the array. The array stuff is ther only to separate the items in the 'value' parameter of the radio button. Hence, the array things should only be on this page: "prim_cont_drw_rd.asp" That is where the form is posting correct? I'm sorry but I don't really know enough about your project to follow all the logic. I would probably reduce the 'page count' but I would be doing all of this without the DRW. I suspect tho that's not really an option for you right now unless you're comfortable with ASP. So which page has the radio buttons? Where does this stand at the moment? Are the radios being 'checked' properly?
_____________________________
Don't take you're eye off your final destination. ASP Checkbox Function Tutorial.
|
|
|
|
jvcnacho
Posts: 25 Joined: 12/28/2006 Status: offline
|
RE: Radio buttons from database - 2/13/2007 10:14:56
The radio buttons don't seem to be picking up the defaults. When I query the values for primary contact they appear as True/False. When I look at the data in MS Access, it's a check box. I have heard that the data is really null (or 0) and -1 for no and yes respectively. Could you refer me to an explanation of this? I wonder, does radio button not selecting correctly have something to do with that? Also how would you handle organizations with only one contact, which must be their primary_contact? This is what I'm working with now on prim_cont_drw_rd.asp. I haven't put the code on a diet yet so I'm only posting the sql. "Update tblPeople Set Primary_Contact = Null where Organization = '::AliasID::'" "Update tblPeople Set Primary_Contact = -1 where ID = '::PeopleID::'" Generally the project is to create a website where technical support requests for school districts can be logged. I am a novice with FP, ASP, and all so I feel more comfortable with a higher page count. I hopefully will learn enough to redesign these pages down the road make them more efficient.
|
|
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
|
|
|