posts - How to invoke a HTML custom button based on a HTML dropdownlist menu

I am a WordPress beginner and want a helpI created a HTML dropdown list like this:<select name="DropDownList1&qu

I am a WordPress beginner and want a help

I created a HTML dropdown list like this:

<select name="DropDownList1" id="DropDownList1">
    <option value="select you location">&#xf015 select your location</option>
    <option value="cairo">Cairo</option>
    <option value="alexanderia">Alexanderia</option>
    <option value="aswan">Aswan</option>
    <option value="port said">Port Said</option>
</select>

and also I created a HTML button like this:

<button type="button" name="restaurantpreview" type="submit" value="chefpreview">restaurantpreview</button>

I am trying to search about the code that I must use to :

  • when a user select a value from dropdown list

  • then the user click on my button

  • I get this value to my custom page and preview the list of restaurants in it

I am a WordPress beginner and want a help

I created a HTML dropdown list like this:

<select name="DropDownList1" id="DropDownList1">
    <option value="select you location">&#xf015 select your location</option>
    <option value="cairo">Cairo</option>
    <option value="alexanderia">Alexanderia</option>
    <option value="aswan">Aswan</option>
    <option value="port said">Port Said</option>
</select>

and also I created a HTML button like this:

<button type="button" name="restaurantpreview" type="submit" value="chefpreview">restaurantpreview</button>

I am trying to search about the code that I must use to :

  • when a user select a value from dropdown list

  • then the user click on my button

  • I get this value to my custom page and preview the list of restaurants in it

Share Improve this question edited Jun 12, 2019 at 15:25 MikeNGarrett 2,6711 gold badge20 silver badges29 bronze badges asked Jun 12, 2019 at 13:15 Moamen KhedrMoamen Khedr 33 bronze badges
Add a comment  | 

1 Answer 1

Reset to default 0

You want to use admin-post.php or admin-ajax.php (AJAX only) to allow your front-end form to interact with WordPress.

Setting this up will allow you to create an action where you use the $_POST array to find the content you're looking for with WP_Query and print it out as the response to your request.

Here's a decent guide to both methods: https://premium.wpmudev/blog/handling-form-submissions/

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745409753a4626475.html

相关推荐

  • posts - How to invoke a HTML custom button based on a HTML dropdownlist menu

    I am a WordPress beginner and want a helpI created a HTML dropdown list like this:<select name="DropDownList1&qu

    4小时前
    40

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信