Forms, Post and submit buttons

2019-08-07 14:56发布

问题:

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?

回答1:

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;
}


回答2:

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).



回答3:

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.



回答4:

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.



回答5:

You may submit your form via link.

<a href='#' onclick='document.myform.submit()'> Edit </a>


回答6:

<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



标签: php html css forms