NYCPHP Meetup

NYPHP.org

[nycphp-talk] Simple form-based selection and cookie-setting/g etting

Robert Dumas rdumas at cmj.com
Thu Jul 31 15:56:12 EDT 2003


so if I'm reading this right, I want to do something like this?

<form name="mediaplayerchoice" id="mediaplayerchoice" method="post">
	Preferred Media Player:<br />
	<label><input type="radio" name="preferredmediaplayer" value="real"
onclick="document.mediaplayerchoice.submit();return false" /> RealOne
Player</label><br />
	<label><input type="radio" name="preferredmediaplayer" value="wmp"
onclick="document.mediaplayerchoice.submit();return false" /> Windows Media
Player</label><br />
</form>

... and that will cause the form to submit the VALUE of whatever radio input
is clicked?

--RD

-----Original Message-----
From: Sexton, David [mailto:David.SextonJr at ubs.com]
Sent: Thursday, July 31, 2003 3:39 PM
To: 'NYPHP Talk'
Subject: RE: [nycphp-talk] Simple form-based selection and
cookie-setting/g etting


You are trying to execute PHP code on the client. What you would want to do
is have Javascript submit the form
(onClick="document.mediaplayerchoice.submit();"). Then have your setcookie
call at the top of the processing page... like this:
 
setcookie("preferredmediaplayer",
$_POST['preferredmediaplayer'],time()+60*60*24*30,"/player/","cmj.com",0);
 
Basically, if you view the source of the web page after it loads as it is
now, there will be no code for the onClick event since the PHP code is
parsed beforehand and does not output anything. What you will have is the
cookie value always set to 'wmp' since you are overwriting it each time a
user hits this form.
 
HTH... let me know if it's still unclear.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.nyphp.org/pipermail/talk/attachments/20030731/7bbaab8f/attachment.html>


More information about the talk mailing list