Reputation: 67
I am trying to make an iframe change based on a text input field.
The string that I want to append to the url that the user will input is in the middle of the url though.
Have tried but not quite sure how to define it correctly
<script>
$("#search").click(function(e) {
e.preventDefault();
var url = "http://www2.sdfsdf.com/admin/agent_order_srch_ordet.asp?action=searchStrPostcode&idOrder=" $('#search').val(); "&Submit=Search";
$("#someFrame").attr("src", url;
})
</script>
Upvotes: 4
Views: 669
Reputation: 15616
You have a copy paste error inside your url variable. Here's the corrected version. And I used the plain javascript version to change the url.
<script>
$("#search").click(function(e) {
e.preventDefault();
var url = "http://www2.sdfsdf.com/admin/agent_order_srch_ordet.asp?action=searchStrPostcode&idOrder=" + $('#search').val() + "&Submit=Search";
$("#someFrame").get(0).src = url;
});
</script>
Upvotes: 2
Reputation: 337580
Try this:
$("#search").click(function(e) {
e.preventDefault();
var url = "http://www2.sdfsdf.com/admin/agent_order_srch_ordet.asp?action=searchStrPostcode&idOrder=" + $(this).val() + "&Submit=Search";
$("#someFrame").attr("src", url);
})
Note the +
character is used to concatenate string values together.
Upvotes: 1