Wrox Programmer Forums
|
Classic ASP Basics For beginner programmers starting with "classic" ASP 3, pre-".NET." 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 Basics 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 March 9th, 2006, 02:12 PM
Authorized User
 
Join Date: Mar 2006
Posts: 13
Thanks: 0
Thanked 0 Times in 0 Posts
Default Greying out dropdown fields in another form

I have a page split up into two forms. Both the forms are method GET. The first form has a text field and a dropdown with a submit button ‘Retrieve SKUs’. While the second form has two dropdown menus and a ‘Create Reports’ button.
The flow of events is such. The user enters a name in the text field, then selects something from the dropdown and clicks on retrieve skus. The user then selects something from the other two dropdown menus in the second form and clicks on ‘Create Reports’.
Problem: When the page first loads, I need to have the two dropdowns in the second form greyed out or disabled. Once the user enters a name and selects something from the dropdown from the first form and then clicks on retrieve SKUs, after the page refreshes the other two dropdowns should then get enabled.
Following is the code:

================================================== ===================
<form name="Report_Drive" action="frm_pop_results.asp" method="GET" onsubmit="return Form1_Validator(this)">
<table border="0" width="600" cellpadding="5" cellspacing="5">
    <tr>
        <td align="left">Enter Report Name</td>
        â€¦â€¦â€¦â€¦â€¦â€¦
    </tr>

//code for dropdown here...

<input type="submit" name="RetrieveSKUs" value="Retrieve SKUs">
    </td>
    </tr>
  </form>

//code for second form follows...

   <form name="Results_Report" action="reports_results_page.asp" method="get">

    <tr>
       <td align="left">Select a Product</td>
        <td><select name="product" size="1" value=product id=product style="top: 30px; left: 393px; width: 200px">
    <OPTION value=0 id=0>Select a Product...
    <% Dim vls_product_name
    â€¦â€¦â€¦â€¦.
        </select>
....

    <td><select name=quarter size="1" id=quarter style="top: 30px; left: 393px; width: 200px">
    <OPTION value=0 id=0>Select a Quarter...
    <% Dim vls_quarter
    strSQL = "SELECT Quarter FROM QUARTER "
    â€¦â€¦â€¦â€¦â€¦â€¦

    </select>
    </td>
</table>
Form Validator functions to give you a better idea…

function Form1_Validator(theForm)
{
    var alertsay = "";

    // check to see if the field is blank
    if (theForm.report_name.value == "")
    {
        alert("You must enter a Report Name.");
        theForm.report_name.focus();
        return (false);
    }

    // check if no drop down has been selected
    if (theForm.drive.selectedIndex < 0)
    {
        alert("Please select one of the following Drive Periods from the list.");
        theForm.drive.focus();
        return (false);
    }

    // check if the first drop down is selected, if so, invalid selection
    if (theForm.drive.selectedIndex == 0)
    {
        alert("Please select one of the following Drive Periods.");
        theForm.drive.focus();
        return (false);
    }

}


function validate(link)
 {

    if(document.Results_Report.product.value == 0) // Check if the Product is null
            {
             alert( "Choose a Product Name.");
             document.Results_Report.product.focus();

             }
    else if(document.Results_Report.quarter.value == 0) // Check if the Quarter is null
            {
             alert( "Choose a Quarter.");
             document.Results_Report.quarter.focus();

             }

    else if (!checkbox_checker())
    {
        alert("Please make atleast ONE SKU selection.")
    }
    else
    {
    submitDrive(link);
    }
 }
================================================== =============


 
Old March 10th, 2006, 04:18 AM
Friend of Wrox
 
Join Date: Nov 2005
Posts: 223
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hi rabbit124,

The problem is not completely clear to me so correct me if I'm wrong.
btw what are Skus

1. the first form has a field for "Name"
2. when you click "retrieve SKUs" it checks if there is something or not.
3. when there is data retrieved the pulldowns should be enabled.
4. (not sure about this one) the pulldowns should have the retrieved values.

What about only refreshing the second form using AJAX.

Need help just ask.

__________________________________________________ ________
This is my junk I'm gona eat it
 
Old March 10th, 2006, 12:37 PM
Authorized User
 
Join Date: Mar 2006
Posts: 13
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hello DJ Kat,

1. Yes, the first form has a field Name AND a dropdown (Drive Period). This form also has Retrieve SKUs submit button (which on clicking checks with JS validator functions if entries have been made in the text field and dropdown menu then runs some results based on those values and displays them in a table below. Then user moves on to the second form-product and qrtr)
2. Yes, when the data is retrieved on clicking retrieve skus, the pulldowns in the second form for product and quarter should be enabled. Initially when the page loads they should be disabled. On clicking the submit button a.k.a Retrieve SKUs, the two pulldowns should be enabled. FYI, SKUs are like a serial number for a particular product item.

Here is what I have so far…
function enableField()
{
document.forms.Results_Report.product.disabled=f alse; document.forms.Results_Report.quarter.disabled=fal se;
}
///////////
<input type="submit" name="RetrieveSKUs" value="Retrieve SKUs" onclick="javascript:enableField()">
////////
<td align="left">Select a Product</td>
        <td><select name="product" size="1" value=product id=product disabled=”true” style="top: 30px; left: 393px; width: 200px">
    <OPTION value=0 id=0>Select a Product...
///////

3&4: Now the problem here is, when the page first loads, the product and quarter fields (from the second form) are disabled, on entering report name, selecting from Drive Period dropdown and clicking on retrieve skus submit button, the page refreshes, the dropdowns get enabled for a split second and then gets disabled again. My problem is how do I get the second form to enable its dropdowns when the submit button in the first form has been clicked (ofcourse they will be disabled initially)
Hope you can understand the problem.
 
Old March 12th, 2006, 07:35 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

I believe disabled=”true” is incorrect syntax all the is required is the word disabled inside your select tag. I recognize your post to do with a previous problem, I still got a bit lost understanding it.

If you want to diable a select list simply place a condition around it. the same as you did in the last post.

EG:
 <select name="product" size="1" value=product id=product style="top: 30px; left: 393px; width: 200px" <% if trim(request.querystring("valueName")) <> "" then response.write " disabled " end if %>>

BTW why do you place quotes around some values and not others? I notice you still use in-line styles. Are you aware of how useful and time saving CSS is?

Wind is your friend
Matt





Similar Threads
Thread Thread Starter Forum Replies Last Post
2 table fields into 1 dropdown selectbox sdagger Classic ASP Basics 2 September 23rd, 2008 03:42 PM
Form Fields Terry J Daichendt JSP Basics 2 September 15th, 2008 05:53 PM
copy fields from Form to new form - openargs justabeginner Access VBA 1 February 4th, 2007 01:28 PM
Dropdown List search form [?] antonioluis Dreamweaver (all versions) 1 May 25th, 2005 01:10 AM
Question Re: DropDown box in Windows Form savoym C# 5 March 15th, 2004 09:10 AM





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