radio button reamains checked


Posted on 16th Feb 2014 07:03 pm by admin

Hello i'm trying to keep the state off my radio buttons so it shows which ones where clicked after the submit button is clicked im new to this so bare with me.

heres my code

<?php
foreach($_POST as $key => $value){
$clicked[$key] = $value;
}
var_dump($clicked);

$block1 = $_POST['q1']+$_POST['q2']+$_POST['q3']+$_POST['q4'];

echo $block1*100/16;

?>

this is the result of the vardump.
array(5) { ["q1"]=> string(1) "1" ["q2"]=> string(1) "2" ["q3"]=> string(1) "3" ["q4"]=> string(1) "2" ["signup"]=> string(6) "submit" } 50


How can i take the value that is outputted from the relevant radio button and retain it after submit.

Here's the form code.


<FORM METHOD="post" ACTION="" id="check">
<table width="830" height="auto" border="0" cellpadding="1" cellspacing="1" style="">
<!----- SECTION ----->
<tr>
<h2>Marketing</h2>
</tr>
<tr>
<td width="25" align="center" valign="top" style="color: #D54D12">&nbsp;</td>
<td width="622" class="none"><p>&nbsp;</p></td>
<td width="17" align="center" valign="middle" class="borderbutton">1</td>
<td width="17" align="center" valign="middle" class="borderbutton">2</td>
<td width="17" align="center" valign="middle" class="borderbutton">3</td>
<td width="17" align="center" valign="middle" class="borderbutton">4</td>
<td width="92"></td>
</tr>
<tr>
<td colspan="6" align="center" valign="top" class="none" style="color: #D54D12"><hr /></td>
<td></td>
</tr>
<tr>
<td width="25" align="center" valign="top" class="borderbutton" style="color: #D54D12">1.</td>
<td width="622" class="borderbutton"><p>I know where I want my business to go and have a clear vision how to get there.</p></td>
<td width="17" align="center" valign="middle" class="borderbutton"><input type="radio" name="q1" value="1" validate="required:true" /></td>
<td width="17" align="center" valign="middle" class="borderbutton"><input type="radio" name="q1" value="2" /></td>
<td width="17" align="center" valign="middle" class="borderbutton"><input type="radio" name="q1" value="3" /></td>
<td width="17" align="center" valign="middle" class="borderbutton"><input type="radio" name="q1" value="4" /></td>
<td width="92"><label for="q1" class="error">* Required.</label></td>
</tr>

<tr>
<td width="25" align="center" valign="top" class="borderbutton" style="color: #D54D12">2.</td>
<td width="622" class="borderbutton">I have a written marketing plan that I follow to ensure I market my brand on a regular basis.</td>
<td width="17" align="center" valign="middle" class="borderbutton">
<input type="radio" name="q2" value="1" validate="required:true" /></td>
<td width="17" align="center" valign="middle" class="borderbutton"><input type="radio" name="q2" value="2" /></td>
<td width="17" align="center" valign="middle" class="borderbutton"><input type="radio" name="q2" value="3" /></td>
<td width="17" align="center" valign="middle" class="borderbutton"><input type="radio" name="q2" value="4" /></td>
<td width="92"><label for="q2" class="error">* Required.</label></td>
</tr>

<tr>
<td width="25" align="center" valign="top" class="borderbutton" style="color: #D54D12">3.</td>
<td width="622" class="borderbutton">I understand the role my brand (value delivered by my products and services ) plays in achieving my business goals.</td>
<td width="17" align="center" valign="middle" class="borderbutton"><input type="radio" name="q3" value="1" validate="required:true" /></td>
<td width="17" align="center" valign="middle" class="borderbutton"><input type="radio" name="q3" value="2" /></td>
<td width="17" align="center" valign="middle" class="borderbutton"><input type="radio" name="q3" value="3" /></td>
<td width="17" align="center" valign="middle" class="borderbutton"><input type="radio" name="q3" value="4" /></td>
<td width="92"><label for="q3" class="error">* Required.</label></td>
</tr>

<tr>
<td width="25" align="center" valign="top" class="borderbutton" style="color: #D54D12">4.</td>
<td width="622" height="22" class="borderbutton">Our current prices are a true reflection of the value my brand brings our clients.</td>
<td width="17" align="center" valign="middle" class="borderbutton"><input type="radio" name="q4" value="1" validate="required:true" /></td>
<td width="17" align="center" valign="middle" class="borderbutton"><input type="radio" name="q4" value="2" /></td>
<td width="17" align="center" valign="middle" class="borderbutton"><input type="radio" name="q4" value="3" /></td>
<td width="17" align="center" valign="middle" class="borderbutton"><input type="radio" name="q4" value="4" />



<!----- SECTION END ----->

</table>

<table>
<td width="17" align="center" valign="middle" class="borderbutton"><input type="submit"
name="signup" value="submit"></td>
</table>
</FORM>

No comments posted yet

Your Answer:

Login to answer
334 Like 13 Dislike
Previous forums Next forums
Other forums

Any Good MMORPGs you've played?
I'm about to have ALOT of free time on my hands (finished highschool) and I need something to fill t

Taking an HTML form and a PHP program and making it into one working file.
Hello,

So I would like to display everything INSIDE a specific directory. In other words, I

Need help with an email blocker for a guessbook
I am new with php and here is a simple guessbook page but I am being hit with spam from a group of t

Not connecting to DB using ruby, error:env.c:257:in oci8lib.so: ORA-12154:
Hi All,

I am trying to connect to the database server from the client server using ruby and f

Is there a way to override built in php functions without APD?
I am trying to use the
rename_function()
override_function()
options that are built into

Basic Question about Threading and PHP...
I have a page that I am working on and it is taking several hours to process. The basics of what th

Remote Database Access
Hey guys!!

OK, i'm used to only working with databases from the CPANEL, accessing phpMyAdmin

Losing 'page' data
I have this code that allows me to update my database. But after updating, I lose the $_GET['page']

temporary objects
Until now i thought every temporary object in C++ is created as constant. I'm wondering why my compi

Filename and Line Number Custom Error
I have a class, with a method that accepts 2 parameters. I would like to output error messages.

Sign up to write
Sign up now if you have flare of writing..
Login   |   Register
Follow Us
Indyaspeak @ Facebook Indyaspeak @ Twitter Indyaspeak @ Pinterest RSS



Play Free Quiz and Win Cash