-
Posts
5,717 -
Joined
-
Last visited
-
Days Won
6
Everything posted by Adam
-
Err, PHP includes? Templates?
-
[SOLVED] script works but still get error message
Adam replied to kcp4911's topic in Javascript Help
Oh if that's the cause of the status 0, just turn your 'else' into an 'elseif': elseif (xmlhttp.status != 0) { alert("Error during AJAX call. Please try again"); } -
[SOLVED] script works but still get error message
Adam replied to kcp4911's topic in Javascript Help
Try alerting the status to actually see what the 'else' is catching: else { //alert("Error during AJAX call. Please try again"); alert('status is: ' + xmlhttp.status); } -
I can't imagine finding a script out there tailored to those needs, better searching for tutorials and articles. I'd read up on how to retrieve inputs first and then how to send basic emails. Once you're fairly confident with each shouldn't be tricky combining the knowledge.
-
There's nothing wrong with the syntax there. Show how you're outputting them both, including the echo / print statements. You can also check the source to find out exactly what you're getting.
-
You shouldn't have the 2 single quotes between the buttons.. '<button type="button" onclick="window.location=\'bookview.php?id='. $row['bookingref'].'&hn'. $row['hotelname'].'\'">Book Now</button><button type="button" onclick="window.location=\'bookview.php?id='. $row['bookingref'].'&hn'. $row['hotelname'].'\'">Book Now</button>' If you were to use a syntax highlighter, or learn string concatenation a little more you'll be able to correct these yourself.
-
Actually re-read the post a few times makes more sense now, though can't see why you'd think you'd use PHP for this? It's a JavaScript problem (and nothing to do with AJAX, priti). There's probably a variety of ways you could do this, here's a very rough demo of how it could be done: <html> <head> <script type="text/javascript"> function updateChecks() { var check = document.forms[0].elements['checkbox_name']; var check_count = 0; for (i = 0; i < check.length; i++) { if (check[i].checked == true) { check_count++; } } if (check_count >= 5) { document.getElementById('your_image').style.display = 'block'; // or 'inline' depending on element / desired position } else { document.getElementById('your_image').style.display = 'none'; } return true; } </script> </head> <body> <form> <input type="checkbox" name="checkbox_name" value="check1" onclick="updateChecks();" /> check1<br /> <input type="checkbox" name="checkbox_name" value="check2" onclick="updateChecks();" /> check2<br /> <input type="checkbox" name="checkbox_name" value="check3" onclick="updateChecks();" /> check3<br /> <input type="checkbox" name="checkbox_name" value="check4" onclick="updateChecks();" /> check4<br /> <input type="checkbox" name="checkbox_name" value="check5" onclick="updateChecks();" /> check5<br /> </form> <img src="img/my_image.jpg" alt="your Image" id="your_image" style="display: none;" /> </body> </html> Obviously you'll need to adapt this more to your needs but, should be a good starting point.
-
Ah my mistake, I went wrong too. I didn't actually know there was a "button" tag until now if I'm honest. Going with the w3schools syntax then: '<button type="button" onclick="window.location=\'results.php?id='. $row['proposalid'] . '\'">Book Now</button>'
-
[SOLVED] script works but still get error message
Adam replied to kcp4911's topic in Javascript Help
He's declared the "xmlhttp" variable globally, and the fact that the alert is only called once the readyState property == 4, means that can't be the problem. Obviously the problem is the HTTP status is not 200 / OK, possibily 404 / not found? Have you tried running the script without the AJAX layer? -
Excuse my possible ignorance, but why don't you just use the first version?? I can't say I understand why you're try to echo out the actual PHP code...
-
Giving a mixed image of what you're trying to achieve. Do you mean that you want to use *PHP* to display (or not) something on the page? Or do you want to use JavaScript to hide / show something as it's clicked?
-
You've actually got the syntax for an input button wrong, and the quotes were mixed up. Try this.. '<button type="button" onclick="window.location=\'results.php?id='. $row['proposalid'] .'\'" value="Book Now" />'
-
That's not exactly the best description, but do you mean filling with a pattern? To create a custom pattern you first need to define it. Pointless me trying to describe the process though when there's so many tutorials out there with good illustrations... http://www.google.co.uk/search?q=photoshop+how+to+create+patterns
-
The giant, stretched image doesn't do it any justice. Viewing on a 1280x1024 resolution the image is pixelated and stretched, more noticeably width ways. The contrast between the red text and the background makes reading a strain on the eyes. Despite the claim, neither the HTML or CSS validates (although there's only 4 errors for each). Generally in some areas it's improved, but others it's got worse. Before re-attempting this, I'd recommend reading up on 'common web design mistakes', web design techniques, color schemes, etc. Those kind of articles, or even stretch to a book if you can afford it, that should give you a better idea on how to structure the web site, how to use matching color schemes, give you ideas and so on.
-
There are other possibilities but, AJAX is actually the easiest option. That is if you still don't want the user to be redirected to another page?
-
[SOLVED] Extracting specific number of words from text
Adam replied to dpacmittal's topic in Regex Help
Mine? I have a working test of it. Albeit simple text, i weren't thinking about punctuation at the time. <?php $str = 'one two three four five six seven eight nine ten one two three four five six seven eight nine ten one two three four five six seven eight nine ten'; if (preg_match('#([\w]+\s?){0,30}#', $str, $matches)) { print $matches[0]; } ?> -
Needs it to be honest... Practice makes perfect!
-
[SOLVED] Extracting specific number of words from text
Adam replied to dpacmittal's topic in Regex Help
Try this: if (preg_match('#([\w]+\s?){0,80}#', $str, $matches)) { print $matches[0]; } Edit: Actually this would run into problems with characters such as quotes, commas, dots, etc. hmm -
Perhaps it's just the mark-up not correct. Take a look at: echo '<tr><td><input type="submit" name="SubmitForm" value="Send"></td></tr>'; Previously you've been spanning cols across 2, this doesn't. Also you're not closing the table.
-
$upload_count = 0; for ($i = 1; $i <= 5; $i++) { if (!empty($row['upload_' . $i])) { $upload_count++; } } echo 'you have uploaded ' . $upload_count . ' / 5 photos';
-
This is a pretty tight filtering method, superior to mysql_real_escape_string() ... addcslashes($str, "\x00\n\r\'\x1a\x3c\x3e\x25");
-
Sorry, I don't follow?
-
You mean you want to perform this in the background, without the page redirecting? If so, sounds like you want to look into "AJAX".
-
As far as I'm aware, Linux uses the same naming conventions for files and directories. You should generally just stick to the normal a-z 0-9 . _ - characters, to avoid any hassle. There are a select amount of special characters that can be used (I'm don't know what they are without digging them out), but to make life easier for yourself you should just stick those above. Take a look at this for more info.. http://lowfatlinux.com/linux-filenames.html Also with regard to MySQL support, that would depend up on the charset your database uses. If you're using UTF-8, you probably not going to run into problems.