I have total 3 elements
What I want is... On Button Click It should Take the parameters from TextBox & DropDown and return the data on Button Click
this.html
<div class="input" div id="Searching"><input type="text" name="Search" id="Search" class="ContextualSearchField" placeholder="Search" size="40" value=""/></div>
<div class="dropdown">
<button class="dropbtn">Search▼</button>
<div id="myDropdown" class="dropdown-content">
<a id="Alert" type="button" class="btn btn-lg btn-default" href="#">Alert</a>
<a id="IR" type="button" class="btn btn-lg btn-default" href="#">Incident Report</a>
<a id="Site" type="button" class="btn btn-lg btn-default" href="#">Site</a>
<a id="Devices" type="button" class="btn btn-lg btn-default" href="#">Devices</a>
</div>
</div>
<button type="submit" onclick="SearchContext()" id="searchbutton">Search Now</button>
this.js
var Search = document.getElementById("Search").value;
alert(Search);
Dropdown = document.getElementById("myDropdown").value;
SearchButton = document.getElementById("searchbutton").value;
var Alert = document.getElementById("Alert").value;
var IR = document.getElementById("IR").value;
var Site = document.getElementById("Site").value;
var Devices = document.getElementById("Devices").value;
I have also created service for them in jquery.services.js
just tell me how to put those parameter on button
Just put an event listener on your button than do your things in this scope.
document.querySelector('.dropbtn').addEventListener('click',function(){
//do your required things in here. E.g:
var Site = document.getElementById("Site").value;
var Devices = document.getElementById("Devices").value;
});
If you want to put them in a element, just add parameter to element. E.g:
<button id="example" lang="tr" user-id="15" target="Search">Click me</button>
and for take this parameters from JS, do like this with using HTML element function getAttribute()
:
var lang = document.getElementById('example').getAttribute('lang');
var user_id = document.getElementById('example').getAttribute('user-id');