简体   繁体   中英

Adding string to the end of submitted URL?

I am putting together a simple tool for work where a user can add in some data to a form field which allows them to remotely access a device, but I need it to take them to the the login page.

<input type="text" name="prog_site" id="prog_site" value="http://" />
<a href="http://" onclick="this.href=document.getElementById('prog_site').value" target="_blank">Let's go!</a>

the above takes them to the said device, but I am having problems with adding a script that then adds on the following after the submitted info (which is an IP address)

/web/guest/en/websys/webArch/authForm.cgi

I have been looking at ways but need it to be as simple as possible?

Here is the full script:

    <script>
function open_win() 
{
window.open("");
}
</script>

<style>
body {
background-color: #fff;
}
</style>

<p><img src="logo.gif" /></p>

<p>Hello customer</p>

<p>Welcome to the Activation</p>

<p><a target="_new" href="">Instructions</a></p>


<input type="text" name="prog_site" id="prog_site" value="http://" />
<a href="http://" onclick="this.href=document.getElementById('prog_site').value" target="_blank">Let's go!</a>

Possibly I'm misreading the question, but what is wrong with:

<a href="http://"
    onclick="this.href=(document.getElementById('prog_site').value +
                       '/web/guest/en/websys/webArch/authForm.cgi')"
    target="_blank">Let's go!</a>

?

Your question not clear for me. But i think you want to add a QueryString into your URL. So you can simply add this using ? symbol.

var URL = "YourURL";
    URL = URL + "?IP=" + "YourString"; 

After Update -

<a href="http://" onclick="this.href=(document.getElementById('prog_site').value +'/web/guest/en/websys/webArch/authForm.cgi')" target="_blank">Let's go!</a>

Is this what you are trying to achieve?

<input type="text" name="prog_site" id="prog_site" value="http://" />
<a href="http://" onclick="this.href+=('/web/guest/en/websys/webArch/authForm.cgi?ip=' + document.getElementById('prog_site').value); return true;" target="_blank">Let's go!</a>

JSFiddle

<input type="text" name="prog_site" id="prog_site" value="http://" />
<input type="button" value="Let's go!" onclick="window.location.replace('http://web/guest/en/websys/webArch/authForm.cgi?ip='+document.getElementById('prog_site').value); return true;"></input>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM