Hello everyone, friends!
How to implement the following:
Suppose there are three imput for a subsequent GET request:
1. Name (variable x)
2. Cost (variable z)
3. Comment (variable y)
The user fills out a form, clicks on the button "Create" and for example in textarea receives a link:
site.ru/?x= test% 20 name&z=50.00&y= hello% world 20

Grateful for any help or direction!

    1 answer 1

    Well, nobody canceled string concatenation, except that you need to add processing of spaces and other characters. Those. Space -% 20 and other characters. Here read about encode . Well, the implementation is simple:

    var name = $("input1").val(); var cost = $("input2").val(); var comment = $("input3").val(); var tmp = "site.ru/?x"+name+"&z="+cost+"&y="+comment; var result = encodeURI(tmp); $("textarea#tar1").html(result); console.log(result); 

    UPDATE

    https://jsfiddle.net/j14xpfwo/4/ here is the solution (albeit not very beautiful).

    • Thank you very much! I'm just starting to learn java. Could you help me with jsfiddle.net/j14xpfwo as an example? I tried to reproduce this function, but nothing comes out of me ( - Anton Bogomolov
    • one
      @SergeyPlaxin Glad to help! Well, if you need to java, plz add a java tag to your question. JFY - javascript! = Java;). By sabzh - [read here] ( stackoverflow.com/questions/10786042/… ) about the class URLEncoder that provides the necessary functionality. Actually - the same as in my code). Well, actually there is no $ ("input") in java. this is the jquery syntax of the js library. In java there are forms, getting objects on a form is not a time consuming task. - alexoander
    • Here's your corrected version - jsfiddle.net/j14xpfwo/4 . Apparently you still need the javascript option =) - alexoander