...

View Full Version : <script> tags inside onClick



crmpicco
07-11-2005, 01:52 PM
onclick="<script language='javascript'>bAdult=true</script>javascript: confirmedok();"


Is this valid? I want to set a variable value for the function confirmedok to work with?

vwphillips
07-11-2005, 01:55 PM
onclick="bAdult=true;confirmedok();"

is correct

crmpicco
07-11-2005, 02:20 PM
I have this ASP/JavaScript code.

How do i pass the value of 'adult' to the JavaScript which is client-side and ABOVE this ASP?

This is what i have so far.....




<script language="javascript>

function confirmedok()
{
adult = "<%=adult%>"
alert("adult = " + adult);

... more code......

}
</script>

<%
'... if there are NO CHILDREN AND NO INFANTS
if noc = 0 and noi = 0 then
response.write "ADULTS"
adult="yes"
response.write "adult = " & adult & "<br>"
%>

<img src="images/confirm.gif" onclick="javascript: confirmedok();"
onMouseOver='style.cursor="hand"' value="Confirm">&nbsp;&nbsp;
<% end if %>


Not sure if this is in the correct forum

:-(

glenngv
07-11-2005, 02:52 PM
Is this what you want?


function confirmedok(adult)
{
alert("adult = " + adult);
...
}
...
onclick="confirmedok('<%=adult%>');"

But if there will only be one instance calling the confirmedok() function, then you don't need the parameter and just like what you did, embed the asp variable directly inside the javascript function.

function confirmedok()
{
var adult = "<%=adult%>";
alert("adult = " + adult);
...
}
...
onclick="confirmedok();"

crmpicco
07-11-2005, 03:44 PM
This solved the problem for those ineterested.......



// WHEN THERE IS JUST AN ADULT TRAVELLING
function adt()
{
adult = "yes"
}



function confirmedok()
{

if(adult=="yes")
{
document.form.TK.value=document.form.TK.value;
check(document.form);
}

if(adult!="yes")
{

..... run some code .....

}


}

... onClick="javascript: adt(); confirmedok();" ....

glenngv
07-12-2005, 03:05 AM
Why not simply this?

function confirmedok(isAdult)
{
if(isAdult)
{
'..... run some code .....
}
else
{
'..... run some code .....
}
}
...
onClick="confirmedok(true);"



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum