Notice: This forum has been recovered from an old backup, so some content, links, and dates may be outdated. The forum is currently read-only while we restore sign-in and registration functionality. Details
If you find this forum valuable and would like to help keep it online, donations to help cover hosting and domain costs are greatly appreciated, but never expected. You can support the forum through Buy Me a Coffee or Ko-fi. Thank you for helping preserve the EventGhost community.
This seems like a basic question, but I couldn't find an example. On a webserver plugin html page, how do you generate an event from a dropdown select list? Here's what I have so far:
$('input[type="select"]').bind('change', function(event){
var id = $(this).attr('id');
var selected = $("#"+id+" option:selected");
"your get request";
});
Since you advised using javascript, I googled some other very basic examples and tried them. I don't get an Event generated in EG. What am I still missing?
Now the problem is that I use <meta http-equiv="refresh" content="5"> to refresh the page, and the event keeps getting sent on every refresh. Maybe a javascript version would avoid that.
Sorry that was my fault. I had a the id Case mismatched, i fixed the above example now. If your using raw javascript this function will work.
If you can show me how you have your get request to the server set up i can add it for you.
That code is progress. Now when I select an item, I get a popup that says, <Webserver> says: 68, but no EG event.
I would normally have a link like this, "<a href="commands.html?Test1">This is Test1</a>". When the link is selected, I would get an EG event like HTTP.Test1[]. That's what I'm looking for.
<script>
function onSelectFunction() {
var value = document.getElementById("setTemp").value;
window.location.href = "commands.html?Test1&" + value;
}
</script>
I would still look at one of the WS tutorials. It will probably change your thinking on how to go about all this stuff.
I really appreciate the help. That code works great. Because the page is set to refresh, once an item is selected, the event keeps getting generated. Any idea how to resolve that? I'm just trying to do a quick and dirty for my own use.
Edit: The repeat appears to be because the page changes from *.html to *.html?&69
<script>
function onSelectFunction() {
var value = document.getElementById("setTemp").value;
var request = new XMLHttpRequest();
request.open('POST', 'EG', true);
request.setRequestHeader('Content-type', 'application/x-www-form-urlencoded');
request.send('test1&' + value);
}
</script>
Sorry, I was referencing my earlier comment that I automatically refresh the page with <meta http-equiv="refresh" content="5">. I don't have a clue how to setup a websocket connection to do this.
<script>
function onSelectFunction() {
var value = document.getElementById("setTemp").value;
var request = new XMLHttpRequest();
request.open('POST', 'EG', true);
request.setRequestHeader('Content-type', 'application/x-www-form-urlencoded');
request.send('test1&' + value);
}
</script>