How to pass the jQuery Rating to PHP with the submit button

Asked 1 years ago, Updated 1 years ago, 41 views

I would like to use jQuery Rate (http://wbotelhos.com/raty) to give a five-step rating to the form of posting a review of a book.

<form action="review.php" method="post">
  <label class="control-label" for="title">Name of work</label>
  <input type="text" name="title" id="title" class="form-control">
  <label class="control-label" for="author">Author name</label>
  <input type="text" name="author" id="author" class="form-control">
  <label class="control-label" for="review"> impressions and opinions</label>
  <textarea name="review" class="form-control" rows="6">/textarea>
  <label class="control-label" for="star">Assessment (5 steps)</label>
  <divid="star"></div>
  <script type="text/javascript">
    $.fn.raty.defaults.path="./images";
    $('#star') .raty();
  </script>
</div>
<div class="form-group">
  <input type="submit" class="btn btn-primary" value="Send">
</div>

At this time, I would like to get the value that was voted for in review.php like $_POST['author'], and store the value in DB such as mysqli_query.

When I looked into it, I found out that there was a way to pass data to PHP using Javascript onclick, but there was no way to pass data using submit form.

I am a beginner who touched PHP and MySQL for the first time the other day (jQuery has little experience), so I would appreciate it if you could let me know.

javascript php jquery mysql

2022-09-30 19:55

1 Answers

http://wbotelhos.com/raty has a target entry.
It seems that you can change the value of input when ★ is selected.

<input id="hint" type="text"/>

If this type is hidden, data will be passed when the form is submitted.

<input id="hint" type="hidden"/>


2022-09-30 19:55

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.