Jump to content

wispas

Members
  • Posts

    71
  • Joined

  • Last visited

    Never

Everything posted by wispas

  1. I have attached a file with a date picker script that i ahve been using and working on. Everything works perfectly the way i want it to work, However when the date is inserted into the text field it comes out as '2011-03-01' Now.. i need it in this way as i am collecting this information and sending it to my MySQL query, but is there a way i can change it so it visually displays as '1st March 2011', but still go into the database as '2011-03-01' so i can continue to do my query as well as making it visually look good with some sort of JavaScript date formatting. Can anyone please take a look when they have a momemt. Thanks! [attachment deleted by admin]
  2. I want to set up a Javascript Function with a OnClick without the use of a form. Heres a simple Checkbox: <input type="checkbox" name="checker" id="checker" /> Check the button is clicked. <br /> <br /> <a href="#" onclick="meClick()">Submit This</a> I want to add a function to see if checkbox is checked upon clicking the link: <script type="text/javascript"> function meClick(){ if(document.checker.checked == true){ alert("Hooray... checkbox is clicked"); }else{ alert("Nah... its not working"); } } </script> But this is not working... please help... been driving me mad for hours!!!!
  3. Hi, I have a form on my page. <form id="advanced_search" name="advanced_search" method="POST" action="<?php echo $PHP_SELF;?>"> </form> Form submits with a regular button <input type="submit" name="advSearch" id="advSearch" value="Search" /> And i have a detector to see where submit button has been clicked on my next page: if(isset($_POST['advSearch'])) { echo "Button was clicked"; } However, I wanted a custom button for better styling and control. So i replaced my regular button with this now which uses javascript to submit the form. <a class="button" href="javascript:document.advanced_search.submit()" name="advSearch" id="advSearch"><span>Search</span></a> Now the isset($_POST) is not working anymore. Can anyone help please?? Thanks!
  4. I have a page with a link: <a href="grab.html?myParameter=hotel">Show me the Parameter</a> On 'grab.html' i want to display the 'myParameter' prameter which should be "hotel" Can anyone show me howi can display the parameter from the URL please. Thanks!
  5. worked like a charm... thank you so much"
  6. So i am bringing in two words from a form... but just to keep things simple... lets says i have: GB95/Andrew I want to use PHP to eliminate the '/' and then put the two words 'GB95' and 'Andrew' into seperate variables... does anyone know how i can achieve this?
  7. Anyone know how to use javascript to align div in the center?
  8. I have put together this code that will change the background color of my div container... which works very well... but if i had another div that wanted to do the same thing... is there a way i can make this code reusable and not have to copy and paste the entire function. Thanks! <!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> <style type="text/css"> <!-- #myDiv { background-color: #33CCFF; width: 300px; height: 300px; } --> </style> </head> <body> <script type="text/javascript"> var gothink = 0; function gothink_function(element) { if ( gothink == 0 ) { document.getElementById('myDiv').style.backgroundColor = '#D4DBE7'; gothink = gothink + 1; // alert(gothink) } else if ( gothink == 1 ) { document.getElementById('myDiv').style.backgroundColor = '#D49997'; gothink = gothink - 1; // alert(gothink) } } </script> <div id="myDiv">Content for id "myDiv" Goes Here</div> <p>Click one:</p> <p><img src="images/close_btn.jpg" width="40" height="40" onclick="alert(gothink)" /></p> <p>Click two:</p> <p><img src="images/round_red_close_button_5095.jpg" width="200" height="200" onclick="gothink_function()" /></p> </body> </html>
  9. that worked so well... exactly what i was looking for... thank you very much!
  10. i have a script that expands and collapses a div tag when the a:link has been clicked. i have added an extra div at the bottom called status and wanted it to display some words as to whether the box is expanded or collapsed; can anyone help me with this... im guessing its adding some code into the javascript that i already have. <html> <head> <title>Show/Hide Element</title> <script type="text/javascript"> function showHide(div){ if(document.getElementById(div).style.display == 'none'){ document.getElementById(div).style.display = 'block'; }else{ document.getElementById(div).style.display = 'none'; } } </script> </head> <body> <a href="#"><div id="filter" onClick="showHide('filtersearch');">Filter Search Results</div></a> <div id="filtersearch" style="display:none;">Put content here</div> <div id="status"></div> </body> </html>
  11. I have a website that is PHP and displays information from a MySQL database... i simply want to add rss news feeds onto my website but put the RSS into a MySQL database so only certain pages will display the feed. Any clue on how this can be achieved...
  12. I have a lists of hotel names in a drop down menu: <?php // Connect database include("connectdb.php"); $sql="SELECT hotel_id, hotel_name FROM hotel ORDER BY hotel_name ASC"; $result=mysql_query($sql); $options=""; $id_array = array(); $hotel_name = array(); while ($row=mysql_fetch_array($result)) { $id_array[]=$row["hotel_id"]; $hotel_name[]=mysql_real_escape_string($row["hotel_name"]); $options.="<option VALUE='".$row["hotel_id"]."'>".$row["hotel_name"]."</option>"; } ?> <select name="hotel_name" size="1" style="background-color:#FFFFD7"> <?php echo $options; ?> </select> I want to display a default hotel based on its value... say i want the drop down to be on hotel id 35 when the page loads... does someone know how i can achieve this... ?
  13. I have this SQL query at the moment: SELECT * FROM city INNER JOIN packages ON packages.city_code = city.city_code WHERE city_id='$id'; I have another table i want to inner join called hotel. Does anyone know how to add this into the SQL query above.
  14. you are absolutely right... i dont know why that is there... took it out now... all working well.
  15. I have written a SQL query that for some reason will miss out 1 row... for example i have 8 results with a city_code of AUH this will display properly when putting the SQL query in PHPMyAdmin, but when done in PHP it will only show 7.... Can anyone figure out why it will do this...? SQL: <?php // Connect database include("includes/connectdb.php"); ?> <?php // get value of id that sent from address bar $id=$_GET['id']; // Get records in all columns from table where column id equal in $id and put it in $result. $result=mysql_query(" SELECT * FROM city INNER JOIN hotel ON hotel.hotel_city_code = city.city_code WHERE city_id='$id' "); // Split records in $result by table rows and put them in $row. $row=mysql_fetch_assoc($result); // Close database connection. mysql_close(); ?> Displaying all of the hotels: <?php while($row=mysql_fetch_array($result)){ ?> <table width="325" border="0" cellspacing="0" cellpadding="0"> <tr> <td width="125" align="left" valign="top"><?php echo '<img src="'.$row['hotel_img'].'" />'; ?></td> <td width="200" align="left" valign="top"><div id="hotel_name"><?php echo $row['hotel_name']; ?><br /> <?php for($i = 0; $i < $row['hotel_star']; $i++) echo '<img src="images/star.gif" alt=""/>'; ?></div> <div id="hotel_address"><?php echo $row['hotel_address']; ?></div> <div id="hotel_desc"><?php echo nl2br( substr($row['hotel_desc'], 0, 65 )) . "..." ; ?></div></td> </tr> </table> <br/> <?php } ?>
  16. no worries... i figured it out... SELECT * FROM city INNER JOIN hotel, gallery WHERE hotel.hotel_city_code = city.city_code AND gallery.gallery_city_code = city.city_code AND city_id =1
  17. I have 3 tables which i want to combine and select with one query... Tables: city, hotel, gallery I currently have: SELECT * FROM city INNER JOIN hotel ON hotel.hotel_city_code = city.city_code WHERE city_id=1 This will join the hotel and city together perfectly allowing me to select all of the data from hotel and city with the matching city code, but i want to also join the gallery table as well in the same query and have its city code match the city city code and am getting syntax errors... Heres what i have tried and still working on: SELECT * FROM city INNER JOIN hotel, gallery ON hotel.hotel_city_code = city.city_code AND gallery.gallery_city_code = city.city_code WHERE city_id=1 Anyone can provide me with a quick fix? Cheers!
  18. Fantastic... I will give it a try. Thanks!
  19. Can anyone help me... I am trying to write a SQL Query based on the following: - I have two tables ( city, hotel ) - both have a id field and a field called city_code... so what i need the query to do is get the id from the address bar (e.g $id=1 based off the city... ) and display all the city fields but also display all of the hotel that have the same 'city_code'. so im guessing it will be WHERE hotel.city_code = city.city_code Can someone please help as im so stuck at the moment.
  20. This is simply inserting the form data into the mysql database. so i have a database field with the name 'licence'. this determines the persons licence type.... i have a drop down menu (name is licence which inserts teh value into the database) this drop down menu has the option to select a other option which opens up a text field.... does anyone know how i can script it so that when the user fills in the text field it will go into the database as the text field value rather than the value of other which is taken from the drop down menu. Heres the form: <form id="form1" name="form1" method="post" action="thank_you.php"> <table width="580" border="0" align="center" cellpadding="5" cellspacing="0"> <tr> <td colspan="2" align="left" valign="top"><h1>New Agency Application</h1></td> <td width="215" rowspan="4" align="right" valign="top"> </td> </tr> <tr> <td width="130" align="right" valign="top">Agency Name:</td> <td width="215" align="left" valign="top"><label> <input type="text" name="agency_name" id="agency_name" /> </label></td> </tr> <tr> <td align="right" valign="top">Title:</td> <td align="left" valign="top"><label> <select name="title" id="title"> <option value="" selected="selected"></option> <option value="Mr">Mr</option> <option value="Mrs">Mrs</option> <option value="Miss">Miss</option> <option value="Ms">Ms</option> <option value="Sir">Sir</option> <option value="Dr">Dr</option> </select> </label></td> </tr> <tr> <td align="right" valign="top">Forename:</td> <td align="left" valign="top"><label> <input type="text" name="forename" id="forename" /> </label></td> </tr> <tr> <td align="right" valign="top">Lastname:</td> <td colspan="2" align="left" valign="top"><label> <input type="text" name="lastname" id="lastname" /> </label></td> </tr> <tr> <td align="right" valign="top">Address:</td> <td colspan="2" align="left" valign="top"><label> <textarea name="address" id="address" cols="45" rows="5"></textarea> </label></td> </tr> <tr> <td align="right" valign="top">Phone Number:</td> <td colspan="2" align="left" valign="top"><label> <input type="text" name="phone_no" id="phone_no" /> </label></td> </tr> <tr> <td align="right" valign="top">Email Address:</td> <td colspan="2" align="left" valign="top"><label> <input type="text" name="email_add" id="email_add" /> </label></td> </tr> <tr> <td align="right" valign="top">Licence Type:</td> <td colspan="2" align="left" valign="top"><label> <select name="licence"> <option value="" selected="selected"></option> <option value="ABTA">ABTA</option> <option value="ATOL">ATOL</option> </select> </label></td> </tr> <tr> <td align="right" valign="top">Licence Number:</td> <td colspan="2" align="left" valign="top"><input type="text" name="licence_number" id="licence_number" /></td> </tr> <tr> <td align="right" valign="top"> </td> <td colspan="2" align="left" valign="top"><label> <input type="submit" name="submit" id="submit" value="Register" /> </label></td> </tr> </table> </form> Heres the PHP Generator that inserts that data into the mysql database: <?php include('includes/connectdb.php'); $tbl_name="agents_list"; // Table name if(isset($_POST['submit'])) { $agency_name = $_POST['agency_name']; $title = $_POST['title']; $forename = $_POST['forename']; $lastname = $_POST['lastname']; $address = $_POST['address']; $phone_no = $_POST['phone_no']; $email_add = $_POST['email_add']; $licence = $_POST['licence']; $licence_number = $_POST['licence_number']; // Insert data into mysql $sql="INSERT INTO $tbl_name(agency_name, title, forename, lastname, address, phone_no, email_add, licence, licence_number, CD, UD)VALUES('$agency_name', '$title', '$forename', '$lastname', '$address', '$phone_no', '$email_add', '$licence', '$licence_number', curdate(), curdate())"; $result=mysql_query($sql); } else { echo "Failed to insert."; } ?>
  21. that worked very well. thank you! sorry for putting it into the wrong forum. can administrator please move to php forums.
  22. I currently have a mail form that sends to a single email address. Does anyone know how i can set it up so it sends out to more than one email address. Thanks! The Form <form method="POST" action="mailer.php"> <input type="text" name="name" size="19"><br> <br> <input type="text" name="email" size="19"><br> <br> <textarea rows="9" name="message" cols="30"></textarea> <br> <br> <input type="submit" value="Submit" name="submit"> </form> Processing PHP <?php if(isset($_POST['submit'])) { $to = "you@you.com"; $subject = "Form Tutorial"; $name_field = $_POST['name']; $email_field = $_POST['email']; $message = $_POST['message']; $body = "From: $name_field\n E-Mail: $email_field\n Message:\n $message"; echo "Data has been submitted to $to!"; mail($to, $subject, $body); } else { echo "blarg!"; } ?>
  23. currently i have the format for my date as 'yyyy-mm-dd' as this is how it inserts into the mysql datbase when i submit for the form... what i want is the date to be shown in the form as dd/mm/yyyy but when submitted the value of the date will be 'yyyy-mm-dd'. does anyone know how this is done... i have used mootools for this date picker script. HTML page: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" > <head> <title>MooTools DatePicker Example</title> <script type="text/javascript" src="scripts/mootools.js"></script> <script type="text/javascript" src="scripts/DatePicker.js"></script> <script type="text/javascript"> // The following should be put in your external js file, // with the rest of your ondomready actions. window.addEvent('domready', function(){ $$('input.DatePicker').each( function(el){ new DatePicker(el); }); }); </script> <link href="styles/DatePicker.css" rel="stylesheet" type="text/css" /> </head> <body> <div class="yep"> <p> <input id="birthday" name="birthday" type="text" class="DatePicker" tabindex="1" /> </p> </div> </body> </html> And the DatePicker script: /* * DatePicker * @author Rick Hopkins * @modified by Micah Nolte and Martin VaĊĦina * @version 0.3.2 * @classDescription A date picker object. Created with the help of MooTools v1.11 * MIT-style License. -- start it up by doing this in your domready: $$('input.DatePicker').each( function(el){ new DatePicker(el); }); */ var DatePicker = new Class({ /* set and create the date picker text box */ initialize: function(dp){ // Options defaults this.dayChars = 1; // number of characters in day names abbreviation this.dayNames = ['Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday']; this.daysInMonth = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]; this.format = 'yyyy-mm-dd'; this.monthNames = ['January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December']; this.startDay = 7; // 1 = week starts on Monday, 7 = week starts on Sunday this.yearOrder = 'asc'; this.yearRange = 10; this.yearStart = (new Date().getFullYear()); // Finds the entered date, or uses the current date if(dp.value != '') { dp.then = new Date(dp.value); dp.today = new Date(); } else { dp.then = dp.today = new Date(); } // Set beginning time and today, remember the original dp.oldYear = dp.year = dp.then.getFullYear(); dp.oldMonth = dp.month = dp.then.getMonth(); dp.oldDay = dp.then.getDate(); dp.nowYear = dp.today.getFullYear(); dp.nowMonth = dp.today.getMonth(); dp.nowDay = dp.today.getDate(); // Pull the rest of the options from the alt attr if(dp.alt) { options = Json.evaluate(dp.alt); } else { options = []; } dp.options = { monthNames: (options.monthNames && options.monthNames.length == 12 ? options.monthNames : this.monthNames) || this.monthNames, daysInMonth: (options.daysInMonth && options.daysInMonth.length == 12 ? options.daysInMonth : this.daysInMonth) || this.daysInMonth, dayNames: (options.dayNames && options.dayNames.length == 7 ? options.dayNames : this.dayNames) || this.dayNames, startDay : options.startDay || this.startDay, dayChars : options.dayChars || this.dayChars, format: options.format || this.format, yearStart: options.yearStart || this.yearStart, yearRange: options.yearRange || this.yearRange, yearOrder: options.yearOrder || this.yearOrder }; dp.setProperties({'id':dp.getProperty('name'), 'readonly':true}); dp.container = false; dp.calendar = false; dp.interval = null; dp.active = false; dp.onclick = dp.onfocus = this.create.pass(dp, this); }, /* create the calendar */ create: function(dp){ if (dp.calendar) return false; // Hide select boxes while calendar is up if(window.ie6){ $$('select').addClass('dp_hide'); } /* create the outer container */ dp.container = new Element('div', {'class':'dp_container'}).injectBefore(dp); /* create timers */ dp.container.onmouseover = dp.onmouseover = function(){ $clear(dp.interval); }; dp.container.onmouseout = dp.onmouseout = function(){ dp.interval = setInterval(function(){ if (!dp.active) this.remove(dp); }.bind(this), 500); }.bind(this); /* create the calendar */ dp.calendar = new Element('div', {'class':'dp_cal'}).injectInside(dp.container); /* create the date object */ var date = new Date(); /* create the date object */ if (dp.month && dp.year) { date.setFullYear(dp.year, dp.month, 1); } else { dp.month = date.getMonth(); dp.year = date.getFullYear(); date.setDate(1); } dp.year % 4 == 0 ? dp.options.daysInMonth[1] = 29 : dp.options.daysInMonth[1] = 28; /* set the day to first of the month */ var firstDay = (1-(7+date.getDay()-dp.options.startDay)%7); /* create the month select box */ monthSel = new Element('select', {'id':dp.id + '_monthSelect'}); for (var m = 0; m < dp.options.monthNames.length; m++){ monthSel.options[m] = new Option(dp.options.monthNames[m], m); if (dp.month == m) monthSel.options[m].selected = true; } /* create the year select box */ yearSel = new Element('select', {'id':dp.id + '_yearSelect'}); i = 0; dp.options.yearStart ? dp.options.yearStart : dp.options.yearStart = date.getFullYear(); if (dp.options.yearOrder == 'desc'){ for (var y = dp.options.yearStart; y > (dp.options.yearStart - dp.options.yearRange - 1); y--){ yearSel.options[i] = new Option(y, y); if (dp.year == y) yearSel.options[i].selected = true; i++; } } else { for (var y = dp.options.yearStart; y < (dp.options.yearStart + dp.options.yearRange + 1); y++){ yearSel.options[i] = new Option(y, y); if (dp.year == y) yearSel.options[i].selected = true; i++; } } /* start creating calendar */ calTable = new Element('table'); calTableThead = new Element('thead'); calSelRow = new Element('tr'); calSelCell = new Element('th', {'colspan':'7'}); monthSel.injectInside(calSelCell); yearSel.injectInside(calSelCell); calSelCell.injectInside(calSelRow); calSelRow.injectInside(calTableThead); calTableTbody = new Element('tbody'); /* create day names */ calDayNameRow = new Element('tr'); for (var i = 0; i < dp.options.dayNames.length; i++) { calDayNameCell = new Element('th'); calDayNameCell.appendText(dp.options.dayNames[(dp.options.startDay+i)%7].substr(0, dp.options.dayChars)); calDayNameCell.injectInside(calDayNameRow); } calDayNameRow.injectInside(calTableTbody); /* create the day cells */ while (firstDay <= dp.options.daysInMonth[dp.month]){ calDayRow = new Element('tr'); for (i = 0; i < 7; i++){ if ((firstDay <= dp.options.daysInMonth[dp.month]) && (firstDay > 0)){ calDayCell = new Element('td', {'class':dp.id + '_calDay', 'axis':dp.year + '|' + (parseInt(dp.month) + 1) + '|' + firstDay}).appendText(firstDay).injectInside(calDayRow); } else { calDayCell = new Element('td', {'class':'dp_empty'}).appendText(' ').injectInside(calDayRow); } // Show the previous day if ( (firstDay == dp.oldDay) && (dp.month == dp.oldMonth ) && (dp.year == dp.oldYear) ) { calDayCell.addClass('dp_selected'); } // Show today if ( (firstDay == dp.nowDay) && (dp.month == dp.nowMonth ) && (dp.year == dp.nowYear) ) { calDayCell.addClass('dp_today'); } firstDay++; } calDayRow.injectInside(calTableTbody); } /* table into the calendar div */ calTableThead.injectInside(calTable); calTableTbody.injectInside(calTable); calTable.injectInside(dp.calendar); /* set the onmouseover events for all calendar days */ $$('td.' + dp.id + '_calDay').each(function(el){ el.onmouseover = function(){ el.addClass('dp_roll'); }.bind(this); }.bind(this)); /* set the onmouseout events for all calendar days */ $$('td.' + dp.id + '_calDay').each(function(el){ el.onmouseout = function(){ el.removeClass('dp_roll'); }.bind(this); }.bind(this)); /* set the onclick events for all calendar days */ $$('td.' + dp.id + '_calDay').each(function(el){ el.onclick = function(){ ds = el.axis.split('|'); dp.value = this.formatValue(dp, ds[0], ds[1], ds[2]); this.remove(dp); }.bind(this); }.bind(this)); /* set the onchange event for the month & year select boxes */ monthSel.onfocus = function(){ dp.active = true; }; monthSel.onchange = function(){ dp.month = monthSel.value; dp.year = yearSel.value; this.remove(dp); this.create(dp); }.bind(this); yearSel.onfocus = function(){ dp.active = true; }; yearSel.onchange = function(){ dp.month = monthSel.value; dp.year = yearSel.value; this.remove(dp); this.create(dp); }.bind(this); }, /* Format the returning date value according to the selected formation */ formatValue: function(dp, year, month, day){ /* setup the date string variable */ var dateStr = ''; /* check the length of day */ if (day < 10) day = '0' + day; if (month < 10) month = '0' + month; /* check the format & replace parts // thanks O'Rey */ dateStr = dp.options.format.replace( /dd/i, day ).replace( /mm/i, month ).replace( /yyyy/i, year ); dp.month = dp.oldMonth = '' + (month - 1) + ''; dp.year = dp.oldYear = year; dp.oldDay = day; /* return the date string value */ return dateStr; }, /* Remove the calendar from the page */ remove: function(dp){ $clear(dp.interval); dp.active = false; if (window.opera) dp.container.empty(); else if (dp.container) dp.container.remove(); dp.calendar = false; dp.container = false; $$('select.dp_hide').removeClass('dp_hide'); } });
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.