Jump to content

Recommended Posts

Hello All,

 

I did some customizing of a script for my web site which works well. I just need to change one thing but I'm not sure how to do this.

 

I have people fill out a questionnaire when registering and then these values are inserted into my database. The only problem is if someone doesn't fill out the questionnaire the script inserts the top value of the pull down menu (2010) into the database. I know I could check to see if they filled it in but it doesn't really matter if it's blank as they could fill it in later. Here's the code.

 

              <tr>
                <td width="150" align="right" valign="top"><strong>The year of your auto: </strong></td>
                <td align="left" valign="top"><select name="year" id="year">
                    <option value="2010">2010</option>
                    <option value="2009">2009</option>
                    <option value="2008">2008</option>
                    <option value="2007">2007</option>
                    <option value="2006">2006</option>
                    <option value="2005">2005</option>
                    <option value="2004">2004</option>
                    <option value="2003">2003</option>
	    <option value="2002">2002</option>
	    <option value="2001">2001</option>
	    <option value="2000">2000</option>
	    <option value="1999">1999</option>
                  </select>
		</td>

 

 

Does anyone know how to solve this?

Solve what? You stated some facts. That doesn't tell us crap.

 

1) state the overall situation (done)

2) state what you want to happen

3) state what is happening

4) state what you have tried (optional, but helpful)

5) ask a question.

 

No one can help you at step one.

I have a registration page and on the registration page I have some pull downs with one of them being the year along with username and password setup. So for example, I have a line that says Year of Car: [pull down menu] with the values in the original posting so when someone views the page it'll say Year of Car [2010] where 2010 is the first value. Most people select the year of their car and this entry gets added to the database when they complete the registration process; however, some people don't select the year of car and the default entry of 2010 gets added to the database. I don't want this since the person doesn't really have a car made in 2010 as I'd rather have it left blank. What I want to happen is if someone doesn't select an entry I'd rather have a blank entry entered instead of 2010. How can I do this? The only thing I can think of is add a prefer not say as the top entry or something.

If you are ok with blank spaces in the database, then you can add an empty option to the top of the select list:

 

<select name="some_name">
<option></option>
<option>2010</option>
<option>2009</option>
</select>

 

In this way, the blank info at the top of the list is the default. If someone doesn't select anything, then that blank info is passed as the value of the selection.

 

If you decide later on that the user has to enter a value, do a check to see if the value of 'some_name' is equal to "" (nothing). If it is, then don't let them proceed.

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.