i want to write value in different textfield (rhodes and java) - javascript

i'm using rhostudio to create a mobile app. currently i do have this kind of codes
<div data-role="page">
<script type="text/javascript">
function call(harga,nama){
var quantity=prompt("Insert Quantity");
var pri=harga;
var nam="document.form1."+nama;
alert("unit price RM" + pri+".00");
price= quantity * pri;
alert(quantity);
alert("total price RM" + price+".00");
alert("total price RM" + price+".00" + " should be displayed into " + nam +" textfield");
document.form1."name".value = quantity;
nam.value = quantity;
document.form1."name".value = "RM " + price;
// document.form1.hidden3.value = nam;
}
</script>
<div data-role="header" data-position="inline">
<h1>Displays</h1>
<a href="<%= Rho::RhoConfig.start_path %>" class="ui-btn-left" data-icon="home" data-direction="reverse" <%= "data-ajax='false'" if is_bb6 %>>
Home
</a>
<a href="<%= url_for :action => :new %>" class="ui-btn-right" data-icon="plus">
New
</a>
</div>
<div data-role="content">
<form name="form1">
<table>
<tr align="center">
<td>Product</td>
<td>Quantity</td>
<td>Total Price</td></tr>
<% #products.each do |product| %>
<tr align="center">
<td><%= product.name %></td>
<td><input type="text" name="<%= product.name %>" value="textfield <%= product.name %>"></td>
<td><input type="text" name="<%= product.price %>" value="textfield <%= product.price %>"></td>
</tr>
<% end %>
</table>
<br/>
<br/>
<% #products.each do |product| %>
<input type="hidden" value="price :<%= product.price %>" name="harga"/>
<input type="button" onclick="call(<%= product.price%>,value);" name="Press" value="<%= product.name %>">
<% end %>
</form>
</div>
</div>
i called a function call once i pressed a button.each textfield have different name and value.same goes to the value of the button and value as parameter for function call. it suppost to write the result calculated in the call() function into the specific textfield. unfortunately, it does not! help me..
each text field has different name and it based on object created. since i have created many textfilelds based on the amount of object, is suppose to have different name and write the result into that textfield as well.unfortunately, it does not! help me..

You have lots of error through out the code man. Don't know what are you trying to achieve.
If you just want to pass the values of product.price and product.name to the call function, try this
<input type="button" onclick="call('<%= product.price %>','<%= product.price %>');" value="Press" />
Then on the function like below,
function call(harga,nama){
var quantity=prompt("Insert Quantity");
quantity = isNaN(parseFloat(quantity)) ? 0 : parseFloat(quantity);
var pri = isNaN(parseFloat(harga)) ? 0 : parseFloat(harga);
alert("unit price RM" + pri);
var price= quantity * pri;
alert("total price : " + price);
// specify your rest code over here
}
Hope this helps you.

Related

Item(s) are added into cart, but the total is not updating as per the item(s) added. If I increment/decrement the quantity the total is being updated

I have been working on a nodeJs | Express | MySQL - Ecommerce website with connection to MySQL. In the project, I have developed the code to add the product into the cart by redirecting the user into the "cart.ejs" page. But if one product is added the subtotal is being updated instantly but the grand total is displaying "0". If i increase the product quantity or decrease the product quantity then the loop is being executed and the grand total is being displayed. Please check the code and provide me with some help in this situation. Thanks in advance.
In the below images, the calculateTotal is the function which should calculate the totals for the products added into the cart page. Currently this is only executing if I do some modifications in the page such as increasing the product quantity. But this should be executed immediately when the product is added into the cart, that is how an e-commerce website works right?
In the screenshot of the browser window, you can see the subtotal is being displayed at the same instance when the product is added into the cart, but the total is still being "0".
This is my HTML Code::
<section id="cart">
Proceed to Checkout
You have succesfully placed your item(s) into the cart, Please verify the products you want before heading over to the checkout page.
#
Product
Description
Quantity
Sub Total
<% cart.forEach(function(item) { %>
<tr>
<th>PAC</th>
<td>
<div class="product_info">
<img src="images/products/<%= item.image %>" style="height: 100px; width:100px">
<td><p style="font-weight: bold;"><%= item.name %></p>
<!-- To display the sale price -->
<% if(item.sale_price) { %>
<small>£<span style="color: red; font-weight: bold; text-align: center;"><%= item.sale_price %></span></small>
<% } else { %>
<small>£<span style="color: red; font-weight: bold;"><%= item.price %></span></small>
<% } %>
<br/><br/>
<form method="post" action="/remove_product">
<input type="hidden" name="id" value="<%= item.id %>">
<input type="submit" name="remove_btn" class="btn btn-outline-danger btn-sm" value="Delete">
</form>
</div>
</td>
</td>
<td>
<form method="post" action="/edit_product_quantity">
<input type="hidden" value="<%= item.id %>" name="id">
<input type="submit" value="-" class="edit-btn text-center" name="decrease_product_quantity">
<input type="text" name="quantity" value="<%= item.quantity %>" style="width: 50px; text-align: center;" readonly>
<input type="submit" value="+" class="edit-btn text-center" name="increase_product_quantity">
</form>
</td>
<td>
<!-- To display the subtotal in the table if the item has sale_price (or) without the sale_price -->
<% if(item.sale_price) { %>
<p>£<span class="product-price" style="color: red; font-weight: bold;"><%= item.sale_price * item.quantity %></span></p>
<% } else { %>
<p>£<span class="product-price" style="color: red; font-weight: bold;"><%= item.price * item.quantity %></span></p>
<% } %>
</td>
</tr>
<% }) %>
</table><br/>
Total
£
(incl. of all taxes)
Go to Homepage
Proceed to Checkout
This is my calculateTotal function in app.js code ::
function calculateTotal(cart,req){
total = 0;
for (let i=0; i<cart.length; i++) {
//If we are offering a discounted price so we need to use the sale_price
if (cart[i].sale_price){
total = total + (cart[i].sale_price * cart[i].quantity);
} else {
total = total + (cart[i].price * cart[i].quantity)
}
}
req.session.total = total;
return total;
}
This is my addToCart function:
app.post("/add_to_cart", function(req,res){
let id = req.body.id;
let name = req.body.name;
let price = req.body.price;
let sale_price = req.body.sale_price;
let quantity = req.body.quantity;
let image = req.body.image;
let product = {id:id, name:name, price:price, sale_price:sale_price, quantity:quantity, image:image};
if (req.session.cart){
let cart = req.session.cart;
if(!isProductInCart(cart,id)){
cart.push(product);
}
} else {
req.session.cart = [product];
let cart = req.session.cart;
}
This is the liveserver in vs code in the browser
Please do help! Thanks

How to get variable passed from input box to another page [closed]

Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 5 years ago.
Improve this question
I am trying to get a variable from hidden INPUT text box to another page. I created a search.asp page, when I search a Form from this page, clicked search button, then view.asp page will open with that specific Form ID. On View.asp page, I created a link to open a new page called view2.asp that keeps the same Form ID. But it didn't work. Can you please help? Thanks.
view.asp code
<%#LANGUAGE="VBSCRIPT" CODEPAGE="1252"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>Menus Search</title>
</head>
<body>
<style>
table, td, th {
border: 1px solid #ddd;
}
th, td {
padding: 3px;
}
</style>
</head>
<body>
<!--#include file="openConn.asp" -->
<%
SET objRS = Server.CreateObject("ADODB.Recordset")
SET objRS1 = Server.CreateObject("ADODB.Recordset")
SET objRS2 = Server.CreateObject("ADODB.Recordset")
SET objRS3 = Server.CreateObject("ADODB.Recordset")
If Request.Form("FormSource") = "SubmitForm" Then
For j = 1 to Request.Form("txtCount")-1
strReport = Request.Form("Report[" & j &"]")
strValue = split(strReport,"$")
sMenuID = strValue(0)
sCategoryID = strValue(1)
sStatus = strValue(2)
'response.write strReport & "::" & sMenuID & "::" & sCategoryID & "::" & sStatus & "<br>"
'response.end
sFormID = Request.Form("FormID")
sSQL = "INSERT INTO Report (FormID, MenuID, CategoryID, Status) VALUES " &_
"('" & sFormID & "', '" & sMenuID & "', '" & sCategoryID & "', '" & sStatus & "');"
objConn.Execute(sSQL)
Next
End If
%>
<form action="" method="post" id="newMenu" name="frmReport" onsubmit="return validateForm(this)">
<p>
<%
'''' RR added today
nFormID= Request("FormID") ''Request.Form("SearchObj")
response.write "FormID: " & nFormID & "<br>"
sSQL2 = "SELECT * FROM Form WHERE Formid = " & nFormID
''response.write "SQL:::: " & sSQL2 & "<br>"
objRS2.Open sSQL2, objConn
'response.Write sSQL2
Do Until objRS2.EOF
sFormName = objRS2("Form_Name")
%>
<h2><%= objRS2("Form_Name") %></h2>
<p><a href="#" onclick="openview2.asp();"/>Click me</a></p>
<input type="hidden" id="idFormName" name="FormID" size="40" maxlength="50" value="<%= objRS2("FormID") %>"><br />
<%
objRS2.MoveNext
Loop
objRS2.Close
%>
<p>
<table>
<thead bgcolor="#336666" style="color:#FFFFFF">
<tr>
<td>Trainer Name:</td>
<td>Pass</td>
<td>Fail</td>
<td>NA</td>
<td>Not taken</td>
</tr>
</thead>
<%
currMenu = ""
sSQL = "SELECT MenuID, Menu_Name FROM Menu where MENUID in (SELECT MENUID FROM Category where formid=" & nFormID & ")"
objRS.Open sSQL, objConn
i=1
While Not objRS.EOF
nMenuID = objRS("MenuID")
sMenuName = objRS("Menu_Name")
If currMenu <> sMenuName Then
currMenu = sMenuName
%>
<tr>
<th bgcolor="#CCCCCC"><%= sMenuName %></th>
</tr>
<input type="hidden" name="MenuID" value="<%=nMenuID%>">
<%
End If
sSQL3 = "SELECT Categoryid, Category_Name FROM Category WHERE MenuID = " & nMenuID & " and FormID=" & nFormID
Set objRS3 = Server.CreateObject("ADODB.Recordset")
objRS3.Open sSQL3, objConn
While Not objRS3.EOF
nCategoryID = objRS3("Categoryid")
sCategoryName = objRS3("Category_Name")
%>
<tr>
<td><%= sCategoryName %></td>
<input type="hidden" name="CategoryID" value="<%=nCategoryID%>">
<td align="center"><input type="radio" id ="Report<%=i%>" name="Report[<%=i%>]" value="<%=nMenuID%>$<%=nCategoryID%>$1"></td>
<td align="center"><input type="radio" id ="Report<%=i%>" name="Report[<%=i%>]" value="<%=nMenuID%>$<%=nCategoryID%>$2"></td>
<td align="center"><input type="radio" id ="Report<%=i%>" name="Report[<%=i%>]" value="<%=nMenuID%>$<%=nCategoryID%>$3"></td>
<td align="center"><input type="radio" id ="Report<%=i%>" name="Report[<%=i%>]" value="<%=nMenuID%>$<%=nCategoryID%>$4"></td>
</tr>
<%
objRS3.MoveNext
i = i + 1
Wend
objRS3.Close
objRS.MoveNext
Wend
objRS.Close
%>
</table>
</p>
<p>
<input type="hidden" name="txtCount" value="<%= i %>">
<input type="button" value="Create Menu" onclick="openwin();" />
<input type="hidden" name="FormSource" value="SubmitForm">
<input type="button" value="View2" onclick="openview2();" />
<input type="submit" value="Update">
Go To Search
</p>
</form>
</div>
<script src="https://code.jquery.com/jquery-3.2.1.min.js" type="text/javascript" ></script>
<script type="text/javascript">
function validateForm(daForm) {
nCount = document.frmReport.txtCount.value;
// check all rb radio buttons
for (var i = 1; i < nCount; i++) {
if (! getCheckedRadioValue(daForm["Report"+i])) {
alert ("Please select a value for option " + i)
return false
}
}
// add other checks here...
return true
}
function getCheckedRadioValue(radio) {
for (var i=0; i < radio.length; i++) {
if (radio[i].checked) return radio[i].value
}
return false
}
function openwin()
{
//alert($('#idFormName').val());
//window.location.href = "Create.asp?FormID=" + $('#idFormName').val();
window.open("Create.asp?FormID=" + $('#idFormName').val(), "Create New Menu", "menubar=0,width=700,height=450");
}
function openView2()
{
alert($('#idFormName').val());
window.open("view2.asp?FormID=" + $('#idFormName').val(), "Create New Menu", "menubar=0,width=700,height=450");
}
</script>
</body>
</html>
view2.asp
<%#LANGUAGE="VBSCRIPT" CODEPAGE="1252"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>Menus Search</title>
</head>
<body>
<style>
table, td, th {
border: 1px solid #ddd;
}
th, td {
padding: 3px;
}
</style>
</head>
<body>
<!--#include file="openConn.asp" -->
<%
SET objRS = Server.CreateObject("ADODB.Recordset")
SET objRS1 = Server.CreateObject("ADODB.Recordset")
SET objRS2 = Server.CreateObject("ADODB.Recordset")
SET objRS3 = Server.CreateObject("ADODB.Recordset")
If Request("FormID")="" then
iFormID =0
Else
iFormID = Request("FormID") ''Request.Form("FormID")
End If
If Request.Form("FormSource") = "SubmitForm" Then
For j = 1 to Request.Form("txtCount")-1
strReport = Request.Form("Report[" & j &"]")
strValue = split(strReport,"$")
sMenuID = strValue(0)
sCategoryID = strValue(1)
sStatus = strValue(2)
'response.write strReport & "::" & sMenuID & "::" & sCategoryID & "::" & sStatus & "<br>"
'response.end
sFormID = Request.Form("FormID")
sSQL = "INSERT INTO Report (FormID, MenuID, CategoryID, Status) VALUES " &_
"('" & sFormID & "', '" & sMenuID & "', '" & sCategoryID & "', '" & sStatus & "');"
objConn.Execute(sSQL)
Next
End If
%>
<form action="" method="post" id="newMenu" name="frmReport" onsubmit="return validateForm(this)">
<p>
<%
'''' RR added today
nFormID= Request("FormID") ''Request.Form("SearchObj")
response.write "FormID: " & nFormID & "<br>"
sSQL2 = "SELECT * FROM Form WHERE Formid = " & nFormID
''response.write "SQL:::: " & sSQL2 & "<br>"
objRS2.Open sSQL2, objConn
'response.Write sSQL2
Do Until objRS2.EOF
sFormName = objRS2("Form_Name")
%>
<h2><%= objRS2("Form_Name") %></h2>
<input type="hidden" id="idFormName" name="FormID" size="40" maxlength="50" value="<%= objRS2("FormID") %>"><br />
<%
objRS2.MoveNext
Loop
objRS2.Close
%>
<p>
<table>
<thead bgcolor="#336666" style="color:#FFFFFF">
<tr>
<td>Trainer Name:</td>
<td>Pass</td>
<td>Fail</td>
<td>NA</td>
<td>Not taken</td>
</tr>
</thead>
<%
currMenu = ""
sSQL = "SELECT MenuID, Menu_Name FROM Menu where MENUID in (SELECT MENUID FROM Category where formid=" & nFormID & ")"
objRS.Open sSQL, objConn
i=1
While Not objRS.EOF
nMenuID = objRS("MenuID")
sMenuName = objRS("Menu_Name")
If currMenu <> sMenuName Then
currMenu = sMenuName
%>
<tr>
<th bgcolor="#CCCCCC"><%= sMenuName %></th>
</tr>
<input type="hidden" name="MenuID" value="<%=nMenuID%>">
<%
End If
sSQL3 = "SELECT Categoryid, Category_Name FROM Category WHERE MenuID = " & nMenuID & " and FormID=" & nFormID
Set objRS3 = Server.CreateObject("ADODB.Recordset")
objRS3.Open sSQL3, objConn
While Not objRS3.EOF
nCategoryID = objRS3("Categoryid")
sCategoryName = objRS3("Category_Name")
%>
<tr>
<td><%= sCategoryName %></td>
<input type="hidden" name="CategoryID" value="<%=nCategoryID%>">
<td align="center"><input type="radio" id ="Report<%=i%>" name="Report[<%=i%>]" value="<%=nMenuID%>$<%=nCategoryID%>$1"></td>
<td align="center"><input type="radio" id ="Report<%=i%>" name="Report[<%=i%>]" value="<%=nMenuID%>$<%=nCategoryID%>$2"></td>
<td align="center"><input type="radio" id ="Report<%=i%>" name="Report[<%=i%>]" value="<%=nMenuID%>$<%=nCategoryID%>$3"></td>
<td align="center"><input type="radio" id ="Report<%=i%>" name="Report[<%=i%>]" value="<%=nMenuID%>$<%=nCategoryID%>$4"></td>
</tr>
<%
objRS3.MoveNext
i = i + 1
Wend
objRS3.Close
objRS.MoveNext
Wend
objRS.Close
%>
</table>
</p>
<p>
<input type="hidden" name="txtCount" value="<%= i %>">
<input type="button" value="Create Menu" onclick="openwin();" />
<input type="hidden" name="FormSource" value="SubmitForm">
<input type="submit" value="Update">
Go To Search
</p>
</form>
</div>
<script src="https://code.jquery.com/jquery-3.2.1.min.js" type="text/javascript" ></script>
<script type="text/javascript">
function validateForm(daForm) {
nCount = document.frmReport.txtCount.value;
// check all rb radio buttons
for (var i = 1; i < nCount; i++) {
if (! getCheckedRadioValue(daForm["Report"+i])) {
alert ("Please select a value for option " + i)
return false
}
}
// add other checks here...
return true
}
function getCheckedRadioValue(radio) {
for (var i=0; i < radio.length; i++) {
if (radio[i].checked) return radio[i].value
}
return false
}
</script>
</body>
</html>
It's hard to understand what you are trying to do.
But as I could understand, you want to open view2.asp and be able to have a value from view.asp there.
As I can see you open view2.asp with this line
<input type="button" value="View2" onclick="openview2();" />
And you want this hidden input
<input type="hidden" id="idFormName" name="FormID" size="40" maxlength="50" value="<%= objRS2('FormID') %>">
If this is what you are trying to do. Then your naming is wrong with the javascript. You probably copied and forgot to change name.
See here, where you try to open view2.asp
function openwin()
{
window.openView2("view2.asp?FormID=" + $('#idFormName').val(), "Create New Menu", "menubar=0,width=700,height=450");
}
You need to change openwin() to openview2()
EDIT:
I just also saw you have this strange code
<a href="#" onclick="openview2.asp();"/>Click me</a>
Which is a link to it self, because you have href="#". But you also trying to call a javascript function with this onclick="openview2.asp();".
You do not have a function called openview2.asp(). And this is not how it works.
If you are trying to call view2.asp with this link and pass the hidden input idFormName. Then it's better if you just do a correct link and pass the ID in the url.
I must say it's a very bad solution, because there is no security here. But the code you provided shows that you are only after a function and ignoring any security aspect.
So change this
<h2><%= objRS2("Form_Name") %></h2>
<p><a href="#" onclick="openview2.asp();"/>Click me</a></p>
<input type="hidden" id="idFormName" name="FormID" size="40" maxlength="50" value="<%= objRS2("FormID") %>"><br />
for this
<h2><%= objRS2("Form_Name") %></h2>
<p><a href="view2.asp?idFormName=<%= objRS2("FormID") %>" />Click me</a></p>
<input type="hidden" id="idFormName" name="FormID" value="<%= objRS2("FormID") %>"><br />
I'm leaving the hidden there in case you refer to this somewhere else in your code.
Good luck and Have a nice day!

Rails - Table <TR> - Add filter with a button / Jquery

I would like to implement a filter on my table by clicking on a button
I got a table here :
<div class="table-container">
<table class="table table-filter">
<tbody>
<% if current_user %>
<% #book.each do |book| %>
<tr data-status = "###">
<!-- I would like to implement <%= book.style %> inside that data-status, to filter on the type of books -->
<td><%= book.name %></td>
<td> <%= book.author %></td>
</tr>
</tbody>
<% end %>
<% end %>
</table>
</div>
And a Script to filter when i click on the button
<button type="button" class="btn btn-success btn-filter" data-target="novel">PC</button>
Here is the script :
<script>
$(document).ready(function () {
$('.btn-filter').on('click', function () {
var $target = $(this).data('target');
if ($target != 'all') {
$('.table tr').css('display', 'none');
$('.table tr[data-status="' + $target + '"]').fadeIn('slow');
} else {
$('.table tr').css('display', 'none').fadeIn('slow');
}
});
});
</script>
I dont know how to pass the value of the book type , inside the Data-status = <% book.style %> and even when i put a text value , like Novel , it doesnt filter on the table.
I dont really know where am I wrong and im looking for help on this. Do I need to use a content_tag ?
you can simply:
<tr data-status = "<%= book.style %>">

Search records from database and adding them to list

i am a beginner developr in ruby on rails.
What i want to do is:
to create an input search to search products.
Then, i click a submit button, this product will be dispalyed in a list below.
I search another product and it will be added to my list.
Finally, i will have a list of searched products.
<script type="text/javascript">
var foodList = [];
function addToFood () {
var addFood = document.getElementById('addFood').value;
var addQuantity = document.getElementById('addFood').value;
foodList.push(addFood + " " + addQuantity );
for (i = 0; i < foodList.length; i++) {
var newFood = "<a href='#' onClick='removeRecord(" + i + ");'>X</a> " + foodList[i] + " <br>";
};
document.getElementById('foods').innerHTML += newFood;
document.getElementById('addQuantity').value = '';
document.getElementById('addFood').value = '';
}
function removeRecord (i) {
foodList.splice(i, 1);
var newFood = "";
// re-display the records from foodList the same way we did it in addToFood()
for (var i = 0; i < foodList.length; i++) {
newFood += "<a href='#' onClick='removeRecord(" + i + ");'>X</a> " + foodList[i] + " <br>";
};
document.getElementById('foods').innerHTML = newFood;
}
</script>
<%= form_tag akala_health_path, :method => 'get', :id => "products_search" do %>
<p>
Product name
<%= text_field_tag :search, params[:search] , :id => "addFood"%></br>
<%= submit_tag "Search", :name => nil %>
</p>
<% end %>
<table id="products">
<tr>
<th>Product name</th>
<th>Product code</th>
<th>Product quantity</th>
<th></th>
</tr>
<% if #products.count == 0 %>
<% else %>
<% #products.each do |product| %>
<tr>
<td id="addFood"><%= product.product_name %></td>
<td id="addFood"><%= product.product_code %></td>
<td><input type="text" value="" /></br></td>
<td><input type="submit" value="Ajouter" onClick="addToFood();"> </td>
</tr>
<% end %>
<% end %>
</table>
<%= will_paginate #products%>
<!-- The list of food is displayed in the following div -->
<div id="foods"></div>
How can i do this ? Please help me.
You need to make ajax requests to get products from the app server. If you are not familiar with ajax/rails, a good place to start is on rails guides http://guides.rubyonrails.org/working_with_javascript_in_rails.html

Passing multiple parameters from jsp page to javascript function

This may seem like a duplicate. But it isn't.
This is my code:
<script language="JavaScript">
function popupwin(qid)
{
var myWindow = window.open("", "", "width=800, height=600");
myWindow.document.write("<p> Qid = "+qid);
}
</script>
.......
<%
try{
Class.forName("oracle.jdbc.driver.OracleDriver");
con = DriverManager.getConnection("jdbc:oracle:thin:#localhost:1521:xe","system","Shravya17");
ps=con.prepareStatement("select * from questions where category = ?");
ps.setString(1,cat);
rs=ps.executeQuery();
while(rs.next()){
qid = rs.getInt(1);
ques = rs.getString(2);
cat = rs.getString(3);
a = rs.getString(4);
b = rs.getString(5);
c = rs.getString(6);
d = rs.getString(7);
ca = rs.getString(8);
%>
<tr align = "center">
<td> <%= qid %> </td>
<td> <%= ques %> </td>
<td> <%= cat %> </td>
<td> <%= a %> </td>
<td> <%= b %> </td>
<td> <%= c %> </td>
<td> <%= d %> </td>
<td> <%= ca %> </td>
<td>
<input type="submit" value="Edit" onclick=(popupwin(<%=qid%>));/>
</td>
</tr>
<%
}
This works fine.
But how do I pass more than one parameter in the function call?
I tried passing parameters separated by commas but it didn't work.
Please help!
there is no reason it shouldn't work, I suspect you had a syntax error. try the following.
<td>
<input type="submit" value="Edit" onclick="(popupwin(<%=qid%>, 'test'))" />
</td>
function popupwin(qid, testVal) {
console.log(testVal); // you should see 'test' in your browser's console
}

Categories

Resources