Select Box Always has selected value twice

I have a select box consisting of years and the selected year always appears twice - the select box is being populated from a List of Strings and there are no duplicates in the list the following is an example any idea why the selected year always appears twice

<td align="center">Calendar Year : <img src="public/images/red_arrow_compulsary_field.gif" border="0">
            <select name="selectYear" id="selectYear" style="width:100px" onchange="javascript:onChangeCalendarYear();">
    <option value="-1"
    > 2011</option>
    <option value="1991">1991</option>
    <option value="1992">1992</option>
    <option value="1993">1993</option>
    <option value="1994">1994</option>
    <option value="1995">1995</option>
    <option value="1996">1996</option>
    <option value="1997">1997</option>
    <option value="1998">1998</option>
    <option value="1999">1999</option>
    <option value="2000">2000</option>
    <option value="2001">2001</option>
    <option value="2002">2002</option>
    <option value="2003">2003</option>
    <option value="2004">2004</option>
    <option value="2005">2005</option>
    <option value="2006">2006</option>
    <option value="2007">2007</option>
    <option value="2008">2008</option>
    <option value="2009">2009</option>
    <option value="2010">2010</option>
    <option value="2011">2011</option>
    <option value="2012">2012</option>
    <option value="2013">2013</option>
    <option value="2014">2014</option>
    <option value="2015">2015</option>
    <option value="2016">2016</option>
    <option value="2017">2017</option>
    <option value="2018">2018</option>
    <option value="2019">2019</option>
    <option value="2020">2020</option>
    <option value="2021">2021</option>
    <option value="2022">2022</option>
    <option value="2023">2023</option>
    <option value="2024">2024</option>
    <option value="2025">2025</option>
    <option value="2026">2026</option>
    <option value="2027">2027</option>
    <option value="2028">2028</option>
    <option value="2029">2029</option>
    <option value="2030">2030</option>
    <option value="2031">2031</option>
abuyusuf35Asked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

chaitu chaituCommented:
can you show me your script?
0
CEHJCommented:
Although your code is incomplete, you have the current year in there twice
0
AielloJCommented:
abuyusuf35:

There is not duplication in your example.  It is how HTML options boxes work.  The <option value="1991"> is the value that will be passed to your script if that option is selected.  The >1991< (brackets show for clarity only) is what's displayed to the user.  In your example the are both the same, but let's use an example of names.  You would want to pass the ID for the name to your script, but display the name to the user.  So that option list would look more like:

    <option value="127">Bob</option>
    <option value="2098">Marie</option>

The ID's (127, 2098) would not make sense to the user, only your script.  The names (Bob, Marie) are what the user sees on the form.  Hope that clears it up.

Regards,

AielloJ
0
Cloud Class® Course: Python 3 Fundamentals

This course will teach participants about installing and configuring Python, syntax, importing, statements, types, strings, booleans, files, lists, tuples, comprehensions, functions, and classes.

abuyusuf35Author Commented:
Thanks but that doesn't solve my issue - is there anyway to avoid that  - if a user selects the 2nd 2011 in the drop down the option value passed is invalid and throws an error ?
0
CEHJCommented:

>>There is not duplication in your example.

Sorry - you're right - i misread the code ;)
0
chaitu chaituCommented:

 which value you want to avoid;if u want to avoid 2011;do like this while submitting form
 <select name="selectYear" id="selectYear" style="width:100px" onchange="javascript:onChangeCalendarYear(this);">


 function onChangeCalendarYear(obj)
 {
            if(obj.value !=2011)
            {
                  then only submit the form
            }
 }
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
abuyusuf35Author Commented:
That still doesn't solve my problem - for now I have added a header key matching the year selected that solves the '-1' issue - but then the other issue still remains how do I resolve the duplicate 2011 ?
0
CEHJCommented:
>> any idea why the selected year always appears twice

Appears WHERE twice?
0
CEHJCommented:
You almost certainly need something like:
<script type="text/javascript">
	    function onChangeCalendarYear(select) {
		var year = select.value;
		if(year > 0) {
		    // You'd really set a form field
		    alert(year);
		}
	    }
</script>
 .....
	      <td align="center">Calendar Year
		  <select name="selectYear" id="selectYear" style="width:100px" onchange="javascript:onChangeCalendarYear(this);">
		      <option value="-1"
		      > Choose year</option>
		      <option value="1991">1991</option>
		      <option value="1992">1992</option>
		      <option value="1993">1993</option>
		      <option value="1994">1994</option>
		      <option value="1995">1995</option>
		      <option value="1996">1996</option>
		      <option value="1997">1997</option>
		      <option value="1998">1998</option>
		      <option value="1999">1999</option>
		      <option value="2000">2000</option>
.....

Open in new window

0
abuyusuf35Author Commented:
I've requested that this question be closed as follows:

Accepted answer: 0 points for abuyusuf35's comment http:/Q_27382778.html#36930670

for the following reason:

none of the suggested solutions resolved my issue
0
abuyusuf35Author Commented:
cancelled
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Java

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.