Reputation: 19
I'm getting undefined ids probably because of stupid syntax error somewhere. I checked to make sure the ids in question (oTel and oTel2) are not duplicated anywhere (they're only there one time)
In a js function I have:
var ucville = $('#oVille').val();
var uctelp = $('#oTel').val();
var uctelp2 = $('#oTel2').val();
var ucEmail = $('#oEmail').val();
and if do:
alert(ucville+"\n"+uctelp+"\n"+uctelp2+"\n"+ucEmail);
I get for example:
Marseille undefined undefined [email protected]
Here is the html:
<div class="control-group">
<label>Ville</label>
<div class="controls">
<input type="text" class="form-control" id="oVille" name="fpVille" value="<?php echo $uville;?>">
</div>
</div>
<div class="control-group">
<label>Telephone 1</label>
<div class="controls">
<input type="text" class="form-control" id="oTel" name="fpTel" value="<?php echo $uctelp;?>">
</div>
</div>
<div class="control-group">
<label>Telephone 2</label>
<div class="controls">
<input type="text" class="form-control" id="oTel2" name="fpTel2" value="<?php echo $uctelp2;?>">
</div>
</div>
<div class="control-group">
<label>Email 1</label>
<div class="controls">
<input type="text" class="form-control" id="oEmail" name="fpCEmail" value="<?php echo $ucEmail?>">
</div>
</div>
I just don't see what is different for the telephone ids ?
Upvotes: 2
Views: 102
Reputation: 19
I changed the names of the ids and now they're seen (defined) whether they have values or not. This should mean that the original names exist somewhere else and were duplicated but searching everywhere I can't find where.
Upvotes: 0
Reputation: 15104
The problem is not in the javascript. It means that <?php echo $uctelp;?>
print nothing. So $uctelp
is empty.
You can check it by inspecting the DOM with the dev tools of your favorite browser.
Upvotes: 4