1

I want to Create a Form, that when its Submitted opens a link with a Variable which is the Input from the Textfield of the Form.

Here is an example:

<form onsubmit=<a href="http://www.link.xx?123&456&input=$UserInput target"_blank">
<p><input type="text" name="name" value="UserInput"/></p>
<p><input type="submit" value="Verbinden" /></p>

I do not need a Solution to get this exact example to work. All I want is:

The User Puts Something in The Form and presses the Submit Button. With Pressing the Submit Button the Browser opens The Link i provide with the Input as a Part of the Link.

In real life it means i want to use a Teamspeak Join Link with the username which the user has provided in the Form.

This is the Link that has to be Modified at the end with the username

ts3server://serverip?port=11&password=123&nickname=!Input from the Form!

I hope there is a better Way than the way i use at the moment:

form.html =

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" 
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en-US" lang="en-US">
<head>
</head>
<body>
<center>
<table border="0" cellspacing="0" cellpadding="0" width="200" id="LayoutBereich5" style="background-attachment: fixed; border: 1px solid rgb(179,0,180); margin: 1px; height: 50px;" >
<tr align="center" valign="top">
<td>

<form action="startts3.php" method="post">
<p>Namen bitte anpassen:
<p><input type="text" name="name" value="InGameName|RealName"/></p>
<p><input type="submit" value="Verbinden" /></p>

</td>
</tr>
</table>
</center>
</body>
</html>

startts3.php =

<?php
$name = $_POST["name"];
header("Location: ts3server://serverip?port=11password=123&nickname=$name"); 
exit;
?>

3 Answers3

1

You can try this:

<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<form>
  <p><input type="text" name="name" value="UserInput"/></p>
  <p><input type="submit" value="Verbinden" /></p>
</form>
<script>
  $("form").submit(function(event) {
    event.preventDefault();
    window.location.href = "ts3server://serverip?port=11&password=123&nickname=" + $("input[name=name]").val();
  });
</script>

It doesn't actually submit the form: JavaScript takes over and opens it by itself.

EDIT As per request, I've included the JS alongside the HTML to show how it can be used.

Jonathan Lam
  • 16,831
  • 17
  • 68
  • 94
  • Hi, thanks for the fast and really amazing answer. Sorry for the nooby question, but where do i put the upper part with $("form")..... inside of my HTML file? I often have no plans of what i´m doing but i try and try as you can see on my original and also "working" solution for which i neede the whole day .... – Jonas Sobottka Jun 30 '16 at 23:42
  • @JonasSobottka You need to put it in a ` – Jonathan Lam Jun 30 '16 at 23:42
  • Wow, thank you again. Now it works like a charm. Well done :) – Jonas Sobottka Jun 30 '16 at 23:48
  • @JonasSobottka I'm glad I helped! Just don't forget to accept my answer to show others it helped (click the check mark next to the answer) :) – Jonathan Lam Jun 30 '16 at 23:49
0

If I got you right, I would do something like:

<form action="http://www.link.xx?123&456" method="GET" target"_blank">
    <p><input type="text" name="name" value="UserInput"/></p>
    <p><input type="submit" value="Verbinden" /></p>
</form>
Itay Merchav
  • 954
  • 8
  • 8
0

You can use GET form method to this (if it's ok that your port and pass place in html) What you should do is that place your parameters that need send in hidden inputs and set action = your target : ts3server://serverip

so:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" 
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en-US" lang="en-US">
<head>
</head>
<body>
<center>
<table border="0" cellspacing="0" cellpadding="0" width="200" id="LayoutBereich5" style="background-attachment: fixed; border: 1px solid rgb(179,0,180); margin: 1px; height: 50px;" >
<tr align="center" valign="top">
<td>

<form action="ts3server://serverip" method="get">
    <input type="hidden" name="port" value="11" />
    <input type="hidden" name="password" value="123" />
<p>Namen bitte anpassen:

<p><input type="text" name="nickname" value="InGameName|RealName"/></p>
<p><input type="submit" value="Verbinden" /></p>
</form>
</td>
</tr>
</table>
</center>
</body>
</html>