node.js - Get request.params via an html form? -


this question title edited. original title "how can submit string in form , have applied request parameter in url?".


think of simple server string received route parameter, e.g. localhost:3000/hello serves page containing 'hello'.

this implemented, here simple express server doing that:

var express = require("express"); var app = express();  app.get("/:string", function(req, res) {   res.send(req.params.string); });  app.listen(3000); 

is possible supply string via form?

isn't hidden parameters start with...?

<form action="http://www.example.com" method="get">   <input type="hidden" name="a" value="1" />    <input type="hidden" name="b" value="2" />    <input type="hidden" name="c" value="3" />    <input type="submit" />  </form> 

i wouldn't count on browser retaining existing query string in action url.

as specifications (rfc1866, page 46; html 4.x section 17.13.3) state:

if method "get" , action http uri, user agent takes value of action, appends `?' it, appends form data set, encoded using "application/x-www-form-urlencoded" content type. maybe 1 percent-encode action-url embed question mark , parameters, , cross one's fingers hope browsers leave url (and validate server understands too). i'd never rely on that.

by way: it's not different non-hidden form fields. post action url hold query string though.


Comments

Popular posts from this blog

php - How to add and update images or image url in Volusion using Volusion API -

javascript - jQuery UI Splitter/Resizable for unlimited amount of columns -

javascript - IE9 error '$'is not defined -