Solved

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

Posted on 2004-04-28
8
226 Views
Last Modified: 2012-06-21
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
Comment
Question by:Meps
  • 2
  • 2
  • 2
  • +1
8 Comments
 

Expert Comment

by:l0_0laelien
ID: 10940931
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
 
LVL 3

Author Comment

by:Meps
ID: 10941070
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
 

Expert Comment

by:l0_0laelien
ID: 10941532
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
 
LVL 10

Expert Comment

by:eeBlueShadow
ID: 10944772
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
DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

 
LVL 4

Expert Comment

by:Neil_Simpson
ID: 10951677
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
 
LVL 4

Expert Comment

by:Neil_Simpson
ID: 10951684
If you need further help with this I'll be happy to provide it.
0
 
LVL 3

Author Comment

by:Meps
ID: 10976628
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
 
LVL 10

Accepted Solution

by:
eeBlueShadow earned 250 total points
ID: 10976770
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Popularity Can Be Measured Sometimes we deal with questions of popularity, and we need a way to collect opinions from our clients.  This article shows a simple teaching example of how we might elect a favorite color by letting our clients vote for …
"In order to have an organized way for empathy mapping, we rely on a psychological model and trying to model it in a simple way, so we will split the board to three section for each persona and a scenario and try to see what those personas would Do,…
The viewer will learn how to count occurrences of each item in an array.
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.

932 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now