Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Question please guys....

Status
Not open for further replies.

coldfused

Technical User
Jan 27, 2001
2,442
US
Ok say there is a form.

Question 1 - "How did you hear of us?"
Drop down list has four items. Say Newspaper, Magazine, Mailer, Friend.

I have seen sites where say if you choose "Magazine", another form field appears beside it with a list of the magazines that it advertises in.

If they choose friend of course no other options would have to be available for them to choose from. And they move on through the form.

How do I accomplish this?

How do I make another field appear depending on what was picked in another?

Thanks in advance.


csatterwhite@orlandomediasolutions.com
 
this is done by using ASP/PHP, what server side language do u use?

Known is handfull, Unknown is worldfull
 
It can also be done via Javascript and DHTML, and it's not terribly complex -- the folks in the Javascript forum should be able to explain how.
 
Here is the code if you guys want it:

var arrayData = new Array();

arrayData[0] = 'Newspaper|Please Select...|'
arrayData[1] = 'Newspaper|Stuart News|'
arrayData[2] = 'Newspaper|Vero Beach Side News|'
arrayData[3] = 'Newspaper|Vero Beach Press Journal|'
arrayData[4] = 'Newspaper|Palm Beach Post|'
arrayData[5] = 'Newspaper|New York Times|'
arrayData[6] = 'Newspaper|Wall Street Journal|'
arrayData[7] = 'Magazine|Please Select...|'
arrayData[8] = 'Magazine|Sub Selection A_cat01|'
arrayData[9] = 'Magazine|Sub Selection A_cat01|'
arrayData[10] = 'Magazine|Sub Selection A_cat01|'
arrayData[11] = 'Magazine|Sub Selection A_cat01|'
arrayData[12] = 'Magazine|Sub Selection A_cat01|'
arrayData[13] = 'Magazine|Sub Selection A_cat01|'
arrayData[14] = 'Magazine|Sub Selection A_cat01|'
arrayData[15] = 'Magazine|Sub Selection A_cat01|'
arrayData[16] = 'Magazine|Sub Selection A_cat01|'
arrayData[17] = 'Magazine|Sub Selection A_cat01|'
arrayData[18] = 'Magazine|Sub Selection A_cat01|'
arrayData[19] = 'Magazine|Sub Selection A_cat01|'
arrayData[20] = 'Magazine|Sub Selection A_cat01|'
arrayData[21] = 'Magazine|Sub Selection A_cat01|'
arrayData[22] = 'Magazine|Sub Selection A_cat01|'
arrayData[23] = 'Internet|Please Select...|'
arrayData[24] = 'Internet|Internet Sub Selection|'
arrayData[25] = 'Internet|Internet Sub Selection|'
arrayData[26] = 'Internet|Internet Sub Selection|'
arrayData[27] = 'Internet|Internet Sub Selection|'
arrayData[28] = 'Internet|Internet Sub Selection|'
arrayData[29] = 'Internet|Internet Sub Selection|'
arrayData[30] = 'Internet|Internet Sub Selection|'
arrayData[31] = 'Internet|Internet Sub Selection|'
arrayData[32] = 'Internet|Internet Sub Selection|'
arrayData[33] = 'Internet|Internet Sub Selection|'
arrayData[34] = 'Internet|Internet Sub Selection|'
arrayData[35] = 'Internet|Internet Sub Selection|'
arrayData[36] = 'Internet|Internet Sub Selection|'
arrayData[37] = 'Internet|Internet Sub Selection|'
arrayData[38] = 'Internet|Internet Sub Selection|'
arrayData[39] = 'Direct Mail|Direct Mail|'
arrayData[40] = 'Other Source|Other Source|'


function populateData( name ) {

select = window.document.form.howDidYouHear_WhichSource;
string = "";

// 0 - will display the new options only
// 1 - will display the first existing option plus the new options

count = 0;

// Clear the old list (above element 0)

select.options.length = count;

// Place all matching categories into Options.

for( i = 0; i < arrayData.length; i++ ) {
string = arrayData.split( &quot;|&quot; );
if( string[0] == name ) {
select.options[count++] = new Option( string[1] );
}
}

// Set which option from subcategory is to be selected

// select.options.selectedIndex = 2;

// Give subcategory focus and select it

// select.focus();

}

Called like this:

<select name=&quot;howDidYouFindOut&quot; size=1 style=&quot;width:160;&quot; onchange=&quot;javascript:populateData( this.options[selectedIndex].text )&quot;>


csatterwhite@orlandomediasolutions.com
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top