John Davidson

How to "match" html hidden input with a chosen radio input in php?

0 comments
Message:


I want to $_POST the ID of the selected radio button. The problem is the value of my radio button is not the ID, but the string title.


foreach($products as $product) {
echo '<input required type="radio" id="'.$product->ID.'" name="product" value="'.$product->post_title.'">';
echo '<label for="'.$product->ID.'">'.$product->post_title.'</label><br>';
echo '<input type="hidden" name="postid" value="'.$product->ID.'">';
}

Is there a way I can "match" that hidden field, so I can access the proper value in $_POST?
If I just do $_POST["postid"] it does not work because it just gets the last record from the foreach loop



My Answer:
There are many things you could be asking about how to do, so it would be helpful if you could provide more specific information. However, here are some general steps on how to approach learning a new skill or task:

1. Research and gather information: Start by researching and gathering information about the skill or task you want to learn. This could include reading books, watching tutorials, or taking a class.

2. Break it down into smaller steps: Break down the skill or task into smaller, manageable steps. This will make it easier to learn and practice.

3. Practice regularly: Practice is key to mastering any skill. Set aside time each day to practice and improve.

4. Seek feedback: Ask for feedback from others who are experienced in the skill or task. Constructive feedback can help you identify areas for improvement.

5. Stay motivated: Stay motivated and committed to learning the skill or task. Celebrate small victories and milestones along the way.

6. Keep learning: Learning is a continuous process. Keep seeking new information and techniques to improve your skills.

Remember, learning a new skill takes time and patience, so be kind to yourself and enjoy the process.

Rate this post

3 of 5 based on 2256 votes

Comments




© 2024 Hayatsk.info - Personal Blogs Platform. All Rights Reserved.
Create blog  |  Privacy Policy  |  Terms & Conditions  |  Contact Us