How do you post data with a link

后端 未结 7 1958
感情败类
感情败类 2021-01-30 18:15

I have a database which holds the residents of each house in a certain street. I have a \'house view\' php web page which can display an individual house and residents when give

7条回答
  •  鱼传尺愫
    2021-01-30 18:52

    This post was helpful for my project hence I thought of sharing my experience as well. The essential thing to note is that the POST request is possible only with a form. I had a similar requirement as I was trying to render a page with ejs. I needed to render a navigation with a list of items that would essentially be hyperlinks and when user selects any one of them, the server responds with appropriate information.

    so I basically created each of the navigation items as a form using a loop as follows:

      begin loop...
    • end loop.

    what it did is to create a form with hidden input with a value assigned same as the text on the button. So the end user will see only text from the button and when clicked, will send a post request to the server.

    Note that the value parameter of the input box and the Button text are exactly same and were values passed using ejs that I have not shown in this example above to keep the code simple.

    here is a screen shot of the navigation... enter image description here

提交回复
热议问题