Simple HTML forms action

Hopefully a simple question here. If in HTML I have a form like this:

<form name="f_input" action="Test="+num target="TargetFrame" method="get">
Set Number: <input type="text" name="num" value="10">
<input type="submit" value="Submit">
</form>

When I click the button it goes (in the separate TargetFrame frame) to "Test=?num=10". I want it to go to "Test=10", how do I do that?

Answers


HTML forms do not provide that capability.

The closest you could get would be:

action="/"

and

name="Test" value="10"

which would give you: /?Test=10


If you really want just Test=10 then you would have to use JavaScript to capture the submit event of the form and override the normal form behaviour. This adds a dependancy on JavaScript so is not a good idea. It would be better to modify the server side of the program to handle the standard form submission schemes.

document.querySelector('form').addEventListener("submit", customSubmission);

function customSubmission(evt) {
    evt.preventDefault();
    document.frames.TargetFrame.src = "Test=" + encodeURIComponent(this.elements.num.value);
}

Need Your Help

Spring Security - Authenticate not by IP but by Domain/SubDomain?

java spring spring-security

I have a Spring based web service that I want to provide Spring security. Its working and that it can authenticate through USER and ADMIN roles. However I have a new requirement that I need to

Is ASP.NET MVC's FileStreamResult less efficient than writing directly to the Response Output Stream, or am I missing something?

c# asp.net-mvc stream

First of all, I love ASP.NET MVC. This question is not a criticism of it. Rather, I want to confirm what I think I see and make sure I haven't missed something. Bear with me ... I can't get to the