0

I am trying to send specfic form data to a php update script to modify the stored values in our database, how do i pass the hidden value and the checked value.

<?php do { ?>
 <form>
<p> <?php echo $row_tasks['dept']; ?> / <?php echo $row_tasks['descrip']; ?> 
  <input type="checkbox" name="check" id="status" value="<?php echo $row_tasks['id']; ?   >">
  <input type="hidden"   id="tid" value="<?php echo $row_tasks['id']; ?>" />
  <input type="submit" name="update" id="update" value="Submit" />
 </p>
 </form>
 <?php } while ($row_tasks = mysql_fetch_assoc($tasks)); ?>
 <script>
  function showValues() {
  var str = $("form").serialize();
  $("#results").text(str);
 }
$(":checkbox, :radio").change(showValues);
$("select").change(showValues);
showValues();
 </script>
 <script type="text/javascript">
 $('form').submit(function() {
  alert($(this).serialize());
return false;
 });
 </script>
 <p><tt id="results"></tt></p
0

1 Answer 1

2

give the hidden input a name..

Sign up to request clarification or add additional context in comments.

3 Comments

ok redid the script and now the correct values show when on the alert step but the post data is equal to the last form generated, how do i have to only post the same values the serialize function has
<script type="text/javascript"> $('form').submit(function() { $.post("/scripts/savetask.php", $("this").serialize()); alert($(this).serialize()); return false; }); </script>
<?php do { ?> <form method="post"> <p> <?php echo $row_tasks['dept']; ?> / <?php echo $row_tasks['descrip']; ?> <input name="sid" type="hidden" id="sid" value="1"> <input name="tid" type="hidden" id="tid" value="<?php echo $row_tasks['id']; ?>" /> <input type="submit" name="update" id="update" value="Submit" /> </p> </form> <?php } while ($row_tasks = mysql_fetch_assoc($tasks)); ?> <div class="success" style="display: none;">Task has been added.</div>

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.