I am making a manage screen for a website were you post articles. I have made it so a table holds all the values of the posts.
<table>
<tr>
<th>Post Title</th>
<th>Post Content</th>
<th>Tag</th>
</tr>
<tr>
<td id="examplePostTitle">Post Title</td>
<td id="examplePostContent">First 35 charecters of post........</td>
<td id="examplePostTag">Post Tag</td>
<td class="postEditButton" id="examplePostButton">edit</td>
</tr>
</table>
I have coded some javascript with jquery so that when the user clicks edit the rows are populated by input boxes.
var click = 1;
if (click == 1) {
$('#examplePostButton').click(function() {
$('#examplePostTitle').html('<input type="text" value="Post Title" size="10"/>');
$('#examplePostContent').html('<input type="text" value="First 35 characters of post........" size="20"/>');
$('#examplePostTag').html('<select><option>Animation</option><option>Programing</option> <option>Robotics</option><option>Other</option></select>');
click = 2;
});
}
if (click == 2) {
$('#examplePostButton').click(function() {
$('#examplePostTitle').html('Post Title');
$('#examplePostContent').html('First 35 characters of post........');
$('#examplePostTag').html('Post Tag');
click = 1;
});
}
For some reason you can click the edit button once and it changes into input boxes. Then when you click it a second time it will not change the variable and will not revert back to non input boxes. I have checked my code with multiple js and jquery validators so I am no quite sure why the second click function isn't working.
tl:dr:
I have some javascript and jquery code, isnt working, help.
Jsfiddle