...

View Full Version : radio button with text field



homer.favenir
05-12-2009, 03:21 AM
hi,
can anyone please help me
i have javasctipt,radio buttons, and textfield
in default my textfield is disabled, and when any of radio buttons was click it is disabled also, but when the radio button of the textfield is click it will enable,
it works fine and submit the correct data.
when i went back to that page the radio button of the text field was checked ( ok its fine because it has value ) but it didnt show the value of the text field, and it is disabled.
i want to repost the input...

please kindly help

here's my code
index:


<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
</head>
<body>
<!-- HOMER -->
<script type="text/javascript">
var textbox = function(me,field){
if(me.checked == false){
var textb = document.createElement('input');
textb.type = "text";
textb.name = field;
me.parentNode.appendChild(textb);
}
setInterval(function(){
if(me.checked == false){
me.parentNode.removeChild(textb);
return false;
}
}, 50);
};
</script>
<!-- HOMER -->
<?php
$con = mysql_connect("localhost","root","");
if (!$con)
{
die('Could not connect: ' . mysql_error());
}
// some code
mysql_select_db("samples", $con);
$sql = "SELECT `subject` FROM topics order by id desc limit 1";
$result = mysql_query($sql);
while($row = mysql_fetch_array($result))
{
$pref_info['Objection'] = $row[0];
}
echo $pref_info['Objection'];
?>
<form name="pref_form" method="post" action="form4.php">
<TABLE width="700" cellpadding="2" cellspacing="2" border="0" bgcolor="#ffffff">
<tr bgcolor="#e8e8e8">
<TD WIDTH="36%" class="main">
&nbsp;&nbsp;:Punctuation after “objection”
</TD>
<TD WIDTH="64%" class="main" valign="top">
<input name="Objection" type="radio" value="3"<? print($pref_info['Objection'] == '3')? " checked" : ""; ?>> Objection. Vague, asumes facts not in evidence.<br />
<input name="Objection" type="radio" value="2"<? print($pref_info['Objection'] == '2')? " checked" : ""; ?>> Objection. Vague; asumes facts not in evidence.<br />
<input name="Objection" type="radio" value="1"<? print($pref_info['Objection'] == '1')? " checked" : ""; ?>> Objection. Vague. Assumes facts not in evidence.<br />
<input name="Objection" type="radio" value="0"<? print($pref_info['Objection'] == '0')? " checked" : ""; ?>> Objection; vague, assumes facts not in evidence.<br />
<input type="radio" checked="checked" name="Objection" onmouseup="textbox(this,'Objection')"/>Other:<noscript><input name="Objection" width="250" type="text" value="<?php echo $pref_info['Objection']; ?>" /></noscript>
</TD>
</tr>
<tr>
<td width=36% align=right class="main">&nbsp;</td>
<td><INPUT type="submit" name="submit" value="Submit"></td>
</tr>
</TABLE>
</form>
</body>
</html>


form2:


<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
</head>
<body>
<?php
$con = mysql_connect("localhost","root","");
if (!$con)
{
die('Could not connect: ' . mysql_error());
}
// some code
mysql_select_db("samples", $con);
$obj = $_POST['Objection'];
$sql = "INSERT INTO topics (subject) values ('" . $obj ."')";
$result = mysql_query($sql);
if($result){
echo "success";
}else{
echo "unsuccess";
}
echo $obj;
?>
</body>
</html>


table


DROP TABLE IF EXISTS `samples`.`topics`;
CREATE TABLE `samples`.`topics` (
`id` mediumint(9) NOT NULL auto_increment,
`subject` varchar(60) NOT NULL default '',
KEY `id` (`id`)
) ENGINE=MyISAM AUTO_INCREMENT=44 DEFAULT CHARSET=latin1;


i want to repost the input...

thanks in advance

adios
05-12-2009, 06:26 PM
You need to run something onload so the appropriate handler will be called.

Could you please post a single file, no-php sample so someone can modify it?



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum