APD Toronto
asked on
JS Reads one value, but not another
Hi Experts,
I have 2 textboxes as follows
When I try to read the value from the first it works, but it does not in the second
I do not get any errors.
Can anyone see why this is happening?
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>
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'
I do not get any errors.
Can anyone see why this is happening?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thank you very much!!!!
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
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
Sorry, looks like you beat me to it.
ASKER
Thank you both, I was working on that module for 12 straight hours and just got tired.
ASKER
Open in new window