New user problem.
New user problem.
I have a little problem to get inputs value from <input> items.
I have a form with some fields, name, email ... and when i want to check users input values, i get an empty string.
here is my form code :
- <FIELDSET>
<LEGEND align=top>Contactez Nous</LEGEND>
<form id="formul">
<table cellpadding="0" cellspacing="5" width="100%">
<tr>
<td>Nom : *</td>
<td><input id="nom" name="nom" type="text" value="" /></td>
<td> </td>
</tr>
<tr>
<td>Prénom : </td>
<td><input id="prenom" type="text" value="" /></td>
<td> </td>
</tr>
<tr>
<td>Société : </td>
<td><input id="societe" type="text" value="" /></td>
<td> </td>
</tr>
<tr>
<td> </td>
<td> </td>
<td> </td>
</tr>
<tr>
<td>Email : *</td>
<td><input class="email" id="email" type="text" value="" /></td>
<td> </td>
</tr>
<tr>
<td>Téléphone : </td>
<td><input id="phone" type="text" value="" /></td>
<td class="comment"> </td>
</tr>
<tr>
<td> </td>
<td> </td>
<td> </td>
</tr>
<tr>
<td>Message : *</td>
<td><textarea id="message" rows="8" cols="10"></textarea></td>
<td> </td>
</tr>
<tr>
<td> </td>
<td> </td>
<td class="comment"><input type="button" value="Envoyer" onclick="SendMessage()" /></td>
</tr>
</table>
</form>
</FIELDSET>
And here is my JS code :
- function SendMessage()
{
var nom = document.getElementById('nom').value;
alert(nom);
nom = $("#nom").val();
alert(nom);
- }
If i write something on the 'nom' input, and press the button that will use the SendMessage() function, i always have 2 empty alerts...
What i am doing wrong ?
PS : jquery version : jQuery JavaScript Library v1.4.2