Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    New to the CF scene
    Join Date
    Jul 2008
    Location
    Manila, Philippines
    Posts
    6
    Thanks
    0
    Thanked 0 Times in 0 Posts

    radio button with text field

    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:
    Code:
    <!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:
    Code:
    <!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
    Code:
    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

  • #2
    Senior Coder
    Join Date
    Jun 2002
    Posts
    1,404
    Thanks
    2
    Thanked 32 Times in 32 Posts
    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?


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •