Go Back   CodingForums.com > :: Client side development > JavaScript programming

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 07-11-2005, 12:52 PM   PM User | #1
crmpicco
Senior Coder

 
crmpicco's Avatar
 
Join Date: Jan 2005
Location: Mauchline, Scotland
Posts: 1,091
Thanks: 15
Thanked 1 Time in 1 Post
crmpicco has a little shameless behaviour in the past
Question <script> tags inside onClick

Code:
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?
crmpicco is offline   Reply With Quote
Old 07-11-2005, 12:55 PM   PM User | #2
vwphillips
Senior Coder

 
Join Date: Mar 2005
Location: Portsmouth UK
Posts: 4,382
Thanks: 3
Thanked 466 Times in 453 Posts
vwphillips is a jewel in the roughvwphillips is a jewel in the roughvwphillips is a jewel in the rough
onclick="bAdult=true;confirmedok();"

is correct
vwphillips is offline   Reply With Quote
Old 07-11-2005, 01:20 PM   PM User | #3
crmpicco
Senior Coder

 
crmpicco's Avatar
 
Join Date: Jan 2005
Location: Mauchline, Scotland
Posts: 1,091
Thanks: 15
Thanked 1 Time in 1 Post
crmpicco has a little shameless behaviour in the past
Unhappy

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.....

Code:
<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

:-(
crmpicco is offline   Reply With Quote
Old 07-11-2005, 01:52 PM   PM User | #4
glenngv
Supreme Master coder!


 
glenngv's Avatar
 
Join Date: Jun 2002
Location: Los Angeles, CA Original Location: Philippines
Posts: 10,241
Thanks: 0
Thanked 112 Times in 111 Posts
glenngv will become famous soon enough
Is this what you want?

Code:
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.
Code:
function confirmedok()
{
   var adult = "<%=adult%>";
   alert("adult = " + adult);
   ... 
}
...
onclick="confirmedok();"
__________________
Glenn
_____________________________________________
Play Tower of Hanoi Android app (Ad-FREE!)
Play Tower of Hanoi Android app (FREE!)
Go to Tower of Hanoi Leaderboard
Play Tower of Hanoi Facebook app
glenngv is offline   Reply With Quote
Old 07-11-2005, 02:44 PM   PM User | #5
crmpicco
Senior Coder

 
crmpicco's Avatar
 
Join Date: Jan 2005
Location: Mauchline, Scotland
Posts: 1,091
Thanks: 15
Thanked 1 Time in 1 Post
crmpicco has a little shameless behaviour in the past
Thumbs up

This solved the problem for those ineterested.......

Code:
// 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();" ....
crmpicco is offline   Reply With Quote
Old 07-12-2005, 02:05 AM   PM User | #6
glenngv
Supreme Master coder!


 
glenngv's Avatar
 
Join Date: Jun 2002
Location: Los Angeles, CA Original Location: Philippines
Posts: 10,241
Thanks: 0
Thanked 112 Times in 111 Posts
glenngv will become famous soon enough
Why not simply this?
Code:
function confirmedok(isAdult)
{
	if(isAdult)
	{
		'..... run some code .....
	}
	else
	{
		'..... run some code .....
	}
}
...
onClick="confirmedok(true);"
__________________
Glenn
_____________________________________________
Play Tower of Hanoi Android app (Ad-FREE!)
Play Tower of Hanoi Android app (FREE!)
Go to Tower of Hanoi Leaderboard
Play Tower of Hanoi Facebook app
glenngv is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 11:58 AM.


Advertisement
Log in to turn off these ads.