Wrox Programmer Forums
|
ASP CDO As of Oct 5, 2005, this forum is now locked. No posts have been deleted. Please use "Classic ASP Professional" at: http://p2p.wrox.com/forum.asp?FORUM_ID=56 for discussions similar to the old ASP Pro Code Clinic or one of the other many remaining ASP and ASP.NET forums here.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP CDO section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old February 21st, 2005, 12:11 AM
Registered User
 
Join Date: Feb 2005
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default Reference ASP Array in Javascript

 This was a question in a previous topic but I didn't quite understand the answer, so here is the question again.

I display radio buttons from an radioArray I built in ASP which contains a code/short desc/long desc. When someone clicks a radio button I want to do invoke a Javascript function to display the short and long desc directly below the list of radio buttons.

1. should I use onClick="return display_desc(this.selectedIndex)"
OR onchange="return display_desc(this.selectedIndex)"

2. How do I get radioArray into a JS array for the JS function?

Any code examples of would be very helpful since I am a novice at JS.

 
Old February 24th, 2005, 10:58 AM
Friend of Wrox
 
Join Date: Oct 2004
Posts: 553
Thanks: 0
Thanked 1 Time in 1 Post
Send a message via MSN to vinod_yadav1919 Send a message via Yahoo to vinod_yadav1919
Default

Hii gaetano!!!
Try this, Hope this will help you

<script>
function checkit(obj,sdesc,cod,ldesc)
{
if(obj.checked==true)
 {
  document.myform.gcod.value=cod
 document.myform.sdesc.value=sdesc
document.myform.ldesc.value=ldesc
 }
else
{
document.myform.gcod.value=" "
 document.myform.sdesc.value=" "
document.myform.ldesc.value=" "
}


}

function checkit1(obj)
{
if(obj.checked==true)
 {
  arr=(obj.value).split("~")

  document.myform.gcod.value=arr[0];
 document.myform.sdesc.value=arr[1];
document.myform.ldesc.value=arr[2];
 }
else
{
document.myform.gcod.value=" "
 document.myform.sdesc.value=" "
document.myform.ldesc.value=" "
}


}
</script>
<form name=myform>
Method1<br>
<input type=radio name=x value=1 onclick="checkit(this,'Description1','code1','Long _Description1')">Item1<br>
<input type=radio name=x value=1 onclick="checkit(this,'Description2','code2','Long _Description2')">Item2<br>
Method2<br>
<input type=radio name=x value='Description1~code1~Long_Description1' onclick="checkit1(this)">Item1<br>
<input type=radio name=x value='Description2~code2~Long_Description2' onclick="checkit1(this)">Item1<br>

Method2<br>

Code<input type=text name="gcod" size=100 maxlength=100 readonly> <br>
ShortDesc<input type=text name="sdesc" size=100 maxlength=100 readonly><br>
LongDesc<input type=text name="ldesc" size=100 maxlength=100 readonly><br>

</form>


You can do this by two ways,it's up to your choice and application requirement.
if u use 1st method then use ASP/JSP code like
<input type=radio name=x value=1 onclick="checkit(this,'<%=desc%>','<%=cod%>','<%=l ong_desc%>')" >
and for 2nd method,here i use "~" for separator
<input type=radio name=x value='<%=desc%>~<%=cod%>~<%=long_desc%>' onclick="checkit1(this)">

Cheers :)

vinod





Similar Threads
Thread Thread Starter Forum Replies Last Post
Javascript reference for download rungss Javascript 3 March 31st, 2006 08:31 AM
ASP/MySql database into JavaScript Array Hazzardusa Classic ASP Databases 1 August 14th, 2005 10:02 PM
Transfer double array from asp to javascript simi Classic ASP Databases 1 May 17th, 2005 06:40 AM
Reference ASP Array in Javascript gaetano Classic ASP Basics 1 February 21st, 2005 10:09 AM
Passing php array values to javascript array gkrishna Pro PHP 0 November 6th, 2004 03:20 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.