/    Sign up×
Community /Pin to ProfileBookmark

Hi all
I’m learning how to tranfer value. I used hours to think how to get value (font color) from radio, then send that value to show.php to show NAME with chosen color by clicking “OK” once but not success yet. Need your assist.

[code=php]
<?php
//Input name
echo “<br><br> Enter your name : “;
echo “<input type=”text” name=”name”><input type=”submit” >”;

//Choose color
echo “<br><br>Please choose your font color.<br>”;
$color[] = “#000000”;
$color[] = “#FF0000”;
$color[] = “#00FF00”;
$color[] = “#0000FF”;
$color[] = “#FFFF00”;
$color[] = “#00FFFF”;
$color[] = “#FF00FF”;
$color[] = “#C0C0C0”;

$num = 0;
echo “<br><form>”;
while($num < 7){
echo “<input type=”radio” name=”color” value = $color[$num]>”;
echo “<font color=$color[$num]> This color </font><br>”;
$num++;
}
echo “</form>”;
echo “<input type=”button” value=”OK, Choose this color!”>”;
?>
[/code]

to post a comment
PHP

2 Comments(s)

Copy linkTweet thisAlerts:
@ThompsonOct 17.2009 — Hi there,

Most of you coding was correct there was just the issue of the form submitting.

[code=php]echo '<form action="show.php" method="GET">';[/code]

To submit to the page you want to.

Button
[code=php]echo "<input type="button" value="OK, Choose this color!">";[/code]

The code above was just a button that does nothing. What you want to use is

[code=php]echo "<input type="submit" value="OK, Choose this color!">";[/code]

Below is a working example of code which will carry across the colour value to show.php

[code=php]<?php
//Input name
echo "<br><br> Enter your name : ";
echo '<form action="show.php" method="GET">';
echo "<input type="text" name="name">";

//Choose color
echo "<br><br>Please choose your font color.<br>";
$color[] = "#000000";
$color[] = "#FF0000";
$color[] = "#00FF00";
$color[] = "#0000FF";
$color[] = "#FFFF00";
$color[] = "#00FFFF";
$color[] = "#FF00FF";
$color[] = "#C0C0C0";

$num = 0;
echo "<br>";
while($num < 7){
echo "<input type="radio" name="color" value = $color[$num]>";
echo "<font color=$color[$num]> This color </font><br>";
$num++;
}
echo "<input type="submit" value="OK, Choose this color!">";
echo "</form>";

?>[/code]
Copy linkTweet thisAlerts:
@GillbateauthorOct 17.2009 — Thank you! It works now.
×

Success!

Help @Gillbate 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 5.17,
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: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

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