0


I have got the script below which I am using to pass a variable to a URL. When I click the search button it redirects to the URL including the variable in the text box however what I need to do is open the page in an iframe that opens beneath the search box so I can search again with the box still visible.
Any assistance would be much appreciated.
Many thanks,
Martyn.

P.S. I have removed the spreadsheet code from the URL.

<!DOCTYPE html>
<html>
<body>
Search by word (case sensitive):<br>
<input type="text" id="urlInput" value="">
<input type="hidden" id="urlInput2" value="%22">


<button onclick="redirect()">Search</button>

<script>
function redirect() {
var url = "https://docs.google.com/spreadsheets/d/XXXXXXXXXXXXXXXXXX/gviz/tq?tqx=out:html&tq=SELECT%20*%20where%20B%20contains%20%22" + document.getElementById('urlInput').value + document.getElementById('urlInput2').value;
window.location=url;
}
</script>

</body>
</html>

1 Answer 1

1

did you want this?

function redirect() {
  var url = "https://docs.google.com/spreadsheets/d/XXXXXXXXXXXXXXXXXX/gviz/tq?tqx=out:html&tq=SELECT%20*%20where%20B%20contains%20%22" + document.getElementById('urlInput').value + document.getElementById('urlInput2').value;
  document.getElementById('iframe').src = url;
}
#iframe {
  width: 100%;
  height: 80%;
}
Search by word (case sensitive):<br>
<input type="text" id="urlInput" value="">
<input type="hidden" id="urlInput2" value="%22">


<button onclick="redirect()">Search</button>
<iframe src="https://cn.bing.com/?scope=web" id="iframe"></iframe>

Sign up to request clarification or add additional context in comments.

1 Comment

That is exactly what I am after! Many thanks @xianshenglu

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.