JS Reads one value, but not another

Hi Experts,

I have 2 textboxes as follows
            <div class="divDetailDivs">
                
                <label for="txtPickupDate" id="lblPickupDate" class="required detailControls">
                    Pickup Date:
                </label>
                
                <br>
                
                <input type="text" id="txtPickupDate" name="txtPickupDate" class="required detailControls"
                       maxlength="10" value="<?php echo $errand['pickup_date']; ?>">
                
            </div>

            <div class="divDetailDivs">
                
                <label for="txtReservID" id="txtReservID" class="detailControls">
                    txtReservID:
                </label>
                
                <br>
                
                <input type="text" id="txtReservID" name="txtReservID" class="detailControls"
                       value="<?php echo $errand['id']; ?>">
                
            </div>    
        

Open in new window


When I try to read the value from the first it works, but it does not in the second
var conf = document.getElementById('txtPickupDate').value; //Returns a value
var conf = document.getElementById('txtReservID').value; //Returns 'Undefined'

Open in new window


I do not get any errors.

Can anyone see why this is happening?
APD TorontoSoftware DeveloperAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
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.

Ryan ChongBusiness Systems Analyst , ex-Senior Application EngineerCommented:
<label for="txtReservID" id="txtReservID" class="detailControls">
                    txtReservID:
                </label>
                
                <br>
                
                <input type="text" id="txtReservID" name="txtReservID" class="detailControls"
                       value="<?php echo $errand['id']; ?>">

Open in new window


These 2 elements shouldn't it be defined with different names... ?

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
APD TorontoSoftware DeveloperAuthor Commented:
The resulting HTML is
<input id="txtPickupDate" name="txtPickupDate" class="required detailControls" maxlength="10" value="2014-06-09" type="text">

<input id="txtReservID" name="txtReservID" class="detailControls" value="75768" type="text">

Open in new window

APD TorontoSoftware DeveloperAuthor Commented:
Thank you very much!!!!
Big Business Goals? Which KPIs Will Help You

The most successful MSPs rely on metrics – known as key performance indicators (KPIs) – for making informed decisions that help their businesses thrive, rather than just survive. This eBook provides an overview of the most important KPIs used by top MSPs.

bigeven2002Commented:
Hello,

In your HTML, on line 16 for the Label tag, the ID is the same as the input tag.  So change your label tag ID to lblReservID
bigeven2002Commented:
Sorry, looks like you beat me to it.
APD TorontoSoftware DeveloperAuthor Commented:
Thank you both, I was working on that module for 12 straight hours and just got tired.
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
JavaScript

From novice to tech pro — start learning today.