How to write javascripts

Ads
 

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 for to do some operation den a alert message is showing that "You must select a radio button" .so please help me sir...
Thanks and Regards
Harini veerapur.
View Answers

June 8, 2010 at 10:49 AM

Hi Friend,

Try the following:

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(form.radio.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/test","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>

Thanks

Ads









Related Tutorials/Questions & Answers:
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
Advertisements
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 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 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 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
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 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 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 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 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 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 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

Ads