Link to home
Start Free TrialLog in
Avatar of robrodp
robrodpFlag for Mexico

asked on

Pass asp session variable to a js function in an asp script

I have an asp script (script 1) . A form vaildates the input with js.  If input is ok (as determides by the js validation)  it runs another asp script (script 2)

I need asp script2  to return a result to script 1 and modify the value of the submit value form:

script 2 true

script 2 false

I know that it should be addesed with an ajax approach. Beyond my scope.  Script 2 is ran in a hidden frame mimics ajax. But can set or reset a session variable.

Script 1 form code: (MyIFrame is a hidden frame)
<form name="check" action="participante.asp" method="post" target="MyIFrame">
<input type="text" name="email" id="email" size="30" maxlength="100"><span id="email" style="font-size:8pt; padding: 3px;"></span>
<input type="hidden" value="" name="send">
<input type="button" name="enviado" value="Recuperar Número de Corredor" OnClick="return ValidatePart(this)" >
</form>

Open in new window


Validation code:
function ValidatePart(ccc) {
         	if (!validateEmail(document.check.email.value)) {
	     alert("La dirección de correo electrónico no es valida.");
	     return false;
	         }
	      
        ccc.disabled=true;
        document.check.enviado.value='Email enviado';
		document.check.send.value=ccc.value;
		setTimeout('document.check.submit()',1000);

        return(true)
        
}

Open in new window



participante.asp wil return a session("sent") either true or false if the script was run with or without a problem. Like

scirpt 2 ran ok (true)

script 2 had a problem  (false)

if ran ok then
session("ran")=true
else
session("ran")=false
end if

Open in new window


I need this to se the subit value to ok not ok
Avatar of Ryan Chong
Ryan Chong
Flag of Singapore image

in participante.asp, you should return some javascript in its onload event, so that that javascript can based on the returned results in participante.asp, may modify its parent (the form)'s value.
Avatar of robrodp

ASKER

I get get idea.On paticipante.aspI code <body (onloald  (whaaterver) )

What to  script  (participante.asp whatever)
how to return  (from participante.asp)
how to set it up in my form. (sript 1)

Is beyond my understanding.

Anu help will be valuable and much appreciated
I need asp script2  to return a result to script 1 and modify the value of the submit value form
what kind of element you want to modify here? a field's value, a div, etc?
Avatar of robrodp

ASKER

Script 1 will always return a email sent u¿in the submit vaue even if there was an error.

I want the error in the submit value so users can know where it was successful enogh.

I guess the cdeI snet would be self explanatory
ASKER CERTIFIED SOLUTION
Avatar of Aurelian Constantin
Aurelian Constantin
Flag of Romania image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of robrodp

ASKER

Simple and to the point. Thx for the code it works like a charm