URL - Encodeing (javascript) method=“GET”

I have a form with some input fields (6). When I click the submit button "I would like to format the URL" in such a way:

/actionname?input1|input2|input3|input4|input5|input6

and maybe for null values: /actionname?input1|input2||input4||input6

and maybe a time-stamp for when the user clicks the submit button.

Can this be done using javascript.

Thanks,

Chad

Answers


if you are using any java script library like jQuery, you can serialize the form which gives the data in query string format. ex: see here


It can be done via javascript but I can't understand why you would want to. You would have to use the onsubmit event of the form, loop through the form elements appending each value to a url string in the format you offered and then setting window.location to that url string.

For users with javascript disabled, the form would still submit in the "proper" manner, which is why I can't understand why you would want to change the format of the query string.


Need Your Help

“The name 'GRID' does not exist in the current context” error

c# windows forms

List item Hey guys recently have been doing my first ever windows forms/c# application and i cannot get rid of this error. I've dragged and dropped data grid view into my form and renamed it GRI...

Developing as a programmer

c++ mfc stl

I have been learning C++ for three months now and in that time created a number of applications for my company. I consider myself fairly comfortable with C++ / MFC and STL, however I don't just wan...