Click On Button To Add Time To A Form Field In A Certain Format?
May 25, 2011
i am looking for a way to click on a button next to a time field that will paste the current date and time into that filed in this format: 01:00:00 08-08-2007 is that possible?
I wish to ammend it so that the time or h:m:s part is validated only if supplied (i.e. I wish to make the time part optional). At present if a time is not supplied the validation fails. I gather that the following part of the above expression
(20|21|22|23|[0-1]?d):[0-5]?d:[0-5]?d$
validates the time, however I don't know the syntax to make it optional.
my javascript code is only validating one field at a time (as in it validates on field then submits the form, instead of going through the entire thing and then returning it as true and submitting it...) I'm not sure what to do to be honest, I've looked up google to no real avail.. my variables are declared in a seperate file to the actual even handlers and I have heaps of comments through out it, so please don't judge lol i'm still learning Quote:
//Event Registrations (Variable Declarations) found in validation_chkr.js //Validate Entire Form using validate_join() function validate_join()
I am new to javascript (4 months), I would like to add an hour to the current time each time a button is clicked.
I have this code: var hourstbutton=document.getElementById("button3"); hoursbutton.onclick=function() { var divlink=document.getElementById("math3"); var newtime2=new Date(); var currenthours2=newtime2.getHours()+1; var currentmins2=newtime2.getMinutes(); var currentsecns2=newtime2.getSeconds(); var ampm2= (currenthours2>=12) ? "P.M." : "A.M."; if (currenthours2>=13) { currenthours2-=12; }if(currenthours2<1){ currenthours2=12; }if(currentmins2<10){ currentmins2= "0" + currentmins2; }if(currentsecns2<10){ currentsecns2="0" + currentsecns2; } divlink.innerHTML=currenthours2+":"+currentmins2+":"+currentsecns2+ " "+ampm2;
How do I tie the number of button clicks into the number of times this code is executed?
I'm trying to make buttons that change from one color to another when you click them and change back when you click them a third time. I wrote this page (http://cf.lehigh.edu/ems/test.html) but it only works on Firefox(Not IE or Chome, untested on safari or Opera). I'm using javascript to change the button colors. Is there another way to do this that works universal or another tool such as CSS?
I have a form that is using HTML and PHP to make calculations for an order form. One of the fields is asking for a total number of workstations. I would like this field to be a real-time total of five other fields in this form.
I wish to have my form update a text field when a 'add' link or button is clicked, allow for more entries to be added without having the page refresh. but i need to be able to have both the friends name and their number added to the field like so
if friends name is say 'jason' and their number is '0987654321' then it will add to the textarea like so.
jason [0987654321] this way i should be able to get the data and split it up when the form is send so i can add them in the DB. the part i am stuck on is how to get both fields in the textarea. allowing for more to be added without a refresh. can anyone suggest how they might do this.
I have a problem in getting database query result to text field when button was clicked. So far I have two php files, one used to connect database and save the database query value to a variable. The second php file used to create the buttons and text field.
code for dbconnection.php [code] $con_str = "host=jojo1234 port=3214 dbname=postgres user=postgres password=postgres"; $con = pg_connect("$con_str") or die('Could not connect: ' . pg_last_error()); $queryresult1 = pg_query($query1); $result11=array_sum(pg_fetch_array($queryresult1)); [code]
I am trying to produce a web form to allow wedding guests to RSVP. The form allows them to enter a name and select from a radio button whether they will be attending or not. If they select the "yes" radio button then a further pair of radio buttons are displayed for their meal preference.
They can then click a submit button or they can click another button to add another line for another guest which operates in exactly the same way. I've almost got this working, but it seems that the checkbox change handler is lost for the current guest when a new guest is added and the checkbox value is reset. I've got a feeling I'm doing something stupid but can't for the life of me figure out what.
Code (source file (renamed to .txt) also attached as I'm not sure the pasted code is too clear):
I am doing donation script. Here is my script so far
<script type="text/javascript"> <!--// function chkDonation(){ var form = document.forms[0]; // FORM NAME OR PLACE IN FORMS COLLECTION //; var amount = form['OtherAmount']; // TARGETTED INPUT NAME ( OtherAmount ) //; amount.style.visibility = 'hidden'; for(var i=0, input=form.getElementsByTagName('input'); i<input.length; i++){ if(input[i].type.match(/radio/i) && input[i].name.match(/DonationAmount/i)){ if(input[i].value.match(/Other/i)){ input[i].onclick = function(){ amount.style.visibility = 'visible'; .....
I have pretty much completed my script but now what I want it to do is to add more forms/field when the "Other" radio button is selected. So when the Other button is checked, I want the script to display more fields/forms below. Only when the "other" button is selected. When "other" selected the script should display fields like "cheque", "cash", "Payment" etc.
I've seen other posts regarding the reformatting of a military time format to a regular/standard time format but nothing has worked so far. I'm pulling events from Google Calendar, have set the date properly but not the correct time format (20:00 needs to be changed to 8:00pm). Here's my code thus far:
Does JavaScript have an easy of converting an ordinary integer like 135 into a time format like 02:15? I'm working on a timer that handles the backend with just a plain integer that counts down every second but it needs to output looking like a clock.
I have the function below to check the user input for time format. I need to modify the reg expression to NOT allow this format (hh:mmAM/PM). I want to force the user to add a space between the (mm) and (AM/PM)(hh:mm AM/PM) instead of (hh:mmAM/PM).
function checkAccessTime(time) { if (time.value != '') { if (!/^(1[0-2]|0?[1-9]):[0-5]d ?[ap]m$/i.test(time.value)) { alert('Enter a valid time format hh:mm AM/PM'); time.focus(); time.select(); return false; } return true; } else return true; }
I have a popup window, and in that window i have some links
my question its:
then i click one of the link its have to copy in a form in a text field to anothersite. its the site there i get the popup..
1. have a site whit a form there are some text field and one of the field have a link to popup.
2. then i get popup and in the popup there are some links. so then i click on link, its have to copy this linie / Text then i click on it, its have to copy into the field in site"not popup site" the site there i have the form.
I have an admin page in which I enter information for a Math Education website. I have to pre-load 10 video fields just in case a lesson has 10 videos. This is an over simplification:
[Code]...
What I would like to do is load 1 single video field and then have a button that when it is clicked automatically creates another field. I'm sure this is possible but everything I know I've learned from searching the internet and reading a few simple books so my knowledge is fragmented.
I'm only validating one (Consent) radio button with this code but I need to validate multiple different questions/buttons.
<script> function getRBtnName(GrpName) { var sel = document.getElementsByName(GrpName); var fnd = -1; var str = ''; for (var i=0; i<sel.length; i++) { if (sel[i].checked == true) { str = sel[i].value; fnd = i; } } return fnd; }
function checkForm() { var chosen = getRBtnName('Consent'); if (chosen < 0) { alert( "Please choose one answer when you are asked to select a number." ); return false; } else { return true; } }
</script> <form action="congratulations_aff.php" method="post" name="congratulations_aff" onSubmit="return checkForm()"> <table border="0" cellspacing="1" cellpadding="0"> <tr> <td colspan="3">I consent to providing my electronic signature.</p></td> </tr> <tr> <td colspan="3" valign="top"> <input type="radio" name="Consent" value="Y" /> Yes <input type="radio" name="Consent" value="N" /> No
<table border="0" cellspacing="1" cellpadding="0"> <tr> <td>I consent to electronic receipt of my information reporting documentation.</td> </tr> <tr> <td valign="top"> <input type="radio" name="Consent1099YesNo" value="Y" /> Yes <input type="radio" name="Consent1099YesNo" value="N" /> No</td> </tr> <tr> <td valign="top">
For tax purposes are you a U.S. citizen, U.S. resident, U.S. partnership, or U.S. corporation? <input type="radio" name="USPersonYesNo" value="Y" /> Yes <input type="radio" name="USPersonYesNo" value="N" /> No </tr> </table> <input type="submit" value="submit" value="Submit" /> </form>
I have a form that makes visible a text field when a specific radio button is checked. That works. Then I validate to see if a radio button is checked before I let the form be submitted. That works.
BUT - I cannot seem to get it to validate the form field that is made visible to see if it has content or at least the proper content when the form is submitted. Can you tell me what I am doing wrong please?
I can give more info on what kind of validation I want done if needed, but I think my code speaks for itself Code: