+ 3

Form Redirect

Sorry for the dumb question, but i wanna know that, I'm creating a form. It has a submit button too. So i wanna to redirect to a specific website on submit. Elaboration ~~~ like if i submit <#GYJ20QVJ>.It'll redirect to <clashforever.online/coc_cf/clan.php?tag=#GYJ20QVJ>. Or if i type <#Y0JCGJUU> In put, and on submit it'll redirect to <clashforever.online/coc_cf/clan.php?tag=#Y0JCGJUU>..help me please with a example.

14th Nov 2020, 5:39 AM
simple boii
simple boii - avatar
12 Réponses
+ 3
🙂King😉 Check this example https://code.sololearn.com/WcYSaxO4YG25/?ref=app You'll have to modify it with something like this <form action="https://clashforever.online/coc_cf/clan.php" method="GET"> <input type="text "name="tag" value="#GYJ20QVJ"> <button type="submit">Send</button> </form>
14th Nov 2020, 8:36 AM
Tibor Santa
Tibor Santa - avatar
+ 3
Thank you very very much... You're very helpful🙂😄😄
14th Nov 2020, 11:55 AM
simple boii
simple boii - avatar
+ 2
Didn't get that from, can you please show that with a example here. It'll be helpful🙂☺️Tibor Santa
14th Nov 2020, 7:25 AM
simple boii
simple boii - avatar
+ 2
Show your code, please. It would be easier to debug.
14th Nov 2020, 1:41 PM
Tibor Santa
Tibor Santa - avatar
+ 2
You can remove the value (it is just a default that the user can override) But the name atrribute is important
15th Nov 2020, 12:22 PM
Tibor Santa
Tibor Santa - avatar
+ 1
Here is a full guide to forms. https://developer.mozilla.org/en-US/docs/Learn/Forms/Sending_and_retrieving_form_data Check the example about the GET method. It should give you an idea, how to set the attributes of the form and input fields, that is similar to your question.
14th Nov 2020, 5:47 AM
Tibor Santa
Tibor Santa - avatar
+ 1
Your code is semantically incorrect, and you did not even follow the example I gave you. Your opening FORM tag is missing and it should have an action attribute pointing to the root url, and method=GET Then you should probably get rid of the javascript part, form submit works fine without any fancy JS too. And I suggest to use the <button> tag instead of <input> at the end. Just check my example again.
15th Nov 2020, 10:11 AM
Tibor Santa
Tibor Santa - avatar
+ 1
Ok i followed you example. See here https://code.sololearn.com/WaIASr94EaJ4/?ref=app Tibor Santa . Read the comment on the code to understand what i meant and enter the tag "GYJ20QVJ" too.
15th Nov 2020, 11:01 AM
simple boii
simple boii - avatar
+ 1
You are almost there. Some small changes: <form action="http://clashforever.xyz/coc_cf/clan.php" method="GET"> <input type="text" name="tag" value="GYJ20QVJ"> <button type="submit">Submit</button> </form> Try it.
15th Nov 2020, 11:16 AM
Tibor Santa
Tibor Santa - avatar
+ 1
Tibor Santa yeah right, but you've entered a value there. But i want that if anyone enters any value in the "input". Here i have to change value in the code everytime...... How to avoid this?
15th Nov 2020, 12:10 PM
simple boii
simple boii - avatar
0
Tibor Santa i see that the action url is <http://clashforever.xyz/clan.php?tag=<{The input entered in the form}>. It's correct, but when I'm redirecting it, it's included a extra "+", i mean the redirecting url becomes <http://clashforever.xyz/coc_cf/clan.php?tag=<{entered input} +>. So i can't understand why it's including the extra "+", the url is becoming incorrect of this🤔. Please help if you can☺️
14th Nov 2020, 12:06 PM
simple boii
simple boii - avatar
14th Nov 2020, 2:41 PM
simple boii
simple boii - avatar