Jump to content


Form and subject selecting


4 replies to this topic

#1 Marxx

    Young Padawan

  • Members
  • Pip
  • 116 posts
  • Gender:Male
  • Location:Finland

Posted 18 January 2006 - 02:16 PM

Hi all!

I have this form and i've some question about subject selecting..

If i want to link into my form from another page whit specific subject selected - how do i do that?

Here is my form code:

<form name="form1" action="sendmail[contact].php" onsubmit="return formCheck(this);" method="post">  
				  <table border="0">  
				  <tr>  
					 <td class="formtext">Nimesi :</td>
				  </tr>  
				  <tr> 
					 <td><input class="formfield" type="text" size="30" name="name"></td>
				  </tr>  
				  <tr>  
					 <td class="formtext">Sähköposti :</td>
				  </tr>  
				  <tr> 
					 <td><input class="formfield" type="text" size="30" name="email"></td>
				  </tr>  
				  <tr>  
					 <td class="formtext">Viestin aihe :</td>
				  </tr>  
				  <tr> 
					 <td><select class="formfield" name="subject" onChange="displaydesc(document.form1.subject, thetext1, 'textcontainer1')">
						  <option value="">Valitse aihe</option>
						  <option value="Virhe sivustolla">Virhe sivustolla</option>
						  <option value="Tutoriaaleista">Tutoriaaleista</option>
						  <option value="Viikon sivusto">Viikon Sivusto</option>
						  <option value="Viikon kuva">Viikon Kuva</option>
						  <option value="Muu">Muu</option>
						  </select>
					  </td>  
				  </tr>  
				  <tr>  
					 <td class="formtext">Viesti :</td>  
				  </tr>  
				  <tr> 
					   <td><textarea class="formfield" rows="8" cols="50" name="message"></textarea></td>		
				  </tr>
				  <tr>
					<td><br /><input class="submit_button" type="image" src="images/button_laheta.gif"></td>
				  </tr>
				  </table>  
				  </form>

I'm looking for sollution which could be like

http://www.myserver.com/contact.php?subject_id=2

Hope everyone understod what i mean.. :)


Thanks in advance...

#2 rc69

    PHP Master PD

  • P2L Staff
  • PipPipPipPip
  • 3,827 posts
  • Gender:Male
  • Location:Here
  • Interests:Web Development

Posted 18 January 2006 - 02:28 PM

					 <td><select class="formfield" name="subject" onChange="displaydesc(document.form1.subject, thetext1, 'textcontainer1')">
<?
$options = array('Valitse aihe',
				 'Virhe sivustolla',
				 'Tutoriaaleista',
				 'Viikon sivusto',
				 'Viikon kuva',
				 'Muu');
foreach($options as $key=>$value){
	echo '<option value="'.$value.'" '.($key == $_GET['selected_id'] ? 'selected="selected" : '').'>'.$value."</option>\n";
}
?>
						  </select>
					  </td>
That is one way you could do it. But you should get the general idea.

Edited by rc69, 18 January 2006 - 02:29 PM.


#3 Marxx

    Young Padawan

  • Members
  • Pip
  • 116 posts
  • Gender:Male
  • Location:Finland

Posted 18 January 2006 - 03:10 PM

hmm.. looks great but i get this

Parse error: parse error, unexpected T_CONSTANT_ENCAPSED_STRING

Tried to find some " or ' missing or something but didn't found... is there? :)


Thanks..

#4 rc69

    PHP Master PD

  • P2L Staff
  • PipPipPipPip
  • 3,827 posts
  • Gender:Male
  • Location:Here
  • Interests:Web Development

Posted 18 January 2006 - 10:26 PM

Ya... thats what you get when you try to code without dreamweavers fancy color coding...
echo '<option value="'.$value.'" '.($key == $_GET['selected_id'] ? 'selected="selected"' : '').'>'.$value."</option>\n";
Missed a quote in that section, after the "selected" part. You can copy what's above and just replace the line that looks similar to it.

#5 Marxx

    Young Padawan

  • Members
  • Pip
  • 116 posts
  • Gender:Male
  • Location:Finland

Posted 19 January 2006 - 01:39 AM

Yes, that's it! :D

Thanks you rc69 very much for helping me!! Respect..





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users