I have a bit of javascript that finds an existing id and replaces it with a form.
Within that form I'd like to be able to add javascript variables to the submit url. I'm not sure if that's possible or if I'm just implementing it incorrectly.
$(document).ready(function () {
$("#FB_cs_redirectTextBox")
.replaceWith('<form class="cf" action="http://test.com/s/search.html?profile=_default&collection=general + document.getElementById(' + item-select + ').value" method="get">' +
'<input type="search" placeholder="Search for stuff" name="search" class="searchbox-input" required="">' +
'<select name="item-select" id="item-select" required="">' +
'<option value="" selected="selected">Item type...</option>' +
'<option value="level">item 1</option>' +
'<option value="taste">item 2</option>' +
'<option value="location">item 3</option>' +
'<option value="month">item 4</option>' +
'</select>' +
'<button type="submit" class="btn btn--green searchbox-submit">' +
'Search for items' +
'</button>' +
'</form>');
});
So this is my problem line I think:
action="http://test.com/s/search.html?profile=_default&collection=general + document.getElementById(' + item-select + ').value"
I was also wondering if this is possible, how I could also add the value of the select to the url action. Would I do this by applying the same id to all the options and then calling document.getElementById on that id name?
All help greatly appreciated!