Jump to content
Larry Ullman's Book Forums

Search the Community

Showing results for tags 'radio button'.



More search options

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


Forums

  • Single Editions
    • Modern Javascript: Develop and Design
    • The Yii Book
    • Effortless Flex 4 Development
    • Building a Web Site with Ajax: Visual QuickProject
    • Ruby: Visual QuickStart Guide
    • C++ Programming: Visual QuickStart Guide
    • C Programming: Visual QuickStart Guide
    • Adobe AIR: Visual QuickPro Guide
  • PHP and MySQL for Dynamic Web Sites: Visual QuickPro Guide
    • PHP and MySQL for Dynamic Web Sites: Visual QuickPro Guide (5th Edition)
    • PHP and MySQL for Dynamic Web Sites: Visual QuickPro Guide (4th Edition)
    • PHP 6 and MySQL 5 for Dynamic Web Sites: Visual QuickPro Guide (3rd Edition)
    • PHP and MySQL for Dynamic Web Sites: Visual QuickPro Guide (2nd Edition)
    • PHP and MySQL for Dynamic Web Sites: Visual QuickPro Guide (1st Edition)
  • PHP for the Web: Visual QuickStart Guide
    • PHP for the Web: Visual QuickStart Guide (5th Edition)
    • PHP for the Web: Visual QuickStart Guide (4th Edition)
    • PHP for the Web: Visual QuickStart Guide (3rd Edition)
    • PHP for the World Wide Web: Visual QuickStart Guide (2nd Edition)
    • PHP for the World Wide Web: Visual QuickStart Guide (1st Edition)
  • Effortless E-commerce with PHP and MySQL
    • Effortless E-Commerce with PHP and MySQL (2nd Edition)
    • Effortless E-Commerce with PHP and MySQL
  • PHP Advanced: Visual QuickPro Guide
    • PHP Advanced and Object-Oriented Programming: Visual QuickPro Guide (3rd Edition)
    • PHP 5 Advanced: Visual QuickPro Guide (2nd Edition)
    • PHP Advanced: Visual QuickPro Guide
  • MySQL: Visual QuickStart Guide
    • MySQL: Visual QuickStart Guide (2nd Edition)
    • MySQL: Visual QuickStart Guide (1st Edition)
  • Other
    • Announcements
    • Newsletter, Blog, and Other Topics
    • Forum Issues
    • Social

Find results in...

Find results that contain...


Date Created

  • Start

    End


Last Updated

  • Start

    End


Filter by number of...

Joined

  • Start

    End


Group


Found 2 results

  1. I want to enable a text field and button when the user selects a radio button, I have tried the following code but not working. echo CHtml::textField('trid','',array('id'=>'trid','size'=>7,'disabled'=>true)); echo CHtml::submitButton('Submit', array('id'=>'submit','name'=>'submit','disabled'=>true)); echo('<b>Dispaly records acoording to status number.</b>'); echo CHtml::radioButton('status',false,array( "success"=>"function(){ $(#trid).attr('enabled',true)';} $(#submit).attr('enabled',true)';", ));
  2. Hello I'm building a restaurant reservation form which needs to do 3 things - 1) Allow users to input # of people reserving for (Drop down) 2) Then dynamically based on # of people show available rooms (Radio button) 3) Then based on selected room, show date availability via (jquery datepicker) I need all 3 items to access mysql database and appear on same page without refresh. I have 1 & 2 working well but can't figure out how to pass on #2's selected room value onto a php and datepicker id to show dynamically. However, #3, as an independent file actually works well. Hence I have a challenge of linking 2 to #3. I'd greatly appreciate your expert input and apologies in advance for the length of the codes below. View.html <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title></title> <script src="js/ajax.js"></script> <script type="text/javascript"> function showUser(str) { var venue = '<?php echo $_GET['VenueID'] ?>'; if (str=="") { document.getElementById("txtHint").innerHTML=""; return; } var ajax = getXMLHttpRequestObject(); ajax.onreadystatechange=function() { if (ajax.readyState==4 && ajax.status==200) { document.getElementById("txtHint").innerHTML=ajax.responseText; } } //xmlhttp.open("GET","test.php?c="+str,true); ajax.open("GET","roomselect.php?c="+str+"&venue="+venue,true); ajax.send(null); } </script> </head> <body> <form> <select name="username" onchange="showUser(this.value)"> <?php $venue = $_GET['VenueID'];?> <option value="">Select # of People here </option> <?php while ($row=mysql_fetch_array($result)) { echo "<option value=\"".$row['Capacity']."\""; echo ">".$row['Capacity']."</option>\n"; ; } ?> </select> </form> <br /> <br /> <br /> <div id="txtHint"><b>Person info will be listed here. </b></div> <br /> <br /> <br /> <h3>Would like to show a button that upon clicking, would show datepicker here</h3> <br/> </body> Here's the Roomselect.php which the above references and contains the radio select buttons for rooms. <?php $c=$_GET["c"]; $id = &$_GET["venue"]; $con = mysql_connect('DBHOST', 'DBUSER', ''); if (!$con) { die('Could not connect: ' . mysql_error()); } mysql_select_db("DBNAME", $con); if(isset($id ) && is_numeric($id)) { $sql="SELECT * FROM venue_room WHERE MaxCap > $c and VenueID =$id"; $result = mysql_query($sql); echo mysql_error($con); while($row = mysql_fetch_array($result)) { echo ' <input type ="radio" name="'.$row['RoomName'].'" id="'.$row['RoomID'].'" value = "'.$row['RoomID'].'" > <img src = " '.$row['Image1'],'" alt="" height="100" width="120" /> in ' . $row['RoomName'] . ' at venueID '.$id.' with capacity from '.$row['Capacity'].' to '.$row['MaxCap'].'</br> ' ; } } else { echo "Oops! Sorry, but this link seems to not be working. Please press back and try again!" ; } ?> As mentioned, the above two files have #1 & #2 working well together on same page without refresh. Now for #3...below are the independent datepicker files which work well on its own. I just can't figure out how to link the below to #1 & #2 Calendar.html <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title></title> <link href="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8/themes/base/jquery-ui.css" rel="stylesheet" type="text/css"/> <link rel="stylesheet" href="http://static.jquery.com/ui/css/demo-docs-theme/ui.theme.css" type="text/css" media="all"/> <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.5/jquery.min.js"></script> <script src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8/jquery-ui.min.js"></script> <script> $(document).ready(function() { var selected_dates = new Array(); // get all the events from the database using AJAX selected_dates = getSelectedDates(); $('#datepicker').datepicker({ //Image: '/images/logo.png',//delete this and the next two lines (so first line showing is dateFormat to go to the way it was before. And then must change //ImageOnly: true, //showOn: 'both', dateFormat: 'yy-m-d', inline: true, beforeShowDay: function (date) { // get the current month, day and year // attention: the months count start from 0 that's why you'll need +1 to get the month right var mm = date.getMonth() + 1, dd = date.getDate(), yy = date.getFullYear(); var dt = yy + "-" + mm + "-" + dd; if(typeof selected_dates[dt] != 'undefined') { // put a special class to the dates you have events for so you can distinguish it from other ones // the "true" parameter is used so we know what are the dates that are clickable return [true, " my_class"]; } return [false, ""]; }, onSelect : function(date) { $('#date_select').val(date); $('#date_selection_container').html(date); } }); }); function getSelectedDates() { var the_selected_dates = new Array(); $.ajax( { url: 'dateselect.php', dataType: 'json', async: false, success: function(data) { $.each(data, function(n, val) { the_selected_dates[val.event_date] = val; }); } }); return the_selected_dates; } </script> </head> <body> <h3>3. Select Date</h3> <br/> <div id="datepicker"></div> <!--div id="date_selection_container"></div--> </body> </html> And finally the dateselect.php which the above calendar.html file references I fully admit I found the below on a website which uses PHP PDO which I'm not familiar with. I stuck to it though because it's working <?php session_start(); // Initializations of the variables used $dates = array(); // MYSQL connection credentials include_once "Connection.php"; // PDO - connect to the database try { $dbh = new PDO('mysql:host='.DB_HOST.';dbname='.DB_NAME, DB_USER, DB_PASS); $dbh->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); $dbh->setAttribute(PDO::ATTR_PERSISTENT, true); $dbh->setAttribute(PDO::ATTR_EMULATE_PREPARES, true); $dbh->setAttribute(PDO::MYSQL_ATTR_USE_BUFFERED_QUERY, true); } catch (PDOException $e) { echo 'Error!: ' . $e->getMessage() . '<br/>'; } // take the events from the table named "events" try { $id = (int)$_SESSION['VenueID']; //leave it as session as needed for multiple pages $room = (int)$_POST['RoomID']; $sql = ' SELECT * FROM venue_room_availability WHERE IsAvailable = "Y" and RoomID=:Room and VenueID = :Venue '; $stmt = $dbh->prepare($sql); $stmt->bindParam(':Venue',$id,PDO::PARAM_INT); $stmt->bindParam(':Room',$room,PDO::PARAM_INT); $stmt->execute(); } catch (PDOException $e) { print($e->getMessage()); die; } while ($row = $stmt->fetch(PDO::FETCH_ASSOC)) { // because $row['event_date'] will have this form: 2012-01-10 and in Javascript we have 2012-1-10, // we need to rewrite it the way we use it in Javascript so we can compare it $row['event_date'] = date("Y-n-j", strtotime($row['event_date'])); $dates[] = $row; } echo json_encode($dates); ?>
×
×
  • Create New...