Search code examples
htmlurlparameter-passing

Is it possible to pass a text input as a URL parameter on a particular page?


I want to pass the Text input parameters as a URL to coa.edu.mirantis.com/tool.

In the inspector I can see that it has the following parameters:

    render() {
        return <form onSubmit={this.handleSubmit}>
            <div className="row">
            <div className="col-sm-6">
                <label>
                    Certificate ID #:
                </label>
                <input
                        type="text"
                        name="cert"
                        placeholder="Ex: COA-1111-2222-3333"
                        value={this.state.cert}
                        className="form-control"
                        onChange={this.handleChange}/>
            </div>
            <div className="col-sm-6">
                <label>
                    Name as it appears on certificate:
                </label>
                <input
                    type="text"
                    name="name"
                    value={this.state.name}
                    className="form-control"
                    onChange={this.handleChange}/>
            </div>
            </div>
            <div className="row">
                <div className="col-sm-12">
                    <input type="submit" value="Verify" className="verify-btn"/>
                </div>
            </div>
        </form>

    }

And tried passing the input in the URL parameters, when typed into the address bar like this:

https://coa.edu.mirantis.com/tool?cert=COA-2300-110711-0100&name=Alexey+Kashavkin

But it doesn't work. The page opens without my values as default.

Also in the inspector I can see the URL after clicking verify:

https://coa.edu.mirantis.com/verify/?cert=COA-2300-110711-0100&name=Alexey+Kashavkin

And if I type that URL into the browser address bar, I get the json output as a page.

Maybe I need to pass the parameters to the URL some other way or it won't work anyway?

I need to add this link to a image on my site and when I click on the image it opens a site with certificate verification already with the result. Earlier I wrote a script in python with selenium, but it is difficult for me to add this script to the site correctly or it looks like I can't use it on the site, only for local use.


Solution

  • To populate an input with data passed in via the URL (or any other mechanism) the website that serves the HTML with those inputs needs to write code which will do it.

    You cannot create a link that pre-populates a form on an arbitrary third-party site. It would be a security problem if you could.