Click to See Complete Forum and Search --> : input type image variables


il_betto
05-14-2009, 05:39 AM
Hi to All,
I have a page called index.asp in which:

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<Script Language="JavaScript">
function notify(n) {
if (n==1) {
var answer = confirm("Would you like to register new values?")
if (answer) {
document.FrontPage_Form.action = "pass.asp "
document.FrontPage_Form.submit();
return true; } }
}
</script>
</head>

<body>
<form method="POST" webbot-onSubmit language="JavaScript" name="FrontPage_Form">
.......
<input type="image" name="pippo" id="pippo" value="pippo" onClick="notify(1)" src="images/plus.png" >
......
<input type="image" name="pluto" id="pluto" value="pluto" onClick="notify(1)" src="images/plus.png" >
</form>

When the Client click on tthese 2 images, I want to extract the different values: pippo, pluto and define them as variables in the page pass.asp

Inside pass.asp:

<%@ Language=VBScript %>
<%
Option Explicit
Dim objConn, objRS, sql, var1, var2
'
Set objConn = Server.CreateObject("ADODB.Connection")
objConn.ConnectionString = "DSN=ssd09.dsn"
objConn.Open
Set objRS = Server.CreateObject("ADODB.Recordset")
objRS.Open "t_check", objConn, , 3, 2
'
Do While Not objRS.EOF
'
var1 = Request.Form("pippo")
var2 = Request.Form("pluto")
Response.Write var1 & var2 <---- ARE EMPTY !!! :confused:
'
objConn.Execute(sql)
objRS.MoveNext
Loop
'
objRS.Close
Set objRS = Nothing
objConn.Close
Set objConn = Nothing
%>

Thanks a lot in advance !!!

Kuriyama
05-14-2009, 08:06 AM
For some reason the submit() function in JavaScript is not passing those image inputs. If you really need to do this try hidden fields. I'm not quite sure why you are using JavaScript to submit a form.

il_betto
05-14-2009, 08:23 AM
Thanks,

I ask: if it' s not possible to pass the values in this way, if I modify this function like this:

function notify(n) {
if (n==1) {
var answer = confirm("Would you like to register new values?")
if (answer) {
document.FrontPage_Form.action = "pass.asp "
document.FrontPage_Form.submit();
return pippo; } }
function notify(n) {
else if (n==2) {
var answer = confirm("Would you like to register new values?")
if (answer) {
document.FrontPage_Form.action = "pass.asp "
document.FrontPage_Form.submit();
return pluto; } }
}
</script>
</head>

<body>
<form method="POST" webbot-onSubmit language="JavaScript" name="FrontPage_Form">
.......
<input type="image" name="pippo" id="pippo" value="pippo" onClick="notify(1)" src="images/plus.png" >
......
<input type="image" name="pluto" id="pluto" value="pluto" onClick="notify(2)" src="images/plus.png" >
</form>

You think that in a similar way is possible to transfer the values of pippo and pluto ??

Kuriyama
05-14-2009, 11:38 AM
I think your design is screwed up.

What exactly are you trying to accomplish with this? If nothing else you can overwrite the action of the form and just do something like.

form action="page.asp?value=pitto"
where value=pitto is wrote via JS.

il_betto
05-19-2009, 03:20 AM
Thanks a lot Kuriyama,
I used your idea an I solved the problem in this way:

in the page index.asp :

function notify(n) {
if (n==1) {
var answer = confirm("Would you like to register new values?")
if (answer) {
document.FrontPage_Form.action = "pass.asp?value="+document.getElementById('pippo').value
document.FrontPage_Form.submit();
return true; } }
else if (n==2) {
var answer = confirm("Would you like to register new values?")
if (answer) {
document.FrontPage_Form.action = "pass.asp?value="+document.getElementById('pluto').value
document.FrontPage_Form.submit();
return true; } }
}

in the page pass.asp :

<%@ Language=VBScript %>
<%
Option Explicit
Dim objConn, objRS, rec, sql3, sql4, sql5, value
'
value = Request("value")
Response.Write: "This is the variable value: " & value
'
:):)

yamaharuss
05-19-2009, 06:51 AM
That sure is a terribly clunky way to simply pass a variable to a page with a confirmation onclick.


function verify()
{
var agree=confirm("Would you like to register new values?");
if (agree)
return true ;
else
return false ;
}


<a href="pass.asp?value=pitto"><img onClick="return verify()" src="images/plus.png" ></a>

il_betto
05-19-2009, 08:37 AM
Thank You very much for Your precious help !!! :D :D