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

Stopping page post back
I have few literal contriols in my page and a repeater too. But inspite of using update panel, postb

Help on query replacing the date
Hi Pals,

i want to replace the current date in a column to some value say C or D or any n

Where is my php.ini???
Hi

First off - apologies - i'm not a coder so this may sound very amateur.

I'm having

same querie, or a new one??
Hi guys,

I'm still working on this drop down list. I've got the actual drop down list to wor

PHP doesn't send my mail
Hi all, I found this and used it to send mail. Simple contact form with some required fields. The va

remove a ; from emails in textarea
Code: <?php

session_start();

$database_host = "localhost&qu

Images outside webroot
Im hopeing someone can help me with this because i cant figure it out.I have setup an ASP.NET websit

Not showing whole name with mail () script
I sent up a simple mail form with the PHP mail() script. One problem is when it sends an email with

Email Script does not reach destination
Hey Guys look at this code snippet :
Code:
//read a line from the file

$myFile = "

$get problem
Hi Guys ...

can you please tell me what i am doing wrong here
Code: <?php

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