Jump to content

mrsquash

Members
  • Posts

    21
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Male

mrsquash's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. Well, after messing around with this for the better part of a day I finally got it working! This script will allow you to calculate future dates based on an entered date and how many days form that date you want to count. If the day/month/year fields are left blank the script will default to today. <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <head> <title>Calculator:</title> <SCRIPT language="JavaScript"> <!-- Begin function AddDays(DateCalculator) { DaysToAdd=document.DateCalculator.DaysToAdd.value; InputMonth=document.DateCalculator.month.value; InputDay=document.DateCalculator.day.value; InputYear=document.DateCalculator.year.value; var now=new Date(); var newdate=new Date(); var inputdate = new Date(InputYear, InputMonth-1, InputDay) if (document.DateCalculator.month.value != "" && document.DateCalculator.day.value !== "" && document.DateCalculator.year.value !== "") { var newtimems=inputdate.getTime()+(DaysToAdd*24*60*60*1000); } if (document.DateCalculator.day.value == "" && document.DateCalculator.month.value == "" && document.DateCalculator.year.value == "") { var newtimems=newdate.getTime()+(DaysToAdd*24*60*60*1000); } newdate.setTime(newtimems); document.DateCalculator.display.value=newdate.toLocaleString(); } function resetForm() { document.DateCalculator.reset(); document.DateCalculator.day.value=""; document.DateCalculator.month.value=""; document.DateCalculator.year.value=""; document.DateCalculator.DaysToAdd.value=""; document.DateCalculator.display.value=""; } // End --> </SCRIPT> </head> <body> <center> <table> <form name=DateCalculator> <tr> <td>Start Date:</td> <td><input type=text name=month size=2 maxlength="2" value="">-<input type=text name=day size=2 maxlength="2" value="">-<input type=text name=year size=4 maxlength="4" value=""></td> </tr> <tr> <td>Number of Days:</td> <td><input type=text name=DaysToAdd size=5 value=""></td> </tr> <tr> <td> </td> <td><input type=button value="Calculate" align="center" onClick="AddDays(this.form)"></td> </tr> <tr> <td>Calculated Date:</td> <td><input type=text name="display" size=35 value=""></td> </tr> <tr> <td><a href="javascript:resetForm()">RESET</a></td> <td></td> </tr> </form> </table> </center> </body> </html>
  2. Okay, i modified my Javascript a little bit and I'm not getting any errors, but I'm also not getting my desired result. <SCRIPT language="JavaScript"> <!-- Begin function AddDays(DateCalculator) { DaysToAdd=document.DateCalculator.DaysToAdd.value; InputMonth=document.DateCalculator.month.value; InputDay=document.DateCalculator.day.value; InputYear=document.DateCalculator.year.value; var now=new Date(); var newdate=new Date(); var inputdate = new Date(InputYear, InputMonth-1, InputDay) if (document.DateCalculator.month.value != "" && document.DateCalculator.day.value !== "" && document.DateCalculator.year.value !== "") { var newtimems=inputdate.getTime()+(DaysToAdd*24*60*60*1000); } if (document.DateCalculator.month.value = "" && document.DateCalculator.day.value == "" && document.DateCalculator.year.value == "") { var newtimems=newdate.getTime()+(DaysToAdd*24*60*60*1000); } newdate.setTime(newtimems); document.DateCalculator.display.value=newdate.toLocaleString(); } // End --> </SCRIPT>
  3. Hello all, What I'm trying to do seems simple but I just can't get it right. I have a simple form that allows the user to type in a date. I then have the user select how many days from that date he wants to calculate, and then of course the output. I'm having a problem taking the form fields for month/day/year and putting them into a javascript variable to calculate the new date. I also want to to default to 'today' if no date information is added in the form. Below is my code: <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <head> <title>Calculator:</title> <SCRIPT language="JavaScript"> <!-- Begin function AddDays(DateCalculator) { DaysToAdd=document.DateCalculator.DaysToAdd.value; InputMonth=document.DateCalculator.month.value; InputDay=document.DateCalculator.day.value; InputYear=document.DateCalculator.year.value; var now=new Date(); var newdate=new Date(); var inputdate=(InputDay.InputMonth.InputYear); if (document.DateCalculator.month.value != "" && document.DateCalculator.day.value !== "" document.DateCalculator.year.value !== "") { var newtimems=inputdate.getTime()+(DaysToAdd*24*60*60*1000); return; } if (document.DateCalculator.month.value = "" && document.DateCalculator.day.value == "" document.DateCalculator.year.value == "") { var newtimems=inputdate.getTime()+(DaysToAdd*24*60*60*1000); return; } newdate.setTime(newtimems); document.DateCalculator.display.value=newdate.toLocaleString(); } // End --> </SCRIPT> </head> <body> <center> <table> <form name=DateCalculator> <tr> <td>Start Date:</td> <td><input type=text name=month size=2 maxlength="2" value="">-<input type=text name=day size=2 maxlength="2" value="">-<input type=text name=year size=4 maxlength="4" value=""></td> </tr> <tr> <td>Number of Days:</td> <td><input type=text name=DaysToAdd size=5 value=10></td> </tr> <tr> <td> </td> <td><input type=button value="Calculate" align="center" onClick="AddDays(this.form)"></td> </tr> <tr> <td>Calculated Date:</td> <td><input type=text name="display" size=35 value=""></td> </tr> </form> </table> </center> </body> </html>
  4. Hello all, I am having some difficulty when trying to call an INFORMIX stored procedure with PHP. I have verified that the if() condition is true and all of the parameters I am passing are valid. However, when I run the following: Connection if (!$connect_id = ifx_connect("$database@$host", $user, $pass)) { // THE ACTUAL CONNECTION echo "Unable to connect to Informix Database\n"; // DISPLAY IF CONNECTION FAILS exit(); } Calling the procedure if ($num_rows > 0 && $barcode_id == "") { echo "The query found ".$num_rows." row(s)"; $call_procedure = ifx_prepare("CALL informix.updt_brcd_id_req($case, $event_date, $event_sequence, $event_code)", $connect_id); $call_result = ifx_do($connect_id, $call_procedure); } I get these Errors: PHP Warning: ifx_prepare() [function.ifx-prepare]: Prepare fails (E [sqlSTATE=42 000 SQLCODE=-201]) PHP Warning: Wrong parameter count for ifx_do() I have looked all over the web but i cannot find a solution. ny help is appreciated.
  5. I'm pretty sure you cannot break into <?php ?> within your <script></script> tags. You need to do something like this: <html> <head> <script language="JavaScript"> <!-- function validate() { var u = document.my_form.hide_user.value; var p = document.my_form.hide_pass.value; if (document.my_form.user_name.value != u) { alert("Please enter the correct username"); document.my_form.user_name.focus(); return; } if (document.my_form.password.value != p) { alert("Please enter the correct password"); document.my_form.password.focus(); return; } } //--> </script> </head> <body> <?PHP $user='hani'; $pass='annd'; ?> <form name="my_form" action="" method="post" enctype="multipart/form-data"> <input type="hidden" name="hide_user" value="<?php echo $user; ?>"> <input type="hidden" name="hide_pass" value="<?php echo $pass; ?>"> Username: <input type="text" name="user_name" value="" size="10"> Password: <input type="text" name="password" value="" size="10"> <a href="javascript:validate()" title="Submit" tabindex="65">Submit</a> </form> </body> </html>
  6. I was under the impression that to get it to work with Internet Explorer you had to create a new element and remove the old element. Okay, I changed it to this: My button set: <input type="radio" tabindex="49" name="suspended" value="Y" onclick="javascript:showDate();"><span class="small">Yes</span> <input type="radio" name="suspended" value="N" /><span class="small">No</span> My input element I want to update: <input type="hidden" tabindex="50" value="" size="10" maxlength="25" name="suspend_date" id="1"> My javascript function to update the element: function showDate() { document.getElementById('1').type = 'text'; } And it gives me the following: Could not get the type property. This command is not supported.
  7. So something like this? function showDate(id) { document.getElementById('id').type = 'text'; var newObject = document.createElement('input'); newObject.type = "text"; if(oldObject.size) newObject.size = oldObject.size; if(oldObject.value) newObject.value = oldObject.value; if(oldObject.name) newObject.name = oldObject.name; if(oldObject.id) newObject.id = oldObject.id; if(oldObject.className) newObject.className = oldObject.className; oldObject.parentNode.replaceChild(newObject,oldObject); return newObject; }
  8. I have a radio button group on my form. When one of the buttons is selected I am using an "onclick" event to call a function. I want this function to change the input type of a text field from hidden to text. I keep getting an error message that parentNode is null or not an object. Below is my code. Any ideas? My button set: <input type="radio" tabindex="49" name="suspended" value="Y" onclick="javascript:showDate('suspend_date', 'hidden');"><span class="small">Yes</span> <input type="radio" name="suspended" value="N" /><span class="small">No</span> My input element I want to update: <input type="hidden" tabindex="50" value="" size="10" maxlength="25" name="suspend_date"> My javascript function to update the element: function showDate(oldObject, oType) { var newObject = document.createElement('input'); newObject.type = "text"; if(oldObject.size) newObject.size = oldObject.size; if(oldObject.value) newObject.value = oldObject.value; if(oldObject.name) newObject.name = oldObject.name; if(oldObject.id) newObject.id = oldObject.id; if(oldObject.className) newObject.className = oldObject.className; oldObject.parentNode.replaceChild(newObject,oldObject); return newObject; }
  9. post your code so we can see what you are doing.
  10. I think I must be saying something incorrect. I think we're on different levels. I have a .js file that contains a lot of common form validation checks that will be used on every page. I also have additional form validation checks that are unique to every page. I want to include the external .js file with the common functions onto each page and when a user submits the form, I want it to run through all of the common validation checks and once it is finished with those, jump straight into the unique validation checks. Common checks - contained in the external .js file Unique checks - coded into the <head></head> of each page
  11. I'm not exactly sure if this is what you're asking, but I would remove your "submit" button and just have a regular button or link that first performs your function checks and then the last line of your function can pass the submit value to the page for processing. Something like this: <html> <head> <script language="JavaScript"> <!-- function validate_form() { // Verifies that the first name was entered if (document.my_form.first_name.value == "") { alert("Please enter in a first name."); document.my_form.first_name.focus(); return; } // Verifies that the last name was entered if (document.my_form.last_name.value == "") { alert("Please enter in a last name."); document.my_form.last_name.focus(); return; } // Tells the submit what action to take document.my_form.action='doadduser.php'; // Submits the form document.my_form.submit() } //--> </script> </head> <body> <form> <form name="my_form" action="" method="post" enctype="multipart/form-data"> ALL YOUR FORM CODE HERE <table align="center" border="0" cellpadding="0" cellspacing="0" width="680"> <tr> <td width="64" align="left"><a href="javascript:validate_form()" title="Save">Save</a></td> </tr> </table> </form> </body> </html> I personally like to put the checks within my function, instead of having multiple functions and then calling them all from within another function. But, overall I think your problem might be that you are telling the form to submit (by using a submit button) before you are telling it to perform the checks...so, change the type from a submit to a regular button and have that button link(call) your form validation function. Then have that function perform the submit for you once all checks are complete. Hope that helps.
  12. Okay, but say I have 15 checks that will be used across ALL forms. And then I have 5 unique checks for each inidivual form. I would want to reuse the 15 checks to cut down on rekeying code of course but if I included the whole thing from the start I would end up with a lot of scripts to accomplish mostly the same thing...which would defeat the purpose, right? Is it possible to include the file with the common checks, then at the end of the common checks have it call a function that checks the specific fields for the page? Something like: <script language="JavaScript"> // Run a page specific function function help() { alert("Please select the appropriate Type."); return; } // Include the generic form checks src="../my/generic/form/checks.js" // At the end of the generic form checking function call on this function function spcific() { alert("Please select the appropriate Application Type."); return; } </script>
  13. Hello! I have a site that contains numerous forms. Within each form there is a common area that contains customer information (name/address/zip etc) I have written a series of javascript checks that will verify all of these fields have been filled out correctly...after I have verified these fields are correct my page should continue on to the FORM SPECIFIC field checks. My question is how should I go about including my common field checks and then have it continue with th epage specific checks? Can I do something like: function checkForm() { // ** START ** // Include the file with the common javascript checks src="../path/to/included/javascript" // Perform a request specific check if (myform.myfield.value == "") { alert( "Please enter some information." ); myform.myfield.focus(); return; } } Or is there antoher method I have to use to accomplish this?
  14. Wow, if anyone has a "Stupid" stamp, please apply it to my forehead! The code I had was correct...I just didn't notice a missing letter in my form name...sigh
  15. But, since they are the same object name, only one can be checked at a time, if I use a logical or || that would mean it would display the error all the time since only one option can be checked at a time, correct?
×
×
  • 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.