Jump to content


Contact Form With Dropdown


2 replies to this topic

#1 albinoAZN

    Albinos Are Extinct!!!

  • Members
  • PipPipPipPip
  • 1,139 posts
  • Gender:Male
  • Location:Mississippi, USA

Posted 12 March 2007 - 02:10 AM

Hi all. I need to figure out how to make the php tell the email which subject the user chose from the dropdown.

my dropdown is simple
<select id='subject' name="title">
				<option value='0'>Email Subject
				<option value='1'>Affiliation
				<option value='2'>Bug Report
				<option value='3'>Chit-Chat
				<option value='4'>Web Development
				<option value='5'>Other
				</select>

I need the basic function which will appoint the proper Subject chosen from the list.

#2 Mr. Matt

    Moderator

  • P2L Staff
  • PipPipPipPip
  • 1,945 posts
  • Gender:Not Telling

Posted 12 March 2007 - 03:11 AM

There are two ways you can look at doing, the second way is a faster way for php, time difference in it wouldn't be much though.

<select id='subject' name="title">
	<option value='0'>Email Subject</option>
	<option value='1'>Affiliation</option>
	<option value='2'>Bug Report</option>
	<option value='3'>Chit-Chat</option>
	<option value='4'>Web Development</option>
	<option value='5'>Other</option>
</select>
<?php

switch( $_POST['title'] ) {
	case '0':
		$header = 'Email Subject';
	break;
	case '1':
		$header = 'Affiliation';
	break;
	case '2':
		$header = 'Bug Report';
	break;
	case '3':
		$header = 'Chit-Chat';
	break;
	case '4':
		$header = 'Web Development';
	break;
	case '5':
		$header = 'Other';
	break;
}

?>

OR

<select id='subject' name="title">
	<option value='Email Subject'>Email Subject</option>
	<option value='Affiliation'>Affiliation</option>
	<option value='Bug Report'>Bug Report</option>
	<option value='Chit-Chat'>Chit-Chat</option>
	<option value='Web Development'>Web Development</option>
	<option value='Other'>Other</option>
</select>
<?php

$header = $_POST['title'];

#OR you can just use

$_POST['title'];

?>

Matt

#3 nitr0x

    Young Padawan

  • Members
  • Pip
  • 201 posts

Posted 12 March 2007 - 08:41 AM

ha, I never thought about using a switch for that lol. But yea...

second method is how I do mine :P





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users