Let's say I have a text box and a submit button on my page. After filling the text box and submitting, is it possible that I open a URL on new tab and then with JS run such code on that external page:
document.getElementById('input').value=val; // val is the data from my page
document.forms[0].submit();
so that data is submitted and user can directly see the results on that page.
I am not sure about runnig scripts on other pages but I would be glad if anyone can guide me generally which ways should I look for
Thanks in advance
Update 21/07: I tried to change my method to send form to the page that I want to redirect. So I created a model that stores url and form for that spesific address, because it differs, and may not have a form even.
After the form on my site is submitted, I send the model. And I put a JS function to be calles onload of body. So if there is data sent it will display the page in the iframe with this form generated is POSTed.
function onPageLoad() {
if ('@Model' != null) {
var model = @Html.Raw(Json.Encode(Model));
if(model.postForm != null){
document.getElementById("form-tab").innerHTML += model.postForm;
}
}
}
And the html part:
<form class="navbar-form navbar-right" role="search">
<div class="form-group">
<input type="text" class="form-control" name="datano" id="number"required>
</div>
<div id="form-tab"></div>
<div class="col-md-offset-5">
<button id="btnSubmit" type="submit" class="btn btn-default">Track</button>
</div>
</form>