OutFront Forums
     Home    Register     Search      Help      Login    

Follow Us
On Facebook
On Twitter
RSS
Via Email

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

Sponsors
Shopping Cart Software
Ecommerce software integrated into Frontpage, Dreamweaver and Golive templates. No monthly fees and available in ASP and PHP versions.
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

 

Removing initial state from dropdown box

 
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, PHP, and Database >> Removing initial state from dropdown box
Page: [1]
 
mjmtravel

 

Posts: 327
Joined: 7/30/2006
Status: offline

 
Removing initial state from dropdown box - 5/17/2009 17:33:36   
I'm sorry if this is posted somewhere but I have been searching for a hour with no results.

I'm updating a database with a FP form adding a new record. Everything works fine and uploads great, but; I have a lot of dropdown boxes with options for the customer to pick from. I have initial settings on all of them basically telling them to pick this if?

If the customer does not pick from all of the dropdown boxes it updates with all of the initial settings. Is there a way to set it up to so all of the default dropdown settings don't show up? I have been manually deleting them in the database after a customer does his upload.

The form is not on a diet and is built with the FP form wizard.

Thanks for your help in advance.
Spooky

 

Posts: 26681
Joined: 11/11/1998
From: Middle Earth
Status: offline

 
RE: Removing initial state from dropdown box - 5/17/2009 23:40:34   
Its pretty much an "if else" situation with 2 options

1) You would code "pick this" to have no actual value so that the database is updated with a null

2) You would code it so that when no selection is made, that that part of the update or insert statement is left out

_____________________________

If you arent part of the solution, then there is good money to be made prolonging the problem

Sp:)ky


(in reply to mjmtravel)
TexasWebDevelopers

 

Posts: 722
Joined: 2/22/2002
From: Dallas, TX
Status: offline

 
RE: Removing initial state from dropdown box - 5/17/2009 23:58:04   
One other option, have the value of no selection be "0" instead of null.
You can even force the database to automatically fill the field with "0" if the database entry is left blank.
This way, you can return text in the database results if no answer is given.
<%If field-Name="0" then%>
No response given
<%end if%>
Advantages with this technique include quickly spoting spam bots filling out the form; help prevent sql injection by validating the field server-side, etc.

_____________________________

:)

Follow us on TWITTER

(in reply to Spooky)
mjmtravel

 

Posts: 327
Joined: 7/30/2006
Status: offline

 
RE: Removing initial state from dropdown box - 5/18/2009 8:09:21   
I don't want any zero's showing either because the data entered is showing on a results page. The zero's would not look so good. How about if I did this will it leave a blank?

Thanks again

<select size="1" name="Bedroom1Option1">
<option selected>--Select Option--</option>
<option>Sleeper Sofa</option>
<option>Futon</option>
<option>Air Conditioning</option>
<option>Ceiling Fan</option>
<option>Television</option>
<%If field-Name="Null" then%>
No response given
<%end if%>
</select>

(in reply to TexasWebDevelopers)
TexasWebDevelopers

 

Posts: 722
Joined: 2/22/2002
From: Dallas, TX
Status: offline

 
RE: Removing initial state from dropdown box - 5/18/2009 12:14:05   
But what if some other field had a null?
By providing numerals for fields with no values you can control the display.
You may want to substitute text for one field that is null that says "No response given" and simply not display text at all for another field that returns null. If all of the fields are nulll then you have given up control. (Although it may not matter in specific cases where there is ONLY ONE field that is allowed to be null.

It just depends on how you want the display to look.

Lets say the value was a State name in an address and you wanted it to display
"City, State Postal_code"
If you left the field null and did not substitute anything for the null then the display is:
"City, Postal_code"
If the State were forced to "0" you would obviously NOT display :
"City, 0 Postal_code"
But substitute other text or a non-breaking space.

The problem above is fairly easy, but what about items displayed in a list where "item 2" did not have an value?:

  • Item 1

  • Item 3

That display looks pretty bad.
So the display can be controlled by NOT displaying fields="0" just as easily as substituting text like this:
<ul>
<%
Do until rsWhatever.EOF
If rsWhatever("fieldname")<>"0" then%>
<li><%=rsWhatever("fieldname")%></li>
<%
rsWhatever.MoveNext
loop
end if
%>
And then the display looks like this:

  • Item 1
  • Item 3


_____________________________

:)

Follow us on TWITTER

(in reply to mjmtravel)
mjmtravel

 

Posts: 327
Joined: 7/30/2006
Status: offline

 
RE: Removing initial state from dropdown box - 5/18/2009 15:47:32   
Ok I understand what your saying. I would prefer just leaving the field blank because in my instance if the customer does not pick a 2nd bedroom for example the rest of the fields need to show empty anyway. The problem I have is the field is not really blank because its using my initial text that remains in the box. Does that make any sense. Here is a link to see what I mean. http://www.travelbuff.net/propertysignup.asp

Not sure about the coding, something more like this

<select size="1" name="Bedroom1Option1">
<option selected>--Select Option--</option>
<option>Sleeper Sofa</option>
<option>Futon</option>
<option>Air Conditioning</option>
<option>Ceiling Fan</option>
<option>Television</option>
<%If Bedroom1Option1="0" then%>
<%end if%>
</select>

(in reply to TexasWebDevelopers)
TexasWebDevelopers

 

Posts: 722
Joined: 2/22/2002
From: Dallas, TX
Status: offline

 
RE: Removing initial state from dropdown box - 5/19/2009 12:06:21   
You have to provide values for the selections:

<select size="1" name="Bedroom1Option1">
<option value="0" selected>--Select Option--</option>
<option value="sleeper">Sleeper Sofa</option>
<option value="futon">Futon</option>
<option value="ac">Air Conditioning</option>
<option value="fan">Ceiling Fan</option>
<option value="tv">Television</option>
</select>

In this case, no selection ="0" and that's what will be stuck in the database.
You could leave it like:
<option value="" selected>--Select Option--</option>
But why?

_____________________________

:)

Follow us on TWITTER

(in reply to mjmtravel)
mjmtravel

 

Posts: 327
Joined: 7/30/2006
Status: offline

 
RE: Removing initial state from dropdown box - 5/19/2009 15:49:45   
Thanks, that makes good sense. I will give that a try and see how it works.
Thanks again for all your help.

(in reply to TexasWebDevelopers)
mjmtravel

 

Posts: 327
Joined: 7/30/2006
Status: offline

 
RE: Removing initial state from dropdown box - 5/20/2009 17:12:31   
I went with your idea and it worked great, but the zero's still showed up on the results page. After some playing I figured out if you use double quotation marks in place of the zero. The result comes up blank. You have to do this in the code itself because for some reason in you do it in the field properties box it will not work.

So in the end it looked like this.

Old way
<select size="1" name="Bedroom1Option1">
<option value="0" selected>--Select Option--</option>
<option value="sleeper">Sleeper Sofa</option>
<option value="futon">Futon</option>
<option value="ac">Air Conditioning</option>
<option value="fan">Ceiling Fan</option>
<option value="tv">Television</option>
</select>

New way
<select size="1" name="Bedroom1Option1">
<option value="" selected>--Select Option--</option>
<option value="sleeper">Sleeper Sofa</option>
<option value="futon">Futon</option>
<option value="ac">Air Conditioning</option>
<option value="fan">Ceiling Fan</option>
<option value="tv">Television</option>
</select>

(in reply to mjmtravel)
TexasWebDevelopers

 

Posts: 722
Joined: 2/22/2002
From: Dallas, TX
Status: offline

 
RE: Removing initial state from dropdown box - 5/20/2009 17:49:50   
Right---but all you've done is shoved a "null" into the database.

The idea, although it IS more work, is to CONTROL your results by shoving the "0" into the database and then replacing it/manipulating it when you write the results to the page.

This can be more important than you might think. If a spammer or black-hat duplicates the form and posts to your results page from their IP they could use the blank for sql injection. Where if you are forcing the "0" and the database is expecting the 0 then you can validate and avoid the bot spam.

_____________________________

:)

Follow us on TWITTER

(in reply to mjmtravel)
Page:   [1]

All Forums >> Web Development >> ASP, PHP, and Database >> Removing initial state from dropdown box
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