Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 237
  • Last Modified:

Can Java or something run a query when a button is clicked?

What I am trying to do is when a radio button is checked, and everytime it is checked to run a specific query.

Like:
APPROVED -> runs update ..... set approv='APPROVED'
DENY  -> runs update ..... set approv='DENY'

The radio buttons will be dynamic, meaning the amount of approved, and deny buttons will be based on a cfquery.  I really don't want the page to refreash on each click either.  Is this possible?  Thanks
0
Meps
Asked:
Meps
  • 2
  • 2
  • 2
  • +1
1 Solution
 
l0_0laelienCommented:
hi Meps,
do you want to run the query when u click the submit button?, one diferent query for each radio, right?.. And are u using JSP and Java ?
0
 
MepsAuthor Commented:
That is the thing, there will be no submit button, only the radios.  One for Approve, and one for deny.  Right now I am not using either JSP, or Java.  But I figured that HTML, or CFML will not be able to preform this feature without java or the other.

Example of form:
A      D        Apples
A      D        Cookies
A      D        Locks


And you will just click on either the approved radio, or the deny radio, and go down the list, until either the list is done, or you have to leave.
0
 
l0_0laelienCommented:
i think u need to send the value of the checked radio (via URL) by Javascript on the onclick method of the radio, then catch that value and send it to your query.. in JSP i'll do something like :

updateQuery(request.getParameter("nameOfChecked"));
 
that's an idea.. :|
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
eeBlueShadowCommented:
Quite simply, the answer is no.

Javascript runs entirely on the users machine, and the code you will need to update the database or run a particular query must be stored on the server. The only way to exchange information between the two in a web browser is to submit information and retrieve another page in return.

What you could try and do is make the page quick loading so that the delay between different clicks is smaller. Or, you could look into developing a Java applet or Flash movie which can sit in the web page and keeps a connection to the sever open, letting you do real time updates.

Both of those options would need advanced coding skills though, so the refresh-every-click choice is probably your best option.

_Blue
0
 
Neil_SimpsonCommented:
Depending upon the data you need to transfer you could load it all into the HTML on the first page laod and then use Javascript and CSS to just display the relevant info when the radio button is checked. This avoids the page reload problem but relies on you being able to load all of the data initially so it really depends on your query/data.
0
 
Neil_SimpsonCommented:
If you need further help with this I'll be happy to provide it.
0
 
MepsAuthor Commented:
I was thinking about useing a query to display the items someone will need to approve, and inside the output have the radio buttons display, so if I have one item, there will only be one set of radio, if I have 50 items, there will be 50 sets.  So I know what is going to be on the page, and was curious if there was someway to do live updates when the buttons are clicked.

_Blue, what you say make sense.
0
 
eeBlueShadowCommented:
Well, consider the following:

In most cases, submitting any information to a server gets you another page which replaces the original. However, one time that doesn't happen is when the new page is loaded in a new window/frame/iframe - you still get the old page where it was before.

It is perfectly possible to have lots of forms on one page.

It is possible to have a form submit on an onclick event.

try the following HTML which submits the form on each mouse click, and loads the form in a *hidden* iframe so you never see the response. Note that the request is still sent to the server but there is no way to tell if there was an error.

Hopefully you can see how it all works and could be written into whatever loop you have to make the radio buttons

<!-- START CODE -->
<iframe name='t' style='display:none'>
</iframe><br>
<script>
function goForm(id)
{
    form = document.forms[id];
    form.submit();
    for(var i = 0; i < form.elements.length; i++)
    {
      form.elements[i].disabled=true;
    }
}
</script>
<form name='item1' target='t' action='show.php'>
<input type='radio' name='item1' value='approve' onclick='goForm("item1");'><br>
<input type='radio' name='item1' value='deny' onclick='goForm("item1");'><br>
</form>
<form name='item2' target='t' action='show.php'>
<input type='radio' name='item2' value='approve' onclick='goForm("item2");'><br>
<input type='radio' name='item2' value='deny' onclick='goForm("item2");'><br>
</form>
<!-- END CODE -->

_Blue
0

Featured Post

How to Use the Help Bell

Need to boost the visibility of your question for solutions? Use the Experts Exchange Help Bell to confirm priority levels and contact subject-matter experts for question attention.  Check out this how-to article for more information.

  • 2
  • 2
  • 2
  • +1
Tackle projects and never again get stuck behind a technical roadblock.
Join Now