Forms, Post and submit buttons

2019-08-07 14:54发布

I feel a little silly asking this but I wanted everyones opinion on it.

I want to submit a page, target itself, on the press of a button but carrying one piece of data with it.

Example:

Edit | Delete

On the click on edit, I want the page to reload with $_POST['example'] === "edit" or something. I don't want to use $_GET and I don't want to use the ugly submit button.

Any ideas?

标签: php html css forms
6条回答
▲ chillily
2楼-- · 2019-08-07 14:56

Create form carrying the data you want to send and send it using JavaScript when you click a link if you want to avoid submit buttons.

查看更多
神经病院院长
3楼-- · 2019-08-07 15:03

You should probably go ahead and use submit buttons, but use CSS to change how they look. For example:

<input class="aslink" type="submit" />

.aslink {
    background: transparent;
    border: none;
    cursor: pointer;
    text-decoration: underline;
}
查看更多
老娘就宠你
4楼-- · 2019-08-07 15:06

<input class="aslink" type="submit" />

.aslink { background: transparent; border: none; cursor: pointer; text-decoration: underline; }

ideally you would want to write the css out like this:

input.aslink

doing this will lock down those styles to ONLY being used by input tags with the appropriate class

查看更多
姐就是有狂的资本
5楼-- · 2019-08-07 15:12

You could use the button tag:

<button type="submit">put some html</button>

You can put html tags or images in to it and style it to your hearts content.

查看更多
Animai°情兽
6楼-- · 2019-08-07 15:17

You could use Ajax to submit a POST request or style a submit button to look like a link (or whatever else you'd like).

查看更多
趁早两清
7楼-- · 2019-08-07 15:19

You may submit your form via link.

<a href='#' onclick='document.myform.submit()'> Edit </a>
查看更多
登录 后发表回答