Psycho
Moderators-
Posts
12,157 -
Joined
-
Last visited
-
Days Won
129
Everything posted by Psycho
-
<html> <head> <script type="text/javascript"> function validate(formObj) { if (formObj.password_1.value != formObj.password_2.value) { alert('The passwords do not match!'); return false; } else { alert('The passwords Match. Good job.'); return true; } } </script> </head> <body"> <form name="theform" onsubmit="return validate(this);"> Password: <input type="password" name="password_1"><br> Confirm: <input type="password" name="password_2"><br> <button type="submit">Submit</button> </form> </body> </html>
-
After taking some time to reverse-engineer the code, here is all you need to center a div on the page: #content { position: absolute; left: 50%; width: 250px; margin-left: -125px; top: 50%; height: 70px; margin-top: -35px; } If you need a differnt size div, just ensure the margins are negative values for 1/2 the width and height.
-
Change this: foreach ($_POST as $key => $value) { $msg .= ucfirst ($key) ." : ". $value . "\n"; } To this: $msg .= $_POST['Url'] . "\n";
-
how can js. "recall form fields" work with new php form?
Psycho replied to zanzibar's topic in Javascript Help
There is no way for us to answer your question. This: CreateTextRow("First Name", "first_name", 3, 56, true); appears to be a function that takes 5 parameters and creates a text field. I assume the first parameter is the label, the second is the field name. For the other three I have no idea. It would be best to handle the "persistent" data in PHP. But, you could probably take a look at that function and find a way to add a 6th parameter that would add class="memorize" within the function. -
You need to correct your loop so that each element has a unique name and ID. Assuming each record has a unique ID, this should work: <form name="form"> <table border="0" align="center" cellpadding="0" cellspacing="0"> <?php do { ?> <tr> <td><div align="right">Subject :</div></td> <td><span class="style8"><?php echo $row_rscategories['subject']; ?></span></td> </tr> <tr> <td><div align="right">Category :</div></td> <td><?php echo $row_rscategories['category']; ?></td> </tr> <tr> <td valign="top"><div align="right">Note :</div></td> <td><textarea name="template<?php echo $row_rscategories['id']; ?>" cols="60" rows="7" class="inputtextarea" id="template<?php echo $row_rscategories['id']; ?>" readonly="readonly" onKeyDown="limitText(this.form1.template<?php echo $row_rscategories['id']; ?>,this.form1.countdown,1000);" onKeyUp="limitText(this.form1.notes,this.form1.countdown,1000);"><?php echo $row_rscategories['template']; ?></textarea> </td> </tr> <tr> <td colspan="2" align="right"><input type="button" class="inputbox" value="Copy To Clipboard" onclick="copy(document.form.template<?php echo $row_rscategories['id']; ?>.value);"> | <?php echo $row_rscategories['status']; ?> Note - <a href="templates_edit.php?recordID=<?php echo $row_rscategories['id']; ?>">Edit</a></td> </tr> <tr> <td colspan="2"><hr /></td> </tr> <?php } while ($row_rscategories = mysql_fetch_assoc($rscategories)); ?> </table> </form>
-
Although there are a lot of things I would change in that functionality, your problem has to do with your declaration of window.onload. You define two different functions for window.onload window.onload=function(){ setInterval("displaytime()", 1000) } window.onload = function(){ ConvertRowsToLinks("tablem"); } The second will overwrite the first. You need to define both within window.onload: window.onload=function() { ConvertRowsToLinks("tablem"); setInterval("displaytime()", 1000) }
-
You don't need Javascript to center an element - just CSS. Take a look at the code on this page. Even when I modified the code to be long enough that the page scrolled, the box still apppeared in the center of the visible page. http://www.wpdfd.com/editorial/thebox/deadcentre4.html
-
An example of what? Where is your code for defining the variables such as $home? I have no clue as to your datasse structure or design. Assuming these values are contained within a table with a single record (each column in the table represents a different value above). And, I will assume that the column (field) names in the table are exactly the same as the variable names above. <?php //Connect to the database server $link = mysql_connect('localhost', 'mysql_user', 'mysql_password'); if (!$link) { die('Could not connect: ' . mysql_error()); } //Select the database mysql_select_db("my_db", $link) or die('Could not connect to db: ' . mysql_error()); //Query the database $query = "SELECT * FROM `table'"; $result = mysql_query($query) or die('Error running query: ' . mysql_error()); //Get the results $record = mysql_fetch_assoc($result); //Puts the result values into variables with same names as the field names ectract($record); ?> <!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>Dr. Michael D. Doyle | Payment Information</title> <link rel="stylesheet" href="content_management.css" TYPE="text/css" /> </head> <body> <div id="container"> <h3>Michael D. Doyle Content Management System</h3> <div id="form_wrapper"> <form method="post" action="put.php"> <div><label for="index">Homepage</label><textarea name="home" rows="15" cols="70" ><?php echo $home ?> </textarea></div> <div><label for="mot">Meet Our Team</label><textarea name="mot" rows="15" cols="70" ><?php echo $mot ?> </textarea></div> <div><label for="pf">Patient Forms</label><textarea name="pf" rows="15" cols="70" ><?php echo $pf ?> </textarea></div> <div><label for="fi">Financial Information</label><textarea name="fi" rows="15" cols="70" ><?php echo $fi ?> </textarea></div> <div><label for="loc">Locations</label><textarea name="loc" rows="15" cols="70" ><?php echo $loc ?> </textarea></div> <div><label for="con">Contact</label><textarea name="con" rows="15" cols="70"><?php echo $con ?> </textarea></div> <div><label for="ms">Mission Statement</label><textarea name="ms" rows="15" cols="70" ><?php echo $ms ?> </textarea></div> <div><label for="dis">Disclaimer</label><textarea name="dis" rows="15" cols="70" ><?php echo $dis ?> </textarea></div> <div class="actions"><input type="submit" name="submit" value="Submit Content" class="submit"/></div> </form> </div> </div> </body> </html>
-
That looks fine. The problem is probably in the code you have to declare those variables - which you did not provide.
-
You also need to factor in leap years. What format is the input date in?
-
1. Why on earth would you want to use JavaScript for site navigation? Doing so would render the site completely useless to anyone without javascript enabled and/or anyone with a browser with compatibility issues. 2. The page isn't even properly formatted. It starts out like this: <form action='includethis.php'> <input type='hidden' name='email' size='26' value='Enter your email' onfocus="this.value=''"> <input type='hidden' value='Subscribe'> <input type='hidden' name='action' value='subscribe'> </form> <head> <meta http-equiv="Content-Language" content="en-us" /> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> Why is there a "form" before the page has even been declared and there is no opening HTML tag. I tried to debug the code you provided and the code on your site. But, the tabs seem to be created dynamically in the JavaScript and I wasn't able to ascertain which function is called or what parameters are sent.
-
A few things: 1. No need to pass the form ID to the function. Instead, use 'this' to pass the form object. Then you don't need to create the form object using var form = document.getElementByID(elementID); 2. This if statement is part of your problem if(form.element[i].value == null || "") Instead you need to use this: if(form.element[i].value == null || form.element[i].value == "") 3. Also, iterrating through each element is probably not a good idea, because ANY element in the form would be validated, such as the submit button. It is better, in my opinion, that you explicitly validate each field that needs to be validated 4. Here is a better email validation script: function validEmail(emailStr) { //Return true/false for valid/invalid email formatTest = /^[\w`\-=~!#$%^&*'+{}|'/?]+(\.[\w`\-=~!#$%^&*'+{}|'/?]+)*@[-a-z\d]{2,}(\.[-a-z\d]{2,})*\.[a-z]{2,6}$/i lengthTest = /^(.{1,64})@(.{4,255})$/ return (formatTest.test(emailStr) && lengthTest.test(emailStr)); } Here is what I would do: function valitadeForm(formObj) { var isComplete = true; for(var i=0;i<formObj.lenght;i++) { switch(formObj.element[i].name) { case 'field1name': case 'field2name': case 'field3name': case 'field4name': if (emptyField(formObj.element[i].value)) { formObj.element[i].value = "Falta Rellenar Campo"; isComplete = false; } break; case 'email': if (!validEmail(formObj.element[i].value)) { formObj.element[i].value = "E-mail Incorrecto"; isComplete = false; } break; } } return isComplete; } function emptyField(fieldValue) { //Trim white-space characters from the value var trimmedValue = fieldValue.replace(/^\s+|\s+$/g,''); return (trimmedValue == ""); } <FORM id="addcomment" method="POST" enctype="application/x-www-form-urlencoded" action="?go=addcomment" onsubmit="return validateForm(this)">
-
function getAge(bDateStr) { var today = new Date(); var tDay = today.getDate(); var tMonth = today.getMonth(); var tYear = today.getFullYear(); var bDateAry = bDateStr.split('-'); var bDay = bDateAry[0]; var bMonth = bDateAry[1]-1; var bYear = bDateAry[2]; var age = (tYear - bYear); if (bMonth>tMonth || (bMonth==tMonth && bDay>tDay)) { var age = tYear - bYear - 1; } return age; }
-
It can only be done with JavaScript if you want the image to reset for each page load. If you want the image to grow based upon ALL user clicks, then JavaScript will not work.
-
There is no definitive "list" of effects. Many other effects could be created based upon the programmers imagination and the capability of the platform. A better question would be to explain the effect you want and if/how it can be achieved.
-
Those results make sense. With a group by, you get a count for each group. So the first query (with the group by) was returning multiple records. When the group by was removed you were returning one record of the total count. Example Data id | name a | Bob b | Jim a | Dave c | Mary a | Alice c | Rob d | Mike This query SELECT COUNT(*) FROM table GROUP BY id Would return: 3 (for the a records) 1 (for the b records) 2 (for the c records) 1 (for the d records) This query SELECT COUNT(*) FROM table Would return: 7
-
I agree with Nightslyr, but to answer your question as to why your original code didn't work, I suspect it is because of this line: temp = "" + field.substring(i, i+1); That will actually grab TWO characters and not ONE such as you are testing against.
-
[SOLVED] deleting records using javascript function
Psycho replied to kundan's topic in Javascript Help
No. PHP is server-side and JavaScript is client-side. The only way to get them to interact (that I know of) is with AJAX. And, by "deleting a record in PHP" I am assuming you are referring to database records. Because PHP doesn't store records. -
Um, okay . . . That's a pretty well known JavaScript function. You can also go forward in the browser history using a positive integer (assuming the user, or javascript, has gone back in the history)
-
Try this: window.opener.document.Form['Unit[]'].value = Item;
-
I asked you to post the "the actual HTML code that is generated", i.e. when you bring the page up in your browser, right-click and view source. Then cut and paste the HTML code for that link.
-
This function siteloklogout() is probably returning some character(s) that are fouling up the HTML code. Post the actual HTML code that is generated for that link.
-
There are many, many posts with the same questin in this forum. But. I'll reiterrate the basics. The onsubmit action should go in the form tag, not the submit button tag. A user can submit a form by pressing the eneter key and that would bypass the onsubmit trigger if put in the submit button. The current functionality you have would require ALL fields to have input. You don't state if all fields are reuired. I always prefer to explicitly check the fields that need to be checked. Here's how I would do this: <html> <head> <style> .error { color: #ff0000; } </style> <script type="text/javascript"> function validate_form(formObj) { var errors = new Array(); if (!formObj.uname.value) { errors[errors.length] = 'Name is required.'; } if (!formObj.address.value) { errors[errors.length] = 'Address is required.'; } if (!formObj.email.value) { errors[errors.length] = 'Email is required.'; } else if (!validEmail(formObj.email.value)) { errors[errors.length] = 'Email is not a valid format.'; } //There were errors if (errors.length>0) { var errorMsg = 'The following errors occured:'; for (var i=0; i<errors.length; i++) { errorMsg += '\n - ' + errors[i]; } alert(errorMsg); return false; } } function testEmail(fieldObj) { if (!validEmail(fieldObj.value)) { fieldObj.focus(); fieldObj.select(); alert('The email addred is not in a valid format.'); return false; } return true; } function validEmail(emailStr) { //Return true/false for valid/invalid email formatTest = /^[-\w+]+(\.[-\w+]+)*@[-a-z\d]{2,}(\.[-a-z\d]{2,})*\.[a-z]{2,6}$/i lengthTest = /^(.{1,64})@(.{4,255})$/ return (formatTest.test(emailStr) && lengthTest.test(emailStr)); } </script> </head> <body> <form name="test" onsubmit="return validate_form(this);"> <b>Please fill out the form:</b> <br /> <span class="error">*</span> required fields <br /><br /> <span class="error">*</span> Name: <input type="text" name="uname"><br /> <span class="error">*</span> Address: <input type="text" name="address"><br /> Phone: <input type="text" name="phone"><br /> <span class="error">*</span> Email: <input type="text" name="email" onblur="testEmail(this);"><br /> <br /> <button type="submit">Submit</button> </form> </body> </html>
-
I don't think you can submit from one browser window to another like that. An alernative approach would be to have a hidden for in the parent page. When the user "submits" the child window page it runs a script that will populate the values of the child window form into the parent window form, then calls a function in the parent which closes the child window and submits the form in the parent.
-
If I am understanding you correctly you just want links that jump to a part of the page. No need for javascript here, just use regular HTML with anchors. http://www.w3schools.com/TAGS/tryit.asp?filename=tryhtml_link_bookmark