/    Sign up×
Community /Pin to ProfileBookmark

I’m having trouble with my IT homework and looking for help. I have to make the following form sticky and am having trouble working out how to do this for the drop down menu. Please help!

Edit: Forgot to post the form!

[code=html]<form action=”sticky.php” method=”post”>
<fieldset id=”fieldset”>
<label >Name</label>
<input type=”text” name=”name” size=”20″ value=”” /><br />
<label>Favourite food</label>
<select name=”food” size=”1″>
<option value=”” selected=”selected”>Pick-One</option>
<option value=”hot_dog”>Hot Dog</option>
<option value=”hamburger”>Hamburger</option>
<option value=”chips”>Chips</option>
<option value=”doughnuts”>Doughnuts</option>
<option value=”ice_cream”>Ice Cream</option>
</select><br />
<label >Now do a </label>
<input type=”submit” value=”Test” />
</fieldset>
</form>

[/code]

to post a comment
PHP

4 Comments(s)

Copy linkTweet thisAlerts:
@bathurst_guyJul 18.2005 — Sorry what's wrong with it? Do you think you should you include the php file aswell?
Copy linkTweet thisAlerts:
@bokehJul 18.2005 — Well first you should consult a health professional abotut your favorite foods!

You could do it this way, which is a bit unusual:
[code=php]<?php
if($_POST['food'] != ('hot_dog'&&'hamburger'&&'chips'&&'doughnuts'&&'ice_cream')){
$pick_one = ' selected="selected"';
}else{
$$_POST['food'] = ' selected="selected"';
}

echo <<< FORM
<form action="http://{$_SERVER['HTTP_HOST']}{$_SERVER['PHP_SELF']}" method="post">
<fieldset id="fieldset">
<label >Name</label>
<input type="text" name="name" size="20" value="{$_POST['name']}" /><br />
<label>Favourite food</label>
<select name="food" size="1">
<option value=""$pick_one>Pick-One</option>
<option value="hot_dog"$hot_dog>Hot Dog</option>
<option value="hamburger"$hamburger>Hamburger</option>
<option value="chips"$chips>Chips</option>
<option value="doughnuts"$doughnuts>Doughnuts</option>
<option value="ice_cream"$ice_cream>Ice Cream</option>
</select><br />
<label >Now do a </label>
<input type="submit" value="Test" />
</fieldset>
</form>

FORM;

?>[/code]
Copy linkTweet thisAlerts:
@Nine_Years_OldauthorJul 18.2005 — Sorry what's wrong with it? Do you think you should you include the php file aswell?[/QUOTE]That is the PHP file. The whole point is I have to make it sticky. I have tried the code Bokeh posted and it seems to do exactly what I want but I don't understand how it works. As I have to explain this to my teacher could someone please explain it to me, in the simplest way possible.
Copy linkTweet thisAlerts:
@Nine_Years_OldauthorJul 19.2005 — I don't understand where you are getting those other variables from. [B]Anybody help me?[/B]
×

Success!

Help @Nine_Years_Old spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 4.29,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,

tipper: @Samric24,
tipped: article
amount: 1000 SATS,
)...