Thank you in advance.
I am still learning JavaScript and as a project approached, really need some help/insight.
The logic that I am working on is this:
1. HTML structure:
<input title="Type Here" class="search" type="text" placeholder="Type Here"> <select id="device_select"> <option id=one value='a'>a</option> <option id=two value='b'>b</option> <option id=three value='c'>c</option> <option id=many value='many'>many</option> </select> <span class="content-btn-1" type="button"></span>
2. JS structure:
$(function(){
var one = {title:"titletext", description:"descrtext", keyword:"text",
subject:"533,567,457", provider:"c9drlt-sdgtrzz", training:"true"};
var two = {title:"titletext", description:"descrtext", keyword:"textthis",
subject:"537", provider:"c9drlt-sdgtrjt", training:"false"};
});
3. JS logic structure:
function search_class() { if (training == true) {training = "&tr=0";} else {training = "";} return training; } function search_custom() { // NOT SURE HOW TO PULL IT UP // if subject has more than 1 variable like subject:"533,567,457" // then construct the logic to separate them: // &s=533&s=2&567&s=3&457 return subject; } var url = "www.website.com"; var text_area = $('.search'); var btn_click = $('.content-btn-1'); btn_click.click (function () { var value = text_area.val(); var ty = "#s="; if ($.trim($(text_area).val())) { window.location.href = url+ty+search_class()+search_custom(); } });
4. The outcome:
www.website.com#s=titletext&d=descrtext&t=text&p=c9drlt-sdgtrzz&tr=0&s=533&s=2&567&s=3&457
5. The hard part: How can we do the logic so it takes that array in #2, attaches to the option id one, two ... etc in #1 and then constructs the link in #3 on click?
In nutshell: This is a search function with options that has unique variables.
Appreciate any help!