Consume rest service in jsp page - javascript

I am learning spring mvc rest programming and got stuck at the below issue.
I have an item page in JSP which is used for adding a new item as well as editing an item.
What I did here is (not sure if this is the right approach), I have a controller method
#RequestMapping(value = "/item/{id}", method = RequestMethod.GET)
public String addEditItem(Model model, Principal principal, #PathVariable("id") String id) {
model.addAttribute("id", id);
model.addAttribute("item", new Item());
if (Integer.parseInt(id) != 0) {
model.addAttribute("edit", true);
} else {
model.addAttribute("edit", false);
}
System.out.println(model.toString());
return "item";
}
which determines if it is an add/ edit call and accordingly sets the value of booleanedit.
Below given is my item.jsp page.
<%# page language="java" contentType="text/html; charset=ISO-8859-1"
pageEncoding="ISO-8859-1"%>
<%# taglib prefix="sf" uri="http://www.springframework.org/tags/form"%>
<%# taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<script type="text/javascript">
var itemurl = "";
function onDelete(event) {
var doDelete = confirm("Are you sure you want to delete this offer?");
if (doDelete == false) {
event.preventDefault();
}
}
function onReady() {
$("#delete").click(onDelete);
}
$(document).ready(onReady);
function updateItemDetails(item) {
$("#itemName").val(item.itemName);
$("#taxPercentage").val(item.taxPercentage);
$("#price").val(item.price);
$("#count").val(item.count);
}
function updatePage(itemurl) {
$.getJSON("<c:url value='${itemurl}'/>", updateItemDetails);
}
</script>
<c:if test="${edit}">
<c:set var="itemurl" value="/getitem/${id}"></c:set>
<c:out value="${itemurl}" />
<script type="text/javascript">
updatePage(itemurl);
</script>
</c:if>
<sf:form method="put"
action="${pageContext.request.contextPath}/saveitem" commandName="item">
<sf:input type="hidden" name="itemId" path="itemId" />
<table class="formtable">
<tr>
<td class="label">Item Name :</td>
<td><sf:input class="control" path="itemName" name="itemName"
id="itemName" type="text" />
<div class="error">
<sf:errors path="itemName"></sf:errors>
</div></td>
</tr>
<tr>
<td class="label">Tax Percentage :</td>
<td><sf:input class="control" path="taxPercentage"
name="taxPercentage" id="taxPercentage" type="text" />
<div class="error">
<sf:errors path="taxPercentage"></sf:errors>
</div></td>
</tr>
<tr>
<td class="label">Price :</td>
<td><sf:input class="control" path="price" name="price"
id="price" type="text" />
<div class="error">
<sf:errors path="price"></sf:errors>
</div></td>
</tr>
<tr>
<td class="label">Count :</td>
<td><sf:input class="control" path="count" name="count"
id="count" type="text" />
<div class="error">
<sf:errors path="count"></sf:errors>
</div></td>
</tr>
<tr align="center">
<td colspan="2"><input class="control" value="Save offer"
type="submit" /> <c:if test="${item.itemId != 0}">
<input name="delete" class="control" value="Remove offer"
type="submit" id="delete" />
</c:if></td>
</tr>
</table>
</sf:form>
Above the form I have added a <c:out> to see what url is being formed.
The rest method being used is,
#RequestMapping(value = "/getitem/{id}", method = RequestMethod.GET, produces="application/json")
#ResponseBody
public Item getItem(#PathVariable("id") String id) {
Item item = itemsService.getItem(Integer.parseInt(id));
return item;
}
The issue is that, if i make a url request with a particular id, in the <c:out value="${itemurl}" /> the correct url is shown, but the form is poulated with item details from the previous url request.
What could be the reason? Could you point out what i'm doing wrong here?

Related

how to set unique name and id of HTML Table columns which are dynamically created using ajax

I am creating one JSP page in which there is a textfield and button. If user enters some integer value lets say 2 in textfield, then 2 rows will be appended in Html table at last. So the rows of HTML table are being created dynamically.
I am implementing this using ajax call to a page which has <tr> data which is to be added to the main table after last row.
Everything is working fine. Rows are created dynamically using ajax call. But the problem is that all rows added to table have same column name attributes.
Below is my code:
main JSP page:
<%# page language="java" contentType="text/html; charset=ISO-8859-1"
pageEncoding="ISO-8859-1"%>
<!DOCTYPE>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Insert title here</title>
<style>
.table {
font-size: 11px;
}
#dailyTableDiv {
height: 70%;
overflow: scroll;
}
</style>
<script>
function addTask(){
var n=$("#dailytsks").val();
for(i=1;i<=n;i++){
$.ajax({url:"employeeSection/dailyTableRow.jsp",success:function(result){
$('#dailyTable tr:last').after(result);
}});
}
//------------------------------
// i am trying this code to set different names for different select box column.
//but this is not happenting.
for(i=1;i<=n;i++){
$("#chSelect").attr("name","chSelect"+i);
}
//------------------------------
}
function add1Row(){
$.ajax({url:"employeeSection/dailyTableRow.jsp",success:function(result){
$('#dailyTable tr:last').after(result);
}});
}
</script>
</head>
<body>
<div class="container-fluid">
<div class="well">
<input type="text" id="dailytsks" name="dailytsks" /><input
type="button" name="addTsks" value="add" onclick="addTask();" /> <span
style="margin-left: 20px;"></span><input type="button" value="+"
id="add1" name="add1" onclick="add1Row();" /> <span
style="margin-left: 20px;"></span><input type="button" value="-"
id="minus" name="minus" />
</div>
</div>
<div class="container-fluid">
<div id="dailyTableDiv">
<table id="dailyTable" class="table table-bordered">
<thead>
<tr>
<th>Select</th>
<th>Date</th>
<th>Client Name</th>
<th>Task-Type</th>
<th>NBPE-Type</th>
<th>Task-Name</th>
<th>Planned-Hrs</th>
<th>Priority</th>
<th>Cross-Team</th>
<th>Current-Status</th>
<th>Is-Completed</th>
<th>Actual-Hrs</th>
<th>SMC-ID</th>
<th>SMC-URL</th>
<th>Comments</th>
</tr>
</thead>
<tbody>
</tbody>
</table>
</div>
</div>
</body>
</html>
dailyTableRow.jsp
<%# page language="java" contentType="text/html; charset=ISO-8859-1"
pageEncoding="ISO-8859-1"%>
<tr>
<!-- -------------------------------------------------------------------- -->
<!-- currently I am trying to set unique name for Select column only so i hv given it a ID -->
<td><input type="checkbox" id="chSelect" name="chSelect" /></td>
<!-- -------------------------------------------------------------------- -->
<td width="3"><input type="text" style="max-width: 80px;"
name="tskDate" /></td>
<td><select name="cliName">
<option>select client</option>
<option>RWS</option>
<option>Orgbase</option>
<option>RW-MAAS</option>
<option>WSO2</option>
</select></td>
<td><input type="checkbox" name="chTskType" />NBPE?</td>
<td><select name="tskNBPEType">
<option>select NBPE type</option>
<option>meeting</option>
<option>on leave</option>
<option>mom</option>
</select></td>
<td><input type="text" name="tskName" /></td>
<td><input type="text" style="max-width: 15px;" name="plndHrs" /></td>
<td><select name="tskPriority">
<option>select priority</option>
<option>low</option>
<option>med</option>
<option>high</option>
</select></td>
<td><input type="text" style="max-width: 80px;"
name="crosTeamMate" /></td>
<td><select name="curStatus">
<option>select status</option>
<option>on hold</option>
<option>in progress</option>
<option>completed</option>
</select></td>
<td><input type="radio" name="isCompleted" value="N">No <br>
<input type="radio" name="isCompleted" value="Y">Yes</td>
<td><input type="text" style="max-width: 15px;" name="actHrs" /></td>
<td><input type="text" style="max-width: 80px;" name="smcID" /></td>
<td><input type="text" style="max-width: 160px;" name="smcURL" /></td>
<td><textarea name="comment" rows="3" cols="10"></textarea></td>
</tr>
here all columns have same name which is wrong.
how can I make unique name attribute pairs for the column in rows which are added. Currently, as seen in the code I am only trying to set unique name attribute values to Select column only. But I am not able to do.
I want something like:
if name of column is "chSelect" then for two rows, it should become as :
chSelect1 & chSelect2, respectively.
This might help you
HTML:-
<input type="checkbox" name="chSelect" class="chSelect" />
<input type="checkbox" name="chSelect" class="chSelect" />
<input type="checkbox" name="chSelect" class="chSelect" />
JAVASCRIPT:-
var i = 0;
$('.chSelect').each(function () {
$(this).attr('name', "chSelect"+i);
i++;
});
LINK :-
https://jsfiddle.net/ft0uefaL/
The basic idea is to store the row number in a global variable that you'll increase each time you add a row via Ajax.
When your Ajax calls resolve, you parse the resulting html (result) using JQuery, change the name property of the chSelect element, and append the change to the last tr as you did previously:
// add a global variable to store row number
var row = 0;
function addTask(){
var n = $("#dailytsks").val();
var max = parseInt(n);
for(i=1; i<=max; i++){
$.ajax({
url: "employeeSection/dailyTableRow.jsp",
success: function(result){
row += 1
var newName = "chSelect" + row;
var html = $('<div>').append(result);
$(html).find("#chSelect").attr("name", newName)
$('#dailyTable tr:last')
.after( html.html() )
}
});
}
}
function add1Row(){
$.ajax({
url: "employeeSection/dailyTableRow.jsp",
success: function(result){
row += 1;
var newName = "chSelect" + row;
var html = $('<div>').append(result);
$(html).find("#chSelect").attr("name", newName)
$('#dailyTable tr:last')
.after( html.html() )
}
});
}

trying to validate my form

i am trying to validate my form which in jsp but it is not happening!!It runs fine but it i not calling the function validatemark which is in my javascript file
here is my code:
<%# page import = "javax.servlet.http.HttpServlet" %>
<%# page language="java" contentType="text/html; charset=ISO-8859-1"
pageEncoding="ISO-8859-1"%>
<%# page import= "org.akash.java.DabManager" %>
<%# page import= "org.akash.java.GetsSets" %>
<%# page import= "java.sql.ResultSet" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<script type="text/javascript" src="ValidateMark.js"></script>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>FILL IN YOUR MARKS HERE</title>
</head>
<body>
<form action="MarksServlet" method="post" name="SubjectMarks" onsubmit="return(validatemark());" >
<table cellpadding="2" width="20%" bgcolor="maroon" align="center"
cellspacing="2">
<tr>
<td colspan=2>
<center><font size=4><b>Subject Marks Form</b></font></center>
</td>
</tr>
<%
String stid= request.getParameter("identity");
%>
</tr>
<tr>
<td>ID</td>
<td><input type="text" name="iden" id="iden" size="10" value= <%=stid %>></td>
</tr>
<tr>
<td>Name</td>
<%
try {
ResultSet resu= null;
DabManager dab= new DabManager();
resu= dab.Getsname(stid);
if(resu.next())
{
String sname= resu.getString("sname");
%>
<td><input type="text" name="yourname" id="yourname" size="30" value=<%=sname %>></td>
<%
}
}catch(Exception e)
{
e.printStackTrace();
}
%>
</tr>
<tr>
<td>Physics</td>
<td><input type="text" name="Physics" id="Physics" size="10"></td>
</tr>
<tr>
<td>Chemistry</td>
<td><input type="text" name="Chemistry" id="Chemistry" size="10"></td>
</tr>
<tr>
<td>Mathematics</td>
<td><input type="text" name="Maths" id="Maths" size="10"></td>
</tr>
<tr>
<td>Biology</td>
<td><input type="text" name="Biology" id="Biology" size="10"></td>
</tr>
<tr>
<td>
<input type="reset">
</td>
<td colspan="2">
<input type="submit" value="Submit Form" onclick ="confirms()"/>
</td>
</tr>
</table>
</form>
</body>
</html>
and here is my javascript code in ValidateMark.js:
function validatemark()
{
if( document.SubjectMarks.iden.value == "" || isNaN( document.SubjectMarks.iden.value))
{
alert( "Please provide a valid id!" );
document.SubjectMarks.iden.focus() ;
return false;
}
if( document.SubjectMarks.yourname.value == "" )
{
alert( "Please provide your Name!" );
document.SubjectMarks.yourname.focus() ;
return false;
}
if( document.SubjectMarks.Physics.value == "" || isNaN(document.SubjectMarks.Physics.value)|| document.SubjectMarks.Physics.value >100)
{
alert( "Please enter valid marks!!" );
document.SubjectMarks.Physics.focus() ;
return false;
}
if( document.SubjectMarks.Chemistry.value == "" || isNaN(document.SubjectMarks.Chemistry.value)|| document.SubjectMarks.Chemistry.value >100)
{
alert( "Please enter valid marks!!" );
document.SubjectMarks.Chemistry.focus() ;
return false;
}
if( document.SubjectMarks.Maths.value == "" || isNaN(document.SubjectMarks.Maths.value)|| document.SubjectMarks.Maths.value >100)
{
alert( "Please enter valid marks!!" );
document.SubjectMarks.Maths.focus() ;
return false;
}
if( document.SubjectMarks.Biology.value == "" || isNaN(document.SubjectMarks.Biology.value)|| document.SubjectMarks.Biology.value >100)
{
alert( "Please enter valid marks!!" );
document.SubjectMarks.Physics.focus() ;
return false;
}
return true;
}
function confirms()
{
if(validatemark()== true)
alert("Marks Entered Successfully");
}
onsubmit="return(validatemark());"
to
onsubmit=" return validatemark();"

Tried Every Thing But Still Getting OBJECT NOT FOUND error in Xamp when i hit submit button?

I was following some tutorials about ecommerce site in PHP and MySQL.
But when i hit submit button I get OBJECT NOT FOUND ERROR.
Below is the code,please guide me. Directories etc. are fine. I've also tried enclosing the button in seprate form tag but nothing worked.
<?php
include("includes/db.php");
?>
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>Add Products</title>
</head>
<body bgcolor="#3B6AD8">
<form method="post" action="insert_product" enctype="multipart/form-data">
<table width="700" height="650" align="center" border="2" bgcolor="#F3F3F3">
<tr>
<td colspan="2">
<h2 align="center">Insert Product Here</h2>
</td>
</tr>
<tr>
<td><b>Product Title</b></td>
<td><input type="text" name="product_title" /></td>
</tr>
<tr>
<td><b>Product Category</b></td>
<td>
<select name="product_cat">
<option>Select a Category</option>
<?php
$get_categories = "SELECT * FROM categories";
$run_categories = mysqli_query($con,$get_categories);
while($row_categories =mysqli_fetch_array($run_categories) ) {
$cat_id = $row_categories['cat_ID'];
$cat_title = $row_categories ['cat_title'];
echo "<option value='$cat_id'>$cat_title</option>";
}
?>
</td>
</select>
<tr>
<td><b>Product Brand</b></td>
<td><select name="product_brand">
<option>Select a Category</option>
<?php
$get_brands = "SELECT * FROM brands";
$run_brands = mysqli_query($con,$get_brands);
while($row_brands =mysqli_fetch_array($run_brands) ) {
$brand_id = $row_brands['brand_ID'];
$brand_title = $row_brands['brand_title'];
echo "<option value='$brand_id'>$brand_title</option>";
}
?>
</td>
</select>
</td>
</tr>
<tr>
<td><b>Product Image 1</b></td>
<td>
<input type="file" name="product_img1" />
</td>
</tr>
<tr>
<td><b>Product Image 2</b></td>
<td>
<input type="file" name="product_img2" />
</td>
</tr>
<tr>
<td><b>Product Image 3</b></td>
<td>
<input type="file" name="product_img3" />
</td>
</tr>
<tr>
<td><b>Product Price</b></td>
<td>
<input type="text" name="product_price" />
</td>
</tr>
<tr>
<td><b>Product Description</b></td>
<td>
<textarea name="product_desc" cols="30" rows="5"></textarea>
</td>
</tr>
<tr>
<td>Product Keywords</td>
<td>
<input type="text" name="product_keywords" />
</td>
</tr>
<tr align="center">
<td colspan="2">
<form method="post">
<input type="submit" name="add_product" value="Add Product"/>
</form>
</td>
</tr>
</table>
</form>
</body>
</html>
<?php
if(isset($_POST['add_product'])){
//text data variables
$product_title = $_POST['product_title'];
$product_cat = $_POST['product_cat'];
$product_brand = $_POST['product_brand'];
$product_price = $_POST['product_price'];
$product_desc = $_POST['product_desc'];
$product_keywords = $_POST['product_keywords'];
$product_status = 'on';
//Produt Images
$product_img1 = $_FILES['product_img1']['name'];
$product_img2 = $_FILES['product_img2']['name'];
$product_img3 = $_FILES['product_img3']['name'];
//Image Temp Names
$temp_name1 = $_FILES['product_img1']['tmp_name'];
$temp_name2 = $_FILES['product_img2']['tmp_name'];
$temp_name3 = $_FILES['product_img3']['tmp_name'];
if($product_title=="" OR $product_cat=="" OR $product_brand=="" OR $product_price=="" OR $product_desc=="" OR $product_keywords=="" OR $product_img1==""){
echo "<script>alert('Please Fill All The Fields')</script>";
exit();
}
else {
move_uploaded_file($temp_name1,"product_images/product_img1");
move_uploaded_file($temp_name2,"product_images/product_img2");
move_uploaded_file($temp_name3,"product_images/product_img3");
$insert_product_query = "INSERT INTO products(category_ID,brand_ID,date,product_title,product_img1,
product_img2,product_img3,product_price,product_desc,product_status)
values ('$product_cat','$brand_id',
NOW,'$product_title','$product_img1','$product_img2','$product_img3','$product_price','$product_desc',
'$product_status')";
$run_products = mysqli_query($con,$insert_product_query);
if ($run_products){
/*echo "<script>alert('Product inserted successfully')</script>";*/
}
}
}
?>
try to put an extension to your form action="insert_product" ... like .php or .asp .. Also, reform your title to something more like "Object not found on form submit."
Try this:
<form method="post" enctype="multipart/form-data">
Ther are two problems:-
The problem is you write form contains only submit button.Try to remove <form method="post">before button
You write all your code in same page but in form your action is insert_product which have no extension like .php.It's totally wrong
so try to do any one of these two.
a) either define it action= insert_product.php and make a file with that name and put your last form processing code in that file.
b) Or remove form action attribute and write like <form method="post" enctype="multipart/form-data">.
Try 1 point and 2 nd b) point at-once. And check once.

Get Value Checkbox Checked in MVC using Ajax Post

can somebody help me..
this is my Code:
Index.cshtml
<!DOCTYPE html>
<html>
<head>
<title>jQuery With Example</title>
#Scripts.Render("~/bundles/jquery")
<script type="text/javascript">
$(function () {
$('.chkview').change(function () {
$(this).closest('tr').find('.chkitem').prop('checked', this.checked);
});
$(".chkitem").change(function () {
var $tr = $(this).closest('tr'), $items = $tr.find('.chkitem');
$tr.find('.chkview').prop('checked', $items.filter(':checked').length == $items.length);
});
});
function Save() {
$.ajax({
url: #Url.Action("Index", "Home" , "Index"),
type: "POST",
data: formData ,
dataType: "json",
success: function(data){
alert(data.RoleID)
},
error: function(e){
debugger;
}
}
</script>
</head>
<body>
<h2>Access Control-Home</h2>
<br />
#using (Html.BeginForm("Index", "Home", FormMethod.Post, new { RoleID="RoleID" }))
{
<input type="hidden" name="RoleID" value="1" id="RoleID" />
<table id="mytable">
<tr>
<td>View</td>
<td>Insert</td>
<td>Update</td>
<td>Delete</td>
</tr>
<tr>
<td>Administrator</td>
<td>
<input type="checkbox" class="chkview chkview-1" />
</td>
<td>
<input type="checkbox" class="chkitem chkitem-1" />
</td>
<td>
<input type="checkbox" class="chkitem chkitem-1" />
</td>
<td>
<input type="checkbox" class="chkitem chkitem-1" />
</td>
</tr>
<tr>
<td>Free User</td>
<td>
<input type="checkbox" class="chkview chkview-2" />
</td>
<td>
<input type="checkbox" class="chkitem chkitem-2" />
</td>
<td>
<input type="checkbox" class="chkitem chkitem-2" />
</td>
<td>
<input type="checkbox" class="chkitem chkitem-2" />
</td>
</tr>
</table>
<br />
<button type="submit" class="buttons buttons-style-1" onclick="Save()">Save</button>
}
</body>
</html>
HomeController.cs
[HttpPost]
public ActionResult Index(string RoleID)
{
var _roleID = RoleID;
return View();
}
i want to ask 2 question.
how i can parsing value of list checked checkbox using ajax? i want parsing classname of checkbox which i checked example i need list of array if i checked row administrator, { 'chkinsert-1','chkupdate-2' }
how i can get value collection of array in controller post?
example:
public ActionResult Index(string RoleID, array[] collChecbox) contents of collChecbox = { 'chkinsert-1','chkupdate-2'} in accordance with the user checked of checkbox input.
can somebody help me??
Why don't you use Ajax.BeginForm() this makes so easy to send posted form value.
Also, you should create proper model first.
MODEL
public class UserRole
{
public Administrator Administrator { get; set; }
public FreeUser FreeUser { get; set; }
}
public class Administrator
{
public int Checkbox1 { get; set; }
}
public class FreeUser
{
public int Checkbox1 { get; set; }
}
Do following in View.
#model Model.UserRole
<div id="result"></div>
#using (Ajax.BeginForm(new AjaxOptions { UpdateTargetId = "result" }))
{
<input type="hidden" name="RoleID" value="1" id="RoleID" />
<table id="mytable">
<tr>
<td>View</td>
<td>Insert</td>
<td>Update</td>
<td>Delete</td>
</tr>
<tr>
<td>Administrator</td>
<td>
#Html.CheckBoxFor(m => m.Administrator.Checkbox1)
</td>
</tr>
<tr>
<td>Free User</td>
<td>
#Html.CheckBoxFor(m => m.FreeUser.Checkbox1)
</td>
</tr>
</table>
<br />
<button type="submit" class="buttons buttons-style-1" onclick="Save()">Save</button>
}
Controller action
[HttpPost]
public ActionResult Index(UserRole model)
{
return View();
}
Also don't forget to include ajax library.
<script src="#Url.Content("~/Scripts/jquery.unobtrusive-ajax.js")" type="text/javascript"></script>

javascript popup concat not working

I using a simple form where I'm validating a user login. Where I want to pass user name in my javascript POPUP for every successful login. For now it is only displaying Hello .I'm using concatination operator but no luck.
this is what my Javascript looks like
<script language="javascript">
function show()
{
var n = document.getElementById("uname").value;
alert("Hello "+n);
return false;
}
function noshow()
{
alert("Invalid Login");
return false;
}
</script>
HTML & Asp code
<form method="post" name="myform">
<table border="0" width="100%" cellpadding="0" cellspacing="0">
<tr>
<td>User Name:</td>
<td><input type="text" name="uname" value="" /></td>
</tr>
<tr>
<td>Password:</td>
<td><input type="password" name="pass" value="" /></td>
</tr>
<tr>
<td colspan="2" align="center">
<input type="submit" value="Login" name="sub" />
<input type="reset" value="Clear" />
</td>
<%
if Request.Form("sub") <> "" then
sql="select * from login_tbl where u_name = '" & Request.Form("uname") & "' AND pass= '" & Request.Form("pass") & "'"
rs.Open sql,con,1,2
if rs.Eof then
Response.Write("<script language='javascript'>noshow();</script>")
else
'Response.Redirect("http://www.google.com")
Response.Write("<script language='javascript'>show();</script>")
end if
rs.Close
end if
%>
</tr>
</table>
</form>
You just need to do something like this:
<td><input type="text" id="uname" name="uname" value="<% Response.Write(Request.Form("uname")) %>" /></td>
After you submit a form, uname became empty, and you need to restore value of uname element on server.
Also, you are using document.getElementById(), but your uname element has no id. So it will find nothing. In order to avoid that, you need to add id to that input (like in my code above).
But in this case uname will show username after form is submitted. If you do not need that, you can do something like this:
<%
if Request.Form("sub") <> "" then
sql="select * from login_tbl where u_name = '" & Request.Form("uname") & "' AND pass= '" & Request.Form("pass") & "'"
rs.Open sql,con,1,2
if rs.Eof then
Response.Write("<script language='javascript'>noshow();</script>")
else
'Response.Redirect("http://www.google.com")
Response.Write("<script language='javascript'>show('" & Request.Form("uname") & "');</script>")
end if
rs.Close
end if
%>
and update your function like this:
function show(n)
{
alert("Hello "+n);
return false;
}

Categories