JavaScript - Send Form Request To A Second File
Hi; I have three files login.php, process.php and catcher.php. The first one contain the form, the second file is the form action and the last is a second file which must receive the form request as well but not getting redirected to it.
login.php content : PHP Code: <form action="process.php" method="post"> <input type="text" name="userid"> <input type="password" name="userpwd"> <input type="submit" value="Submit"> </form> So I want the user who click on the Submit button get redirected to process.php as usual and at the seem time send a copy of the request into catcher.php. I am thinking for a hidden iframe but don't know how to de it. Regards Similar TutorialsHI there.. Can you please give me code in JavaScript to create a student request form for book request from issue section of college Library.. Please help with code... Thanx in advance... Regards, How come the below code is not woring for me? when someone comments on my facebook comments plugin I want to get an email. This is what i have Code: <!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> </head> <body> <div id="fb-root"></div> <script> window.fbAsyncInit = function() { FB.init({ appId : '220041184732123', // App ID channelUrl : '//http://www.corkdiscos.com/channel.html', // Channel File status : true, // check login status cookie : true, // enable cookies to allow the server to access the session xfbml : true // parse XFBML }); FB.subscribe('comment.create', function(response){ // Here you need to do a call to some service/script/application // to notify your administrator about new comment. // I'll use jQuery ajax to call server-side script to illustrate the flow $.post('mail.php', { "action": "comment created", "url_of_page_comment_leaved_on": response.href, "id_of_comment_object": response.commentID }); }); }; // Load the SDK Asynchronously (function(d){ var js, id = 'facebook-jssdk'; if (d.getElementById(id)) {return;} js = d.createElement('script'); js.id = id; js.async = true; js.src = "//connect.facebook.net/en_US/all.js"; d.getElementsByTagName('head')[0].appendChild(js); }(document)); </script> <div class="fb-comments" notify="true" data-href="http://www.corkdiscos.com/testimonials.html" data-num-posts="30" data-width="544"></div> </body> </html> I then have this php code to send me a mail in a mail.php file PHP Code: <?php $admin_email = 'corkdjs@gmail.com'; $commentID = $_REQUEST['id_of_comment_object']; $page_href = $_REQUEST['url_of_page_comment_leaved_on']; $message = "hello"; mail($admin_email, You have a new comment", $message); ?> what could be wrong and is there anyone that knows how to fix this to make it work? I have the following JavaScript (see below). The script requests an XML file from the server and displays it on the page. The script works fine when the requested XML file is stored on the same server as the script. The problem is when I try requesting an XML file from an external server such as the National Weather Service. I get an error. If I take the XML file from the National Weather Service and save it to my server it works. Why can't I use my script to request XML files stored on external servers? Thanks in advance for any help. Javascript Code Code: window.onload = initAll; var xhr = false; function initAll() { document.getElementById("makeTextRequest").onclick = getNewFile; document.getElementById("makeXMLRequest").onclick = getNewFile; } function getNewFile() { makeRequest(this.href); return false; } function makeRequest(url) { if (window.XMLHttpRequest) { xhr = new XMLHttpRequest(); } else { if (window.ActiveXObject) { try { xhr = new ActiveXObject("Microsoft.XMLHTTP"); } catch (e) { } } } if (xhr) { xhr.onreadystatechange = showContents; xhr.open("GET", url, true); xhr.send(null); } else { document.getElementById("updateArea").innerHTML = "Sorry, but I couldn't create an XMLHttpRequest"; } } function showContents() { if (xhr.readyState == 4) { if (xhr.status == 200) { if (xhr.responseXML && xhr.responseXML.contentType=="text/xml") { var outMsg = xhr.responseXML.getElementsByTagName("choices")[0].textContent; } else { var outMsg = xhr.responseText; } } else { var outMsg = "There was a problem with the request " + xhr.status; } document.getElementById("updateArea").innerHTML = outMsg; } } HTML Code Code: <!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> <title>My First Ajax Script</title> <script type="text/javascript" src="script01.js"></script> </head> <body> <p><a id="makeXMLRequest" href="http://www.weather.gov/xml/current_obs/KOJC.xml">Request an XML file</a></p> <div id="updateArea"> </div> </body> </html> Hello I'd like to open using JS an outlook send mail window having a file from the server (full url, that should work, right ?) attached. Is this possible ? If so, please tell me how. Thanks Hi all. I have a form that I am writing which needs to send information contained inside a textbox when the user presses the "Post Comment" button. I want it be sent as a parameter to the addComment() function. How can you do this??? I have been trying to figure it out for a while now but can't seem to get the syntax right. This is what my code looks like currently. If possible I would like this to work without referencing the name of this form. Code: <form method="post" name="form" action="" style="padding:0px; margin:0px;"> <textarea name="content" id="content" style="width:600px; height:114px; font-family:Verdana,Arial,Tahoma,Times New Roman; font-size:12px; border:1px #666 solid;" onFocus="this.value=''; this.onfocus=null;">Enter your comment...</textarea><br /> <input type="submit" value="Post Comment" id="v" name="submit" onclick="addComment(this.content.value);" /> <span id="wait"></span><span id="flash"></span> </form> Is it possible to use JavaScript to send a HTML FORM this way? (By the way, this is a huge guess - I don't know JavaScript very well) Code: <SCRIPT type="text/javascript"> function Cart1Function() { get.INPUT.quantity.value send.to.formsubmit1.php } function Cart2Function() { get.INPUT.quantity.value send.to.formsubmit2.php } </SCRIPT> <FORM action="?" method="post" name="form"> <DIV> <INPUT type="text" name="quanitity"> <INPUT type="submit" value="CART 1" onClick="Cart1Function"> <INPUT type="submit" value="CART 2" onClick="Cart2Function"> <DIV> </FORM> I want to make two forms sharing the same input (quantity). Hi, i'm sabrina from Asia. i'm new here and a new student in javascript. My english language is not fluent.i'm really sorry about that. i really need help in my assignment. i've already create a form that will pop up an alert message if there is an empty input. it went great. but after i edit <form onSubmit="return formValidator()"> to <form onSubmit="return formValidator()" action="html_form_submit.asp" method="get"> i don't know why my submit button cannot send this form to html_form_action.asp. Please help me.. below is the code that i've done so far..thank you. <html><head> <title>Kelab ICT OUM</title> </head> <body> <script type="text/javascript"> function formValidator(){ var nama=document.getElementById("nama"); var umur=document.getElementById("umur"); var tarikh=document.getElementById("tarikh"); var poskod=document.getElementById("poskod"); var email=document.getElementById("email"); var alamat=document.getElementById("alamat"); var negeri=document.getElementById("negeri"); if(isAlphanumeric(nama,"Sila isi nama anda")){ if(isNumeric(tarikh,"Sila isi tarikh lahir")){ if(isNumeric(umur,"Sila isi umur")){ if(isNumeric(poskod,"Sila isi poskod")){ if(emailValidator(email,"Sila isi email anda")){ if(lengthRestriction(alamat,"Sila masukkan alamat anda")){ if(madeSelection(negeri,"Sila pilih Negeri")){ return true; } } } } } } } return false; } function notEmpty(elem, helperMsg){ if(elem.value.length=0) { alert(helperMsg); alem.focus(); return false; } return true; } function isNumeric(elem, helperMsg){ var numericExpression = /^[0-9]+$/; if(elem.value.match(numericExpression)) { return true; }else{ alert(helperMsg); elem.focus(); return false; } } function isAlphanumeric(elem, helperMsg){ var alphaExp=/^[0-9a-zA-Z]+$/; if(elem.value.match(alphaExp)) { return true; }else{ alert(helperMsg); elem.focus(); return false; } } function emailValidator(elem, helperMsg){ var emailExp=/^[\w\-\.\+]+\@[a-zA-Z0-9\.\-]+\.[a-zAz0-9]{2,4}$/; if(elem.value.match(emailExp)) { return true; }else{ alert(helperMsg); elem.focus(); return false; } } function lengthRestriction(elem,helperMsg){ var uInput=elem.value; if(uInput.length>15) { return true; } else{ alert(helperMsg); elem.focus(); return false; } } function madeSelection(elem, helperMsg){ if(elem.value == "Pilih") { alert(helperMsg); elem.focus(); return false; } else{ return true; } } </script> <form onSubmit="return formValidator()" action="html_form_submit.asp" method="get"> <table border="1" cellpadding="10" width="300"> <tr> <td colspan="3"><h1>Kelab iCT OUM</h1></td> </tr> <tr> <td>Nama</td> <td colspan="3"><input type="text" size="80" id="nama"</td> </tr> <tr> <td>Jantina</td> <td><input type= "radio" Name="Jantina" id="Jantina" value="p">Perempuan <br><input type= "radio" Name="Jantina" id="Jantina" value="l">Lelaki</td> <td>Umur <input type="text" size="10" id="umur"> Tahun <br><br> Tarikh Lahir <input type="text" size="10" id="tarikh"> </tr> <tr> <td>Alamat</td> <td><textarea name= "comments" rows="6" cols="20" wrap="virtual" id="alamat"> </textarea></td> <td>Poskod <input type="text" size="10" id="poskod"> <br><br>Negeri <select name= "negeri" id = "negeri"> <option value="Pilih" selected="select">Pilih</option> <option value="Perlis">Perlis</option> <option value="Kedah">Kedah</option> <option value="Perak">Perak</option> <option value="Selangor">Selangor</option> <option value="Negeri Sembilan">Negeri Sembilan</option> <option value="Melaka">Melaka</option> <option value="Kelantan">Kelantan</option> <option value="Pahang">Pahang</option> <option value="Terengganu">Terengganu</option> <option value="Johor">Johor</option> <option value="Wilayah Persekutuan">Wilayah Persekutuan</option> <option value="Sabah">Sabah</option> <option value="Sarawak">Sarawak</option> </select> <br><br>Email <input type="text" size="10" id="email"></td> </tr> </table><br> <input type="submit" value="Submit"> <input type= reset value ="Reset"> </form> </body> </html> Hello, First off thank you for looking at my post. Please forgive me if I do something incorrectly here. I have never posted in a forum before. You are very kind to assist me in this problem. I wish to send the javascript calculated value in a form from one page to another page form. I just need the one value sent. The value is "answer: in the code below. I would like to send it to a form page called "answer.html" I am not a computer person, and I am doing this in frontpage. I do not know how to write java or anything, I just copied this from a free script site and am trying to use it. Thank you once again for your kindness and patience with me. Thanks to all you experts! Michael here is the code I have. --------------------------------------------- Code: <table cellspacing=0 width=427 height=1 bgcolor="#FFFFFF" style="border-collapse: collapse" cellpadding="0" border="0"> <tr> <td width="634" nowrap height="1"> <script language="JavaScript"> function findcalculatorcalculate(form) { a = form.debt.value - 0; b = form.faith.value - 0; d = a / b; form.answer.value = Math.round (d); }</script> <p align="right" style="margin-left: 3; margin-right: 5"></p> <form name="form" style=" margin-right: 5; padding-left: 4; padding-right: 4; padding-top: 1; padding-bottom: 1" action="--WEBBOT-SELF--" method="POST"> <p align="right"> <font style="font-size: 11pt; font-weight:700">Input amount <input class="regfont" size="13" type="text" name="debt"></font><span style="font-size: 11pt; font-weight:700"> <br> divide by </span><font style="font-size: 11pt; font-weight:700"><input class="regfont" size="6" type="text" name="faith"></font><br> <b><font color="#FF0000" size="5"> </font></b><font style="font-size: 11pt"><input onclick="findcalculatorcalculate(this.form)" value="CLICK HERE TO CALCULATE" type="button" style="border-style:solid; border-width:2; font-weight: bold; font-family:Arial"><br> <b>ANSWER</b> </font></font> <INPUT NAME="answer" SIZE="5" VALUE=""><br> <INPUT TYPE="BUTTON" onClick="nextpage()" VALUE="Go to the next page"></p> </p> </form> </td> </tr> </table> <p align="right" style="margin-left: 3; margin-right: 5">I would like ANSWER field to pre populate the calculated amount on the second page titled "answer.html" THANK YOU!</p> ------------------------ Thank you again for helping me in plain language because I do not have the skills that all of you do. Hi there, I guess my question is very novice but I have to ask it. I can find lots of "form applications" on internet. But anytime I check them I cannot see any "send" button help. I mean I know that when I click it, it wont send the informations to my e-mail page. Because they don't show where to insert my email address there, in the example. So how can we make a form work for us, how can we arrange it to send the informations to our e-mail address? Do we need to use a php file for it? if yes, how? Regards and Thanks in advance Hi. I need to fo a form and the content be sent to a database but i'm stuck... I knwo hot to do forms and also how to send data to mysql using php. But now i need something a bit more complex and i'm stuck. I need to make a form lets say with "parent name, age, child name, child age" Some people has 1 child some people has 2 3 4...and i need to have it separated and not just write like "joe, bob, jack" in the same line. How can i do this? And how should the database be structured? i can't put "id, parent, age, c_name, c_age" because some ppl will need to have more than 1 child in the database. Don't know what to do Hi All, I have created my second Form to File Web Form thanks to some help from other members. Looks great. I am still new to HTML and Javascript, but basically I took my First Web Form coding (with the Java Script) and manipulated it so that it suited my needs for my 2nd Form (both are very close to being the same). For some reason, I can't get my Java Script validation to take effect. I was wondering if some one could try to pin point why it isn't functioning properly? Again it could be the most obvious thing, but please bear with me as I learn. Just for a little more clarity, I am going to list the things that I have changed to possibly make it easier to pin point: Added Fields: Department, SteetAddress, CityState Deleted: State/Research Accounts, Vendor Checkbox Modified: "Type" which is a radio button that I have changed the choices of. I beleive that's it...I will post my Java Script here and attach my Index File. Thank you in advance!! Code: /******************************************************************************** * * FORM VALIDATION * ********************************************************************************/ // get the value of a radio button group: function getRBValue(grp) { if ( grp.length == null ) return grp.checked ? grp.value : null; for ( var g = 0; g < grp.length; ++g ) { if ( grp[g].checked ) return grp[g].value; } return null; } // trim a string function trim(fld) { var val = fld.value.replace(/^\s+/,"").replace(/\s+%/,"").toUpperCase(); fld.value = val; return val; } var echk = /^([a-z][\w\-\'\.]*)+\@([a-z][\w\-\'\.]+\.)+[a-z]{2,6}$/i function emailCheck( fld ) { var email = trim( fld ); fld.value = email; return echk.test(email); } var digonly = /[^\d]/g function formatPhone( fld ) { var ph = fld.value.replace( digonly, "" ); if ( ph.length != 10 ) return; fld.value = "(" + ph.substring(0,3) + ") " + ph.substring(3,6) + "-" + ph.substring(6); } var phchk = /^\(\d\d\d\) \d\d\d\-\d\d\d\d$/ function phoneCheck( fld ) { return phchk.test(fld.value); } function validateForm( frm ) { var oops = ""; if ( trim( frm.elements["Username."] ).length < 5 ) oops += "You must enter your first and last name\n"; if ( ! emailCheck( frm.elements["Email."] ) ) oops += "That does not appear to be a valid email address\n"; if ( trim( frm.elements["Department."] ).length < 3) oops += "You must enter your department name\n"; if ( ! phoneCheck( frm.elements["Phone."] ) ) oops += "That is not a valid 10-digit phone number\n"; if ( trim( frm.elements["ShipToBuildingRoom."] ).length < 5 ) oops += "You must enter your building and room information\n"; if ( trim( frm.elements["StreetAddress."] ).length < 5 ) oops += "You must enter your street address information\n"; if ( trim( frm.elements["CityZip."] ).length < 5 ) oops += "You must enter your city and zip code information\n"; apptype = getRBValue( frm.elements["Type."] ); if ( apptype == null ) oops += "You must check one class\n"; var app = getRBValue( frm.RequireApprovalYesNo ); if ( app == null ) oops += "You must specify whether or not approval is required.\n"; if ( app == "Yes" ) { if ( trim( frm.Approver ).length < 5 ) oops += "You must enter the name of the approver\n"; if ( ! emailCheck( frm.ApprovalEmail ) ) oops += "The approval email is not a valid email address\n"; } } function showapp(yesno) { document.getElementById("APP1").style.display = document.getElementById("APP2").style.display = document.getElementById("APP3").style.display = yesno ? "" : "none"; } </SCRIPT> This is a form to calculate a players age as of May 1st of each year. I need to send the result in a URL string to "http://ntsacom.homestead.com/TEST3.html?TEAM_ID=TS63464122&LOG_IN_ID=11111111&league_age=[FORM RESULT] Can anyone help. This to complete a roster app for our youth BASEBALL league. My JavaScript is very limited and the gentleman that was working on this has abandoned it after receiving pay for the project (lesson learned). I have enough knowledge to finish the project once we figure this one small piece out. Thank you for looking at this for me! Code: <p id="form"></p> <form id="get_birthday" name="get_birthday"> <select id="form_get_month" name="form_birth_month"> <option value="0">january</option> <option value="1">february</option> <option value="2">march</option> <option value="3">april</option> <option value="4">may</option> <option value="5">june</option> <option value="6">july</option> <option value="7">august</option> <option value="8">september</option> <option value="9">october</option> <option value="10">november</option> <option value="11">december</option> </select> <select id="form_birth_day" name="form_birth_day"> <option value="1">1</option> <option value="2">2</option> <option value="3">3</option> <option value="4">4</option> <option value="5">5</option> <option value="6">6</option> <option value="7">7</option> <option value="8">8</option> <option value="9">9</option> <option value="10">10</option> <option value="11">11</option> <option value="12">12</option> <option value="13">13</option> <option value="14">14</option> <option value="15">15</option> <option value="16">16</option> <option value="17">17</option> <option value="18">18</option> <option value="19">19</option> <option value="20">20</option> <option value="21">21</option> <option value="22">22</option> <option value="23">23</option> <option value="24">24</option> <option value="25">25</option> <option value="26">26</option> <option value="27">27</option> <option value="28">28</option> <option value="29">29</option> <option value="30">30</option> <option value="31">31</option> </select> <select id="form_get_year" name="form_birth_year"> <option value="2011">2011</option> <option value="2010">2010</option> <option value="2009">2009</option> <option value="2008">2008</option> <option value="2007">2007</option> <option value="2006">2006</option> <option value="2005">2005</option> <option value="2004">2004</option> <option value="2003">2003</option> <option value="2002">2002</option> <option value="2001">2001</option> <option value="2000">2000</option> <option value="1999">1999</option> <option value="1998">1998</option> <option value="1997">1997</option> <option value="1996">1996</option> <option value="1995">1995</option> <option value="1994">1994</option> <option value="1993">1993</option> </select> <input onclick="calculate_age();" type="button" value="submit " /> </form> <-------------$ I want this to pass as a URL parameter "onclick" of the above button --------------> <p id="baseball"> <script language="JavaScript"> <!-- hide script from old browsers --> function calculate_age() { var birth_year = window.document.get_birthday.form_birth_year.value; var birth_month = window.document.get_birthday.form_birth_month.value; var birth_day = window.document.get_birthday.form_birth_day.value; if (((birth_month == 3) || (birth_month ==5) || (birth_month==8) || (birth_month==10)) && (birth_day==31)) { alert("Please check that you entered a valid date") return; } if ((birth_month == 1) && (birth_day >28)) { alert("Please check that you entered a valid date") return; } //Create the date object for todays date var now = new Date(); //Extract the current year, var the_year = now.getFullYear(); // Calculate elegibility for sport var league_text = "" var paragraph = document.getElementById("baseball"); //Clear the contents of paragraph if the submit button has been clicked more than once . //the Firefox way if (paragraph.innerText = ""); else //The MSIE way if (paragraph.textContent = ""); var league_age = (the_year - birth_year) if (birth_month > 3) league_age --; if (league_age < 5 ) { league_text = "1" } if ((league_age > 5) && (league_age <12)) { league_text = "1" } else if ((league_age >12) && (league_age <16)) { league_text = "1" } else if ((league_age >15) && (league_age <19)) { league_text = "1" } else if (league_age > 18) { league_text = "1" } var output_text = document.createTextNode(league_text); var output_age = document.createTextNode(league_age); paragraph.appendChild(output_age); paragraph.appendChild(output_text); S.redirectTo("search-results?baseball=value1") } </script> Hi Guys, im using chrome and ff and it worked fine till i tested on ie7 and the form just wont send on ie7. it gives me a validation error msg "SOME VALUES ARE NOT ACCEPTABLE" when i try to submit. ive tried so many things and i cant figure out why ie7 wont send upon submit like ff does, code seems to be fine, pls see validation coding line 7 - 32 , any jsGURU advice will be much appreciated! Code: <?php defined('_JEXEC') or die('Restricted access'); ?> <?php JHTML::_('behavior.formvalidation'); ?> <script language="javascript" type="text/javascript"> function submitbutton(pressbutton) { var form = document.adminForm; if (pressbutton == 'cancel') { submitform( pressbutton ); return; } // do field validation if (document.getElementById('jformfirstname').value == ""){ alert( "<?php echo JText::_( 'Firstname is missing.', true ); ?>" ); } else if (document.getElementById('jformsurname').value == ""){ alert( "<?php echo JText::_( 'Surname is missing.', true ); ?>" ); } else if (document.getElementById('jformemail').value == ""){ alert( "<?php echo JText::_( 'Email is missing.', true ); ?>" ); } else if (document.getElementById('jformphone1').value == ""){ alert( "<?php echo JText::_( 'Phone1 is missing.', true ); ?>" ); } else { if (document.formvalidator.isValid(form)) { submitform( pressbutton ); } else { alert("<?php echo JText::_( 'SOME VALUES ARE NOT ACCEPTABLE.', true ); ?>"); } } } </script> <?php if ($this->courseid){ ?> <?php if ( $this->params->def( 'show_page_title', 1 ) ) : ?> <div class="componentheading<?php echo $this->params->get( 'pageclass_sfx' ); ?>"> <?php echo $this->courseDetails->title; ?> </div> <?php endif; ?> <h3>Course Details</h3> <table cellSpacing=0 cellPadding=5 width="90%" border=0> <tr> <td width="20%"><?php echo JText::_( 'Course Title' ); ?>:</td> <td width="30%"><?php echo $this->courseDetails->title;?></td> <td width="20%"><?php echo JText::_( 'Code' ); ?>:</td> <td width="30%"><?php echo $this->courseDetails->code;?></td> </tr> <tr> <td><?php echo JText::_( 'Price' ); ?>:</td> <td><?php echo (number_format($this->courseDetails->price,2));?></td> <td><?php echo JText::_( 'No. of Days' ); ?>:</td> <td><?php echo $this->courseDetails->capacity;?></td> </tr> <tr> <?php if ($_GET['hide'] != 1 ) { ?> <td><?php echo JText::_( 'Location' ); ?>:</td> <td><?php echo $this->courseDetails->course_location;?></td> <?php } else { echo "<td> </td>"; echo "<td> </td>"; } ?> </tr> <tr> <?php if ($_GET['hide'] != 1 ) { ?> <td><?php echo JText::_( 'Start Date' ); ?>:</td> <td><?php echo Date('d-M-y', strtotime($this->courseDetails->start_date));?></td> <?php } else { echo "<td> </td>"; echo "<td> </td>"; } ?> </tr> </table> <?php } ?> <?php if ( $this->params->def( 'show_course_sessions', 1 ) && ($this->courseid) ) : ?> <h3>Sessions</h3> <table cellSpacing=0 cellPadding=5 width="90%" border=0> <tr> <td width="20%" align="center" height="20" class="sectiontableheader<?php echo $this->params->get( 'pageclass_sfx' ); ?>"> <?php echo JText::_('Day'); ?> </td> <td width="20%" align="center" height="20" class="sectiontableheader<?php echo $this->params->get( 'pageclass_sfx' ); ?>"> <?php echo JText::_('Start Time'); ?> </td> <td width="20%" align="center" height="20" class="sectiontableheader<?php echo $this->params->get( 'pageclass_sfx' ); ?>"> <?php echo JText::_('Finish Time'); ?> </td> <td width="10%" align="center" height="20" class="sectiontableheader<?php echo $this->params->get( 'pageclass_sfx' ); ?>"> <?php echo JText::_('Duration'); ?> </td> <td width="30%" align="center" height="20" class="sectiontableheader<?php echo $this->params->get( 'pageclass_sfx' ); ?>"> <?php echo JText::_('Location'); ?> </td> </tr> <?php $k = 0; $n=count( $this->course_sessions ); if ($n > 0){ for ($i=0, $n; $i < $n; $i++) { $row = &$this->course_sessions[$i]; ?> <tr> <td align="center"> <?php echo $row->session_day;?> </td> <td align="center"> <?php echo date('H:i', strtotime($row->start_time));?> </td> <td align="center"> <?php echo date('H:i', strtotime($row->finish_time));?> </td> <td align="center"> <?php echo $row->duration;?> </td> <td align="center"> <?php echo $row->session_location;?> </td> </tr> <?php $k = 1 - $k; } } else { ?> <tr> <td colspan="5"><? echo JText::_( 'There are no sessions for this course' );?></td></tr><?php } ?> </table> <?php endif; ?> <form action="<?php echo $this->action ?>" method="post" name="adminForm" id="adminForm" class="form-validate"> <?php if ( $this->params->def( 'show_page_title', 1 ) ) : ?> <div class="componentheading<?php echo $this->params->get( 'pageclass_sfx' ); ?>"> <?php echo $this->escape($this->params->get('page_title')); ?> </div> <?php endif; ?> <table cellpadding="4" cellspacing="1" border="0" width="100%"> <tr> <td width="15%"> <label for="jformcourseid"> <?php echo JText::_( 'Course' ); ?>: </label> </td> <td> <?php echo $this->lists['courseid'];?>* </td> </tr> <?php if ($_GET['hide'] == 1 ) { ?> <tr> <td valign="top"> <label for="jformcity"> <?php echo JText::_( 'I want to attend this course here' ); ?>: </label> </td> <td width="80%"> <select class="required" type="text" id="jformcountry" name="jform[country]" value="<?php echo $this->escape($this->booking->country);?>" />* <option>Choose your Location</option> <option>Melbourne</option> <option>Sydney</option> <option>Auckland</option> </select> </td> </tr> <?php } ?> <tr> <td valign="top"> <label for="jformfirstname"> <?php echo JText::_( 'Firstname' ); ?>: </label> </td> <td width="80%"> <input class="required" type="text" id="jformfirstname" name="jform[firstname]" size="50" maxlength="250" value="<?php echo $this->escape($this->booking->firstname);?>" />* </td> </tr> <tr> <td valign="top"> <label for="jformsurname"> <?php echo JText::_( 'Surname' ); ?>: </label> </td> <td valign="top"> <input class="required" type="text" id="jformsurname" name="jform[surname]" size="50" maxlength="250" value="<?php echo $this->escape($this->booking->surname);?>" />* </td> </tr> <?php if($this->userid > 0) { ?> <tr> <td valign="top"> <label for="jformusername"> <?php echo JText::_( 'Username' ); ?>: </label> </td> <td width="80%"> <input class="required" type="text" id="jformusername" name="jform[username]" size="50" maxlength="100" value="<?php echo $this->escape($this->username);?>" READONLY/>* </td> </tr> <?php } ?> <tr> <td valign="top"> <label for="jformdepartment"> <?php echo JText::_( 'Company' ); ?>: </label> </td> <td width="80%"> <input class="inputbox" type="text" id="jformdepartment" name="jform[department]" size="50" maxlength="30" value="<?php echo $this->escape($this->booking->department);?>" /> </td> </tr> <tr> <td valign="top"> <label for="jformemail"> <?php echo JText::_( 'Email' ); ?>: </label> </td> <td width="80%"> <input class="validate-email" type="text" id="jformemail" name="jform[email]" size="50" maxlength="100" value="<?php echo $this->escape($this->email);?>"/>* </td> </tr> <tr> <td valign="top"> <label for="jformphone1"> <?php echo JText::_( 'Phone Number' ); ?>: </label> </td> <td width="80%"> <input class="required" type="text" id="jformphone1" name="jform[phone1]" size="50" maxlength="20" value="<?php echo $this->escape($this->booking->phone1);?>" />* </td> </tr> <tr> <td valign="top"> <label for="jformcity"> <?php echo JText::_( 'Locations' ); ?>: </label> </td> <td width="80%"> <select type="text" id="jformcity" name="jform[city]" value="<?php echo $this->escape($this->booking->city);?>" /> <option>Choose your Location</option> <option>Melbourne</option> <option>Sydney</option> <option>Auckland</option> </select> </td> </tr> <tr> <td valign="top"> <label for="jforminstitution"> <?php echo JText::_( 'Referral Source' ); ?>: </label> </td> <td width="80%"> <select type="text" id="jforminstitution" name="jform[institution]" value="<?php echo $this->escape($this->booking->institution);?>" /> <option>How did you find out about us?</option> <option>Search Engine</option> <option>Friends</option> <option>Others</option> </select> </td> </tr> <tr> <td valign="top"> <label for="jformdescription"> <?php echo JText::_( 'Comments' ); ?>: </label> </td> <td> <textarea class="inputbox" cols="47" rows="6" id="jformdescription" name="jform[description]"><?php echo $this->escape( $this->booking->description);?></textarea> </td> </tr> </table> <div> <button type="button" class="button validate" onclick="submitbutton('save')"> <?php echo JText::_('Save') ?> </button> <button type="button" onclick="submitbutton('cancel')"> <?php echo JText::_('Cancel') ?> </button> </div> <input type="hidden" name="jform[id]" value="<?php echo $this->booking->id; ?>" /> <input type="hidden" name="jform[ordering]" value="<?php echo $this->booking->ordering; ?>" /> <input type="hidden" name="jform[approved]" value="<?php echo $this->booking->approved; ?>" /> <input type="hidden" name="jform[userid]" value="<?php echo $this->userid; ?>" /> <input type="hidden" name="option" value="com_courseman" /> <input type="hidden" name="controller" value="booking" /> <input type="hidden" name="task" value="" /> <?php echo JHTML::_( 'form.token' ); ?> </form> </br> Fields marked with an asterisk (*) are required. </br> </br> I'm creating a validation form. It's basic information but I want the form to be sent to my email after the form has been validated. My problem right now is when I hit submit my email comes up so I can send it to the assigned email address. It's not checking for errors first. I have created 5 different validation forms and I'm running across the same problem. I'm not sure if it's a function or form issue maybe even both. Any advice would be highly appreciated. Code: <script type="text/javascript"> /* <![CDATA[ */ /* ]]> */ function checkForNumber(fieldValue) { var numberCheck = isNaN (fieldValue); if (numberCheck ==true) { window.alert("You must enter a numeric value!"); return false; } else return true; } function checkForLetter(fieldValue) { var alphaCheck= /^[A-Za-z]+$/ (fieldValue); if (alphaCheck == true) { window.alert("You must enter letters only!"); return false; } else return true; } function checkEmail(fieldValue) { var emailCheck = /^\w+([/.-]?\w+)*@\w+([\-]?\w+)*(\.\w{2.3})+$/ (fieldValue); if (emailCheck == true) { window.alert("Please enter a valid email address!"); return false; } else return true; } function checkAlphanumeric(fieldValue) { var alphanumericCheck = /^[0-9a-zA-Z]+$/ (fieldValue); if (alphanumericCheck == true) { window.alert("Please enter an alphanumeric address!"); return false; } else return true; } function buttonPic() { for (var i=0; i<document.forms.morePic.length; ++i) { if (document.forms[0].morePic[i].checked == true) { document.forms[0].morePic[i].checked = false; break; } } } function checkPurch() { for (var j=0; j<document.forms.purchase.length; ++j) { if (document.forms[0].purchase[j].checked == true) { document.forms[0].purchase[j].checked = false; break; } } } function confirmSubmit() { var submitForm = window.confirm("Are you sure you want to submit form?"); if (document.forms[0].name_info.value == "" || document.forms[0].address_info.value == "" || document.forms[0].city_info.value == "" || document.forms[0].state_info.value == "" || document.forms[0].zip_info.value == "") { window.alert("You must enter your address."); return false; } else if (document.forms[0].validateEmail.value == "") { window.alert("Please enter a email address where I can contact you."); return false } var picSelected = false; for (var i=0; i < 2; ++i) { if (document.forms[0].morePic[i].checked == true) { picSelected = true; break; } } if (picSelected! = true) { window.alert("Please select if you would like more pictures."); return false; } var purchSelected = false; for (var j=0; j<2; ++j) { if (document.forms[0].purchase[j].check == true) { purchSelected = true; break; } } if (purchSelected! = true) { window.alert("Please select if you are interested in one or two vehicles."); return false; return true; } function confirmReset() { var resetForm = window.confirm("Are you sure you want to reset this form."); if (resetForm == true) return true; return false; } } </script> </head> <body> <p>Full Name:<input type="text" name="name_info" size="30" onblur="return checkForLetter(this.value);"/></p> <p>Street Address:<input type="text" name="address_info" size="50" onblur="return checkAlphanumeric(this.value);"/></p> City:<input type="text" name="city_info" size="20" onblur="return checkForLetter(this.value);"/>     State: <select name="state_info"> <option value="chooseYourState">Choose Your State</option> <option value="alabama">Alabama</option> <option value="alaska">Alaska</option> <option value="arizona">Arizona</option> </select>     Zip Code: <input type="text" name="zip_info" size="10" onblur="return checkForNumber(this.value);"/></p> Email Address: <input type="text" name="validateEmail" size="30" onblur="return checkEmail(this.value);"/></p> <p>Would you like more pictures sent to your email?</p> <input type="radio" name="morePic" value="Yes" onblur="return buttonPic();"/>Yes         <input type="radio" name="morePic" value="No" onblur="return buttonPic();"/>No <p>Are you thinking about purchasing one or two vehicles?</p> <input type="checkbox" name="purchase" value="One" onblur="return checkPurch();"/>One         <input type="checkbox" name="purchase" value="Two" onblur="return checkPurch();"/>Two <form action="mailto:abc@yahoo.com" method="get"> <p><input type="submit" value="Send" onsubmit="return confirmSubmit();"/> <input type="reset" value="Reset" onreset="return confirmReset();"/></p> </form> What I mean by this is how do you load an xml document that has been inputted as a string in a form. I would've assumed it was something like this, but this doesn't seem to be working. Code: <html> <head> <script type="text/javascript"> function loadXML(file) { var moz = (typeof document.implementation.createDocument != 'undefined'); var ie = (typeof window.ActiveXObject != 'undefined'); var xmlDoc; if (moz) xmlDoc = document.implementation.createDocument("", "", null); else if (ie) xmlDoc = new ActiveXObject("Microsoft.XMLDOM"); xmlDoc.async = false; xmlDoc.load(file); return xmlDoc; } </script> </head> <body> <input type="text" name="input1" size="15"/> <input type="button" value="LOADXML" loadXML(input1.value)"/> </body> </html> Where 'input1' would be an xml file in the same folder. i have a html/php form which let users upload pictures onto my server. the problem with it is, it says the picture has been uploaded but if the file name contains any of character apart from text (A-z) and numbers, the picture never shows up in the admin panel. is there a way using ajax or jquery to disallow certain file names in the upload field of the html which uses these characters !@#$%^'&*()"? how do i go on about this? Can someone modify the code below to save name & email to a file named logfile.dat please? Code: <html> <HEAD> <SCRIPT language="JavaScript"> function WriteFile(name, email) { var fso = new ActiveXObject("Scripting.FileSystemObject"); var fh = fso.CreateTextFile("D:\\logfile.dat", true); fh.WriteLine(name); fh.WriteLine(email); fh.Close(); } function sendtopage(whatpage) { alert(whatpage) window.location.href =whatpage; return true; } redirectTime = "3000"; redirectURL = "http://www.cnn.com"; function timedRedirect() { alert('Thank you'); setTimeout("location.href = redirectURL;",redirectTime); } function getCookie(c_name) { var i,x,y,ARRcookies=document.cookie.split(";"); for (i=0;i<ARRcookies.length;i++) { x=ARRcookies[i].substr(0,ARRcookies[i].indexOf("=")); y=ARRcookies[i].substr(ARRcookies[i].indexOf("=")+1); x=x.replace(/^\s+|\s+$/g,""); if (x==c_name) { return unescape(y); } } } function setCookie(c_name,value,exdays) { var exdate=new Date(); exdate.setDate(exdate.getDate() + exdays); var c_value=escape(value) + ((exdays==null) ? "" : "; expires="+exdate.toUTCString()); document.cookie=c_name + "=" + c_value; } function checkEmailCookie() { var email=getCookie("email"); if (email!=null && email!="") { alert("Email: " + email); } } function checkNameCookie() { var name=getCookie("name"); if (name!=null && name!="") { alert("Name: " + name); } } </SCRIPT> <style type="text/css"> .Class01 { font-family: "Lucida Sans Unicode", "Lucida Grande", sans-serif; font-size: 24px; font-weight: bold; } .Class02 { font-size: 36px; font-family: "Lucida Sans Unicode", "Lucida Grande", sans-serif; } .Class013 { font-family: "Lucida Sans Unicode", "Lucida Grande", sans-serif; } .Class01 .Class013 .Class01 { font-weight: bold; } .Classzz { font-family: "Lucida Console", Monaco, monospace; } .Classxx { font-weight: bold; font-size: 24px; } .Classzz { font-family: "Lucida Console", Monaco, monospace; } .style1 { text-align: center; } </style> </HEAD> <body gcolor="#FFFFFF" background="../MCM-background.jpg"> <center> <p class="style1"><img src="../mcm_header2.gif" alt="Header" width="790" height="199"></p> </center> <p></p> <form name="fm" action="http://www.meadecountymessenger.com"> <div align="center"> <p> </p> <p><span class="Class01"><span class="Class02">Please enter the following.</span></span></p> <p> </p> <p><span class="Class01">Your Name: </span> <input name="name" type="text" size="60" /> </p> <p><span class="Classzz"><br /> <span class="Classxx">Your eMail:</span></span><span class="Class01"> </span> <input name="email" type="text" size="60" /> <script type="text/javascript"> setCookie("email",document.fm.email.value,365); setCookie("name",document.fm.name.value,365); </SCRIPT> </p> <p> <input name="" type="submit" class="Class01" OnClick="alert('Thank You !');" value="Submit"/> </p> </div> </form> </body> </html> I'm not a programmer, just a lowly photographer that manages some websites. A company that provides Print-on-Demand services for me has some code that works in most browsers, but not in IE (at least older versions). It has to do with an onClick routine, and after some google searchs, I saw that similar issues have been common for years. Yet I didn't really understand the solutions. I put up a test page with the relevant code snippet. In Chrome, if one clicks on the image, the sales page comes up. In IE, nothing happens. I gathered that any error will bog down IE. If someone recognizes the problem or knows of a solution, I would be most grateful. The example page is here. The code snippet is below. Thanks in advance for anyone taking the time to look. <img src='http://images.fineartamerica.com/images-medium-large-5/autumn-peak-at-oxbow-bend-greg-norrell.jpg' style='position: absolute; top: 0px; left: 0px; width: 100%; height: 100%; border: none; z-index: 0;''> <div onTouchEnd='javascript: if(tap){window.location="http://photoartresource.com/featured/autumn-peak-at-oxbow-bend-greg-norrell.html";}' onClick='javascript: window.location="http://photoartresource.com/featured/autumn-peak-at-oxbow-bend-greg-norrell.html";' style='position: absolute; width: 100%; height: 100%; background-color: transparent; z-index: 1;'> </div> |