How to write javascripts

How to write javascripts

Dear sir,
How to write a java scripts? I have a one table in that i have a radio button and soon..And also i have a submit button.If i didnt select any radio button and click on a submit button i have to get a one popup message...else if i select a any one row and submitted it has to perform some operation wat i have used...so how to do this sir please help me sir.....
Thanks and Regards
Harini.
View Answers

June 7, 2010 at 4:13 PM

Hi Friend,

Try the following code:

1)form.jsp:

<%@page import="java.sql.*"%>
<script>
function validate(form) {
var op = -1;
for (i=form.radio.length-1; i > -1; i--) {
if (form.radio[i].checked) {
op = i; i = -1;
}
}
if (op == -1) {
alert("You must select a radio button");
return false;
}

return true;
}
</script>
<form name="form" method="post" action="getInfo.jsp" onsubmit="return validate(form);" >
<table border="1">
<tr><td></td>
<th>Id</th>
<th>Name</th>
<th>Address</th>
</tr>
<%
int i=0;
try{
Connection conn = null;
Class.forName("com.mysql.jdbc.Driver").newInstance();
conn = DriverManager.getConnection("jdbc:mysql://localhost:3306/register","root";, "root");
ResultSet rs = null;
Statement st=null;
st=conn.createStatement();
rs = st.executeQuery("select * from data");
while(rs.next()){ %>
<tr><td><input type="radio" name="radio" value=<%= rs.getString("id") %>></td>
<td><%= rs.getString("id") %></td>
<td><%= rs.getString("name") %></td>
<td><%= rs.getString("address") %></td>
</tr><%
i++;
}
}catch(SQLException e){ System.out.println(e.getMessage()); } %>
</table>
<input type="hidden" name="count" value="<%=i%>">
<input type="submit">
</form>

2)getInfo.jsp:

<%@page import="java.sql.*"%>
<%
String id=request.getParameter("radio");
Class.forName("com.mysql.jdbc.Driver").newInstance();
Connection conn = DriverManager.getConnection("jdbc:mysql://localhost:3306/register","root";, "root");
Statement st=conn.createStatement();
ResultSet rs = st.executeQuery("select * from data where id='"+id+"'");
if(rs.next()){
out.println("Your name is: "+rs.getString("name"));
}
%>

Thanks









Related Tutorials/Questions & Answers:
How to write javascripts - JSP-Servlet
How to write javascripts  Dear sir, How to write a java scripts? I have a one table in that i have a radio button and soon..And also i have... and submitted it has to perform some operation wat i have used...so how to do this sir
How to write javascripts - JSP-Servlet
How to write javascripts  Dear sir, I got u r code ,thanks for posting me ,but i have a problem.In a table if no of rows are present then its works fine,when their is only a single row then if i select that row
Advertisements
Javascripts events
Javascripts events  Write a JavaScript code to explain, atleast 10 HTML DOM events with example
How to write Java Program
How to write Java Program  how to write a program to find average of 5 student marks
How to write in File in Java
How to write in File in Java  Hi, How to write in File in Java. Please suggest and give example of this program. thanks
How to write in File in Java
How to write in File in Java  Hi, How to write in File in Java... the (BufferedReader) constructor. So that we write some data suing bufferedWriter object to write in the file. For more details and examples related to How
how to write code for this output?
how to write code for this output?   1 2 2 3 3 3 4 4 4 4 5 5 5 5 5
How to write image in Jmagick
How to write image in Jmagick  hi, I am new in Java I am using the Jmagick library, how can I write an image in Jmagick ? Thanks.   hi, You can try this snippet into your code ImageInfo ii = new ImageInfo("abc.jpg
How to Write to file in Java?
How to Write to file in Java?  How to Write to file in Java Program... the Examples of How to write to File in Java Program: WriteToFileExample.java import... how to write in a file."); br.close(); } catch (Exception e) { System.err.println
how to write this program
how to write this program  Write a program in java which calculates a studentââ?¬â?¢s overall gpa for a semester and then displays a studentââ?¬â... or numerical grade. You will be submitting TWO versions of this program. Write one
How to write text on image
How to write text on image  hi, I am using the Jmagick library. I want to write text on image, how is it possible ? Thanks.   hi, I am new in Jmagick but, I used the following code and it might also help you
how to write in xml? - XML
how to write in xml?  can anybody give the code how to write in xml file. i wan to write inside the tag, so what i have to do? Thanks...  ...) tFormer.setOutputProperty(OutputKeys.METHOD, "text"); // Write the document to a file
How to write calculator in J2ME program?
How to write calculator in J2ME program?  How to write calculator in J2ME program
how to write servlet program in eclipse?
how to write servlet program in eclipse?  how to write servlet program in eclipse
how to write store procedure in sql
how to write store procedure in sql  How to write a store procedure in SQL Server
How to write to file using FileOutputStream
How to write to file using FileOutputStream  Hi friends, Please help me in java program. How to write to file using FileOutputStream? thanks,   Hi, To write a file using FileOutputStream, we have to use
how to write java data - XML
how to write java data  how to write data to xml file  Hi friend, Read for more information, http://www.roseindia.net/xml/dom/ Thanks
How to Write To File BufferedWriter in Java
How to Write To File BufferedWriter in Java  how to write to file... to write texts. In this classwe stores the character in a buffer to write into a single character or arrays and strings. Some programmers as so suses write
how to write to file at the end of the line
how to write to file at the end of the line  Hi, Where do i learn how to write to file at the end of the line using Java program. Plz suggest... will help you for "How to write the file at the end of line using Java language
how to write file from FileInputStream
how to write file from FileInputStream  Hi, How to Write a file.... Thanks,   Hi, For Write to file from FileInputStream in java you may use... this website Write to file from FileInputStream in java
How to write file by line in Java
How to write file by line in Java  How to write file by line in Java   Hi, For Write to a file by line using java programming language we... in a new line. How to use Write To File By Line in Java programs
How to write method for UITableView didSelectRowAtIndexPath?
How to write method for UITableView didSelectRowAtIndexPath?  Hi, Please tell me how to write method for UITableView didSelectRowAtIndexPath? Thanks   HI, Here is the code: -(void)tableView:(UITableView *)tableView
How to write a loop and a while loop
How to write a loop and a while loop  How do I write a 1 loop and a 1 while loop for the example code: public boolean isTheFirstOneBigger (int num1, int num2) { if (num1 > num2) { return true
How to write first example in Ajax?
How to write first example in Ajax?  Hi, I am beginner in Ajax and want learn it. How can I write first example in Ajax? Thanks   Hi, Please check the tutorial First Ajax Example. Thank
how to write append file in Java
how to write append file in Java  How to write append file in Java... existing file should be retained when you are trying to write new contents... to FileWriter constructor to write a stream of characters. The Constructor
How to write into CSV file in Java
How to write into CSV file in Java  How to write into CSV file... passed the file name to write into a stream characters. Then we use the FileWriter Object to PrintWriter instance. How to create File to CSV in Java
How to write to xml file in Java?
How to write to xml file in Java?  Hi Friends, Can anyone help me how to write in xml file in Java programming. Please fill free to give example or reference website for getting example.   Hi, To write in xml file
how to write and read text for javaME
how to write and read text for javaME  Hi. I have tried ur read/write coding but why i didnt get the o/p just like urs. do i have to add anything from the library? i want to type multiple line on text file then, read it from
how to write this program? - Java Beginners
how to write this program?  (game:scissor,rock ,paper) A program that plays the sciccor-rock-paper game.Revise the program to let the user continuously play until either the user or the computer wins more than 4 times
How to write to file using FileWriter
How to write to file using FileWriter  hi, How to write to file using FileWriter thanks,   Hi, To writing in a file in Java program we uses a class in java.io package named FileWriter. The main object
how to write the program - Java Beginners
how to write the program  WAP to create the report card user input Name, Class, Division, Roll no., Marks obtained in following subjects Lang Hindi History Geography Math Phy Chem. Bio Eve CSTA Also has a back up
How to write a simple java applet
How to write a simple java applet   Hi, how can i write a simple java applet, displaying text in specific colors and font style. For example, the output will be something like : Name in red color Age in blue color Nationality
in string how will write the return statement..........?
in string how will write the return statement..........?  import java.util.Scanner; class BinaryConversion12{ static int j=1; static int l=1; public static void main(String args[]){ int i=Integer.parseInt(args[0
How To Write the FORM Tag Correctly for Uploading Files?
How To Write the FORM Tag Correctly for Uploading Files?  How To Write the FORM Tag Correctly for Uploading Files
how to write a query for adding records in database
how to write a query for adding records in database  How write fire query in JSP for adding records in database
how to write a english dictionary project in java
how to write a english dictionary project in java  please give me idea how to write program/source code for dictionary project
How to Write to a File in Java
In this Java tutorial, we will demonstrate how to write to a file in Java... will be able to use OutputStreamWriter on a FileOutputStream classes to write data to a file from Java program. To write the Java Write To File we will use two
How to write a file in Java?
How to write a file in Java? To write a file in Java use the class FileWriter and BufferedWriter. Class FileWriter: The FileWriter class is used to write... and strings. Example of how to write text to a file in java:ADS_TO_REPLACE_6 import
how to read and write an xml file using java
how to read and write an xml file using java  Hi Can anyone help me how to read and write an xml file which has CData using java
How to write in Binary file in Java programming language
How to write in Binary file in Java programming language  I need some help about Java programming. Please explain me "How to write in Binary file in Java programming language
How to write a search functionality using javascript/jquery
How to write a search functionality using javascript/jquery   How to write a search functionality using javascript/jquery for ex: im searching "s" names it wil display "s" names
how to write a program to search a record using mvc2
how to write a program to search a record using mvc2   how can we write a code to search a record in table by using java bean as model, servlet as contoller and jsp as view
how to read and write xml files in javascript
how to read and write xml files in javascript  hi m very new to javascript and xml,, now i want to read and write xml files in javascript,, please give me a sample code to do
How to write file text In New Line
How to write file text In New Line  Hi friends, How to write file text in new line in Java program. How to write the syntax for this with example. thanks   Hi, For write a new text new line we need bufferedwriter
How to write jsp/servlet code to integrate LINKDIN?
How to write jsp/servlet code to integrate LINKDIN?  How integrate linkdin api's in java codding
how to write to file from string in Java
how to write to file from string in Java  Hi, Please any one help me for how to write to file from string in Java. I am beginner in Java programming. Thanks,   Hi, Are you eager to learn how to write to file from
how to write to file primitive type double
how to write to file primitive type double  Hi, How to write to file primitive type double in java program? thanks   Hi, To write... a writeDouble() method to write a double value in binary files. writeDouble
How to write the code for date in swings - Struts
How to write the code for date in swings  Hi Friends, I want to code for display the calendar.......technologies use only swing and core java also how to display calendar like that popup window.....please write and send me
How to write file from inputstream in java
How to write file from inputstream in java  Hi, how to write file from inputstream in java program. Plz suggest an example or suggested link... link to your query "How to Write to inputStream in Java". This is good
How to write a session code - Java Beginners
How to write a session code   Once Again Thanks Deepak...Thanks for continuing responce I want using session in my project plz help me how to write a session code plz write a session code and post answer my personal id

Ads