dava133
|
| Posted: 03/08/2002, 2:19 AM |
|
Hi, i am creating a feedback form for logged in users on this site, i have come across a couple of problems u might be able to help me with:
1) The form automatically gathers the users information using session("UserID") and they only have to fill in a couple of fields. The filled in fields are labels but when the form is sent these are not, i am using getparam("labelled_field") to get these and this works fine if i change the fields to textboxes instead of labels. I dont understand why!
2) One of the user controlled fields is a listbox which returns a number in the email, how can i make it return the text value? Theres only 3 options so Im using a list 1;option1;2;option2;3;option3
3) When the form is sent (when i change all the fields to textboxes!) how do i format the email which is receieved, I looked at the tellafriend eg but that didnt really help me. It doesnt need to be too fancy I just want to add a couple of line breaks in now and again.
Cheers for any help
|
|
|
 |
Andrew B
|
| Posted: 03/08/2002, 9:53 PM |
|
1) You can put the fields there as lables, but those are not passed (and not updated if you are using a normal db update process). The way to get around these, other than looking them up yourself in the event, is to also put them on the forms as hidden fields. Then they will both display and be passed.
2) If the number means nothing and you don't use it anywhere (in a db lookup, etc) then you can just do this :
Option 1;Option 1;Option 2;Option 2. (ie. <value>;<display>;<value>...)
the option is constructed like this
<option value="<value>"> <display> </option>
And there is nothing that forces the value to be a number. It can be anything text. If you do need the number, then all you can do is look it up. There may be fast ways to do this if the ListOfValues that is used for the box is there before you get to your event that emails, but I don't know if it is. ASP code would be something like this (look for the LOV in the asp file first)
'fldOptionPassedIn is the option var created by CC from the form variable
'this assumes you number your options 1,2,3 etc...
arrOptions = split(optionsLOV, ";")
sOption = arrOptions(fldOptionPassedIn + 1)
3) for a text only email, this is pretty easy to do. Just add a VBCRLF where you want a return. It goes something like this :
fldEmailBody = "To Whomever It May Concern, " & _ '<-- continues a line
vbcrlf & _ '<--- 'vbcrlf' is the VB constant for carriage return + line feed
"This is the second line" & _
vbcrlf & vbcrlf & _
"Third line, with a space above it"
Hope this helps
Andrew Backer
|
|
|
 |
dava133
|
| Posted: 03/10/2002, 4:51 AM |
|
Yes I think that answers all my questions!! And I understand all the answers which is unusual for me!! Just off to try them all now, thank you again
|
|
|
 |
dava133
|
| Posted: 03/10/2002, 5:21 AM |
|
right got all them working now i have another feedback form which uses a list box from a table, i was wondering how to get the word instead of the index number of the table in the email.
I found this in the ASP code:
fldCounty = DLookUp("Counties", "County", "ID=" & ToSQL(fldCounty, "Number"))
and gathered this had something to do with it but cant seem to get it to work!
cheers
|
|
|
 |
Andrew B
|
| Posted: 03/10/2002, 5:56 PM |
|
right got all them working now i have another feedback form which uses a list box from a table, i was wondering how to get the word instead of the index number of the table in the email.
I found this in the ASP code:
fldCounty = DLookUp("Counties", "County", "ID=" & ToSQL(fldCounty, "Number"))
and gathered this had something to do with it but cant seem to get it to work!
There are several ways to do this (I know, I know, there always is!)
1. If you don't need the number anywhere (if yer not storing it in the database or anything) then you can just make your listbox as you normally would, but... in the join tab, set the 'primary key' to the text field and set 'showing' to the same field. This will make both the 'value' of the field and what it displays be the same. Then, just using fldCountry will give you the text value (since it's now in <option value='USA'>USA</option>.
2. If you do need to stick the from on the database (you are keeping records of them), the code above looks like it should work just fine, if you use it right.
dim sTheOnePicked
sTheOnePicked = DLookup("<table name>", "<field name>", "<sql where clause>")
'becomes
sTheOnePicked = DLookup("Counties", "County", "CountyID=" & fldCounty)
fldCounty should be what was passed in from the feedback form. It will be a number if you set 'primary key' to be the 'CountyID'. If you look at it before the event has time to place the value passed in by the form into the variable, then you will get a NULL, and hence nothing will match and the DLookup will return an empty string (i think). At some point in the event you should see something like this :
fldCounty = GetParam("County")
Make sure the code runs after this.
ToSQL just turns the parameter into a sql safe variable that you can append. Take a look in common.asp.
DLookup is analagous to a vb function that I use in access. It basically returns a single field from a table, based on a where clause. It is nice for looking up things like the sales tax rate w/o opening a recordset and a connection and a command and such.
HTH
Andrew B
|
|
|
 |
|