Solved

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

Posted on 2004-04-28
8
229 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Webinar: Aligning, Automating, Winning

Join Dan Russo, Senior Manager of Operations Intelligence, for an in-depth discussion on how Dealertrack, leading provider of integrated digital solutions for the automotive industry, transformed their DevOps processes to increase collaboration and move with greater velocity.

 
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
 
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

Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Fulfillment API php code sample 1 72
Create animated movies for web page 18 119
What web tools we can use to create a web apps that holds clients data 3 23
Designing forms 3 41
FAQ pages provide a simple way for you to supply and for customers to find answers to the most common questions about your company. Here are six reasons why your company website should have a FAQ page
Color can increase conversions, create feelings of warmth or even incite people to get behind a cause. If you want your website to really impact site visitors, then it is vital to consider the impact color has on them.
This tutorial walks through the best practices in adding a local business to Google Maps including how to properly search for duplicates, marker placement, and inputing business details. Login to your Google Account, then search for "Google Mapmakerā€¦
The viewer will learn how to count occurrences of each item in an array.

740 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