Wrox Programmer Forums
|
Classic ASP Professional For advanced coder questions in ASP 3. NOT for ASP.NET 1.0, 1.1, or 2.0.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Classic ASP Professional 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 December 9th, 2006, 06:23 PM
Authorized User
 
Join Date: Oct 2006
Posts: 13
Thanks: 0
Thanked 0 Times in 0 Posts
Default Need help…any suggestions

Hello,
Here is the code:
<tr>
<tr>
<td class="FormCell">Do you live in US? </td>
<td class="FormCell"><input type="radio" value="true" name="Country">Yes</td>
<td class="FormCell"><input type="radio" value="false" checked name="Country">No</td>
</tr>

    <% if true then %>
        <td class="FormCell"> This is a test </td>
<td class="FormCell" colspan="2"><select name="TEST">
        <option selected value="1">0 to 2500</option>
                  <option value="2">2,501 to 5,000</option>
                  <option value="3">5,001 to 8,000</option>
                  <option value="4">8,001 to 20,000</option>
                 <option value="5">over 20,000</option>
                  </select></td>
            <% end if %>
</tr>

What I want is that when the page loads the No (Radio Button) is selected (that is by default) and than if the user select the Yes radio button than the dropdown list shows up (TEST).
I guess there r two ways to do that:
• Using DHTML (java script)
• Or some how using the post back function
I will really appreciate yr help. It’s kind of urgent.
Thanks a lot for yr time & effort.
Ricky



 
Old December 10th, 2006, 06:31 PM
Friend of Wrox
 
Join Date: Jan 2004
Posts: 1,870
Thanks: 12
Thanked 20 Times in 20 Posts
Send a message via AIM to mat41
Default

try:

<html>
<head>
    <title>Untitled</title>
<script>
  function hide( control, division ) {
   controlChecked = true;
   var mystate = document.all["_state"];
   if ( control.type == "radio" &&
                control.value.substring(0,2) == "No" )
       controlChecked = false;
      if ( control.checked == false )
       controlChecked = false

   if ( controlChecked == true ) {
      document.all[division].style.visibility = "visible";
      if ( mystate.value.indexOf(division) == -1 )
           mystate.value = mystate.value + division + " ";
  } else {
      document.all[division].style.visibility = "hidden";

      if ( mystate.value.indexOf(division) != -1 ) {
          var ar = mystate.value.split(" "+division+" ");
          if (ar.length > 1 )
              mystate.value = ar.join(" ");
          else
              mystate.value = ar[0];
      }
       var argc = arguments.length;

      for ( g = 2; g < argc; g++ ) {
         var elem = document.all[arguments[g]];

          if ( elem.type == "textarea" || elem.type == "text" ) {
              elem.value = "";
          } else {
              if ( elem.length ) {
                  for ( i = 0; i < elem.length; i++ ) {
                      if ( elem.item(i) ) {
                          elem.item(i).checked = false;
                      }
                  }
              } else {
                  elem.checked = false;
              }
          }
      }
 }
 }

 function init() {
      var mystate = document.all["_state"];
      if ( mystate.value != null && mystate.value != "" ) {
          var ar = mystate.value.split(" ");
          for ( i = 0; i < ar.length; i++ ) {
              if ( document.all[ar[i]] )
                  document.all[ar[i]].style.visibility = "visible";
          }
      }
 }
 </script>

</head>

<body onLoad="init();">
<form name="myform">
 <input type="radio" value="Yes" name="yn" onclick="hide(this,'mydiv','tb1','r1','cb1','ckc') " onclick="hide(this,'mydiv')"><b>Yes</b>
 <input type="radio" value="No" checked onclick="hide(this,'mydiv')" name="yn"><b>No</b>
 <div id="mydiv" class=hidesec>
 <select name="TEST">
  <option selected value="1">0 to 2500</option>
  <option value="2">2,501 to 5,000</option>
  <option value="3">5,001 to 8,000</option>
  <option value="4">8,001 to 20,000</option>
  <option value="5">over 20,000</option>
  </select>
 </div>
<Input Type="Hidden" Name="_state" Value="STATE ">
</body>
</html>

Wind is your friend
Matt





Similar Threads
Thread Thread Starter Forum Replies Last Post
any suggestions? Acar BOOK: ASP.NET 2.0 Website Programming Problem Design Solution ISBN: 978-0-7645-8464-0 1 May 27th, 2008 07:19 AM
All suggestions are welcome! Wooger Other Programming Languages 0 September 24th, 2007 09:47 AM
I Need Some Suggestions??? [email protected] ASP.NET 2.0 Professional 0 November 8th, 2006 02:14 AM
Suggestions lagoonblue Visual C++ 0 June 13th, 2005 07:18 PM
Some suggestions richard.york Forum and Wrox.com Feedback 0 October 13th, 2003 01:45 AM





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