This topic is locked
[SOLVED]

 changing lookup box option value for 'please select' default

3/6/2007 6:27:41 AM
ASPRunnerPro General questions
B
brasil author

this is my first post and i'm on day 4 of the trial version of asprunner 4.1 build 225. bear with me as i'm not a dedicated ASP/DB programmer, but i'm not a complete beginner either.
i have a test mySQL database which is a basic address book. the main table contains columns like FirstName, LastName, PhoneNum, EmailAdd, etc., and then a few numerical ID columns which are joined to other related tables for such choices as gender and astrological sign, etc. i've successfully set up lookup dropdown boxes to display the options from those related tables.
my problem is that on the ..._add.asp page, if no selection is made for "gender" and "astrological sign" and it's just left with the "Please select" option, the mySQL 4.1.18 database inserts a NULL value into those fields, and then the new record is not displayed on the list page because i'm using an inner join and "NULL" is not found in the related tables. in the table structure for those columns, i have the desired default values set, but it still inserts NULL.
even though this might be a mySQL 4 bug, how could i change this code: <option value="">Please select</option> so that my problem goes away, by inserting whatever option value will cause mySQL to insert my predefined defaults and not "NULL?"
your help is greatly appreciated, not to mention, if i get at least this working i'm buying the software! <img src='https://asprunner.com/forums/file.php?topicimage=1&fieldname=question&id=4754&image=1&table=forumtopics' class='bbc_emoticon' alt=':)' />

J
Jane 3/6/2007

Hi,
you can change value of your field using default values on the "Edit as" settings dialog on the Visual Editor tab or in the Before record added event on the Events tab:

function BeforeAdd(&$values)

{

if ($values["FieldName"]=="")

$values["FieldName"]=6; //6 - is the required value

return true;

}

B
brasil author 3/6/2007

thanks so much for your quick reply! so far the "default value" value in the "edit as" box (which i somehow overlooked) solves most of my problem.
the next question is: how do i remove the "please select" option entirely from a specific dropdown box or every dropdown box? as long as it's there, it's possible that someone could select it and then the NULL value will be back.
the code you suggested for "before record added" seems to only specify one value to replace, but what if every dropdown's default value is different? in this database i have 4 dropdowns, each with a different default. perhaps i could change everything so a default of "0" works for all of them, but that could lead to to other issues. i believe i saw something in jsfunctions.js, but i don't know javascript so i need your help on that.
thanks!

B
brasil author 3/6/2007

btw, it seems it would be very helpful to be able to edit all possible options for "Please select" right from the asprunner interface, including removing it as an option entirely. this would be a great improvement to consider in your next version.

J
Jane 3/7/2007

Hi,
to remove Please select option open include/commonfunctions.asp file, find following lines:

if strSize<2 then

response.Write "<option value="""">" & "Please select" & "</option>"

and replace it with this one:

if strSize<2 then

'response.Write "<option value="""">" & "Please select" & "</option>"

J
Joseph Zuanger 3/11/2007

Hi,

to remove Please select option open include/commonfunctions.asp file, find following lines:

and replace it with this one:


Jane,
I had the same issue and was able to resolve the problem using your suggestions. However, I was not able to fix the problem for a lookup, which is dependent on another lookup. It seems these two lookup using different format. Please let me know where to find the code in order to remove the "Please select" option for lookup dependent on another lookup.
Appreciate your help.

Joe