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?
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 ChongCommented:
<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... ?
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
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

0
APD TorontoSoftware DeveloperAuthor Commented:
Thank you very much!!!!
0
Ultimate Tool Kit for Technology Solution Provider

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy now.

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
0
bigeven2002Commented:
Sorry, looks like you beat me to it.
0
APD TorontoSoftware DeveloperAuthor Commented:
Thank you both, I was working on that module for 12 straight hours and just got tired.
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
JavaScript

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.