Wrox Programmer Forums
|
ASP Forms As of Oct 5, 2005, this forum is now locked. Please use "Classic ASP beginner" at http://p2p.wrox.com/forum.asp?FORUM_ID=54 or "Classic ASP Professional" http://p2p.wrox.com/forum.asp?FORUM_ID=56 instead.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP Forms 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 August 15th, 2004, 10:49 AM
Registered User
 
Join Date: Aug 2004
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default how is this done

Hi everyone,

I want to have a form where there will be a list of cars in a dropdown box and when a user selects a make all models
related to that make will be inserted in the second dropdown box and I want to do this server side as the forms
using javascript are IE ONLY and I have been told doing it server side it dont matter what browser you use. I hope I have explained myself clearly.using wrox asp 3.0 book, access 2000 database.

Here is IE ONLY example -
http://javascript.internet.com/forms...opulation.html

 
Old August 15th, 2004, 11:27 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 344
Thanks: 0
Thanked 1 Time in 1 Post
Default

You can do it client side in non-IE browsers - see http://www.greggriffiths.org/webdev/...nkeddropdowns/
 
Old August 15th, 2004, 01:37 PM
Registered User
 
Join Date: Aug 2004
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Quote:
quote:Originally posted by Greg Griffiths
 You can do it client side in non-IE browsers - see http://www.greggriffiths.org/webdev/...nkeddropdowns/
Hi Greg Griffiths,

Thanks for the link. Also I have changed your
example to the code below and was wondering If
I used that It would still work in non-IE browsers.


Code:
<html>
<head>
<title></title>

<script language="javascript" type="text/javascript">
// function takes a display NAME and the VALUE for the new element and then adds it to the dropdown specified in the other parameter
function addOption(whichDD,name,value)
{
    // create a reference to the SELECT and the form
    var theDD=eval(whichDD);

    // create the new OPTION
    var newOption;
    newOption= new Option (name,value);

    // position
    var insertAt = theDD.options.length;

    // create the space
    theDD.options.length=theDD.options.length + 1;
      // add the option
    theDD.options[insertAt] = newOption;
}

function populateDD()
{
    // get the value
    var firstDD=document.myForm.first_dropdown.value;

    // reset the dropdown
    document.myForm.second_dropdown.length=0;

    // Populate the second DD
    switch (firstDD)
    {
        case '1':
            addOption('document.myForm.second_dropdown','33');
            addOption('document.myForm.second_dropdown','145');
            addOption('document.myForm.second_dropdown','146');
            addOption('document.myForm.second_dropdown','147');
            addOption('document.myForm.second_dropdown','155');
            addOption('document.myForm.second_dropdown','156');
            addOption('document.myForm.second_dropdown','164');
            addOption('document.myForm.second_dropdown','166');
            addOption('document.myForm.second_dropdown','GTV');
            addOption('document.myForm.second_dropdown','SPIDER');
            addOption('document.myForm.second_dropdown','75');
            break;
        case '2':
            addOption('document.myForm.second_dropdown','ROCSTA');
            break;
        case '3':
            addOption('document.myForm.second_dropdown','DB7');
            addOption('document.myForm.second_dropdown','V8');
            break;
    }
}
</script>
</head>
<body>
<form name="myForm">
<table align="center">
<tr>
<td>
<SELECT NAME="first_dropdown" ONCHANGE="populateDD();">
    <option value="0" SELECTED>Any Make</option>
    <option value="1">ALFA ROMEO</option>
    <option value="2">ASIA</option>
    <option value="3">ASTON MARTIN</option>
</select>
<select name="second_dropdown">
</select>
</form>
</body>
</html>
 
Old August 15th, 2004, 03:38 PM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 344
Thanks: 0
Thanked 1 Time in 1 Post
Default

You could try downloading another browser such as Opera, Mozilla or Firefox - they are all free (although Opera is Shareware, but has an ads version). I've tried your code in Firefox and it works fine.
 
Old August 16th, 2004, 11:48 AM
Registered User
 
Join Date: Aug 2004
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Quote:
quote:Originally posted by Greg Griffiths
 You could try downloading another browser such as Opera, Mozilla or Firefox - they are all free (although Opera is Shareware, but has an ads version). I've tried your code in Firefox and it works fine.
Thanks for all your help.
And I will get another browser

cheers :D










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