JavaScript - Send A Keystroke
Can I send a key stroke to effectively click the back button?
Cheers Daniel. Similar TutorialsHey guys, first I am new and I don't really know where this goes but I am wanting some help with developing a program that converts Sound (Speech or more preferably a sound... Like a frequency) to a Keystroke or code.. I know a little bit of C++ if that helps.. (I also Have Visual Studio 2013) Thanks guys
Reply With Quote 12-21-2014, 12:36 PM #2 Philip M View Profile View Forum Posts Supreme Master coder! Join Date Jun 2002 Location London, England Posts 18,371 Thanks 204 Thanked 2,573 Times in 2,551 Posts Not possible using Javascript. The Warrington players can hang their heads high. - Commentator, BBC Radio 2 Hi to everyone! I need javascript to trigger automatically on load "w" keyboard stroke but to react on browser not on any input or other elements! 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> I need to add onclick event to an element => myFunction(myVariable) but instead of the myVariable I need it's value to be set as an attr. As in: Code: <!html> <head> </head> <body> <input type="button" id="element" value="click me!"> <script type="text/javascript"> var myVariable = "myvalue"; document.getElementById('element').onclick = function () { showIt(myVariable); } myVariable = "myvalue2"; function showIt(msg){ alert(msg); } </script> </body> </html> Now i need the "click me!" input to alert "myvalue" and not "myvalue2". Here is the script I am using: PHP Code: <script type="text/javascript"> //set all the FCKeditor configuration here and pass it to the editable var oFCKeditor = new FCKeditor( 'editor1') ; oFCKeditor.BasePath = "fckeditor/" ; $('.myipwe').editable( { type: 'wysiwyg', editor: oFCKeditor, onSubmit:function submitData(content){ $.ajax({ type: "POST",url: "save.php?savepage=$page", data: {"content": content.current}, complete: function(){ }, //manage the complate if needed success: function(html){ }//get some data back to the screen if needed }); //close $.ajax( }, submit:'save', cancel:'cancel' }); </script> I'm not very familiar with javascript, but I want to get a variable called $page and then set it as the save.php?savepage=$page link. Anyone please tell me how to do it? Hello, In the following code i'm trying to check if the value of the text field is exist in the array. the problem that the function dose not accept the the value(node.value) from the text field. 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>Text Validation</title> <script type="text/javascript" language="javascript"> Array.prototype.inArray = function (value) { // Returns true if the passed value is found in the // array. Returns false if it is not. alert(value); var i; for (i=0; i < this.length; i++) { if (this[i] == value) { return true; } } return false; }; function cal(xx) { var node_list = document.getElementsByTagName('input'); arr = new Array(""); for (var i = 0; i < node_list.length; i++) { var node = node_list[i]; ///alert(node_list.length); // alert(node.value); arr.push(node.value) } alert(xx.length); //var arr= new Array(1,2,3,4,5,6,7,8,9,10); if(xx.length!=0) { if(arr.inArray(xx)) { alert("Your value is found in the Array"); } else { alert("Your value is not found in the Array"); } } } </script> </head> <body> <form id="text_validation" name="text_validation" action="" method="post"> <table width="600" border="1"> <tr> <td><label for="abc_text_1" id="abc_text_1_lb">Text 1</label> </td> <td>:</td> <td><input type="text" id="abc_text_1" name="abc_text_1" onblur="return cal(this.value);" /></td> </tr> <tr> <td><label for="cde_text_2" id="cde_text_2_lb">Text 2</label> </td> <td>:</td> <td><input type="text" id="cde_text_2" name="cde_text_2" value="abc" /></td> </tr> <tr> <td><label for="fgh_text_3" id="fgh_text_3_lb">Text 3</label> </td> <td>:</td> <td><input type="text" id="fgh_text_3" name="fgh_text_3" value="abcaaaaa" onblur="return testvalidation(fgh_text_3);" /></td> </tr> <tr> <td><label for="ijk_text_4" id="ijk_text_4_lb">Text 4</label> </td> <td>:</td> <td><input type="text" id="ijk_text_4" name="ijk_text_4" onblur="return testvalidation(ijk_text_4);" /></td> </tr> <tr> <td><label for="lmn_text_5" id="lmn_text_5_lb">Text 5</label> </td> <td>:</td> <td><input type="text" id="lmn_text_5" name="lmn_text_5" onblur="return testvalidation(lmn_text_5);" /></td> </tr> <tr> <td><label for="opq_text_6" id="opq_text_6_lb">Text 6</label> </td> <td>:</td> <td><input type="text" id="opq_text_6" name="opq_text_6" onblur="return testvalidation(opq_text_6);" /></td> </tr> <tr> <td><label for="rst_text_7" id="rst_text_7_lb">Text 7</label> </td> <td>:</td> <td><input type="text" id="rst_text_7" name="rst_text_7" /></td> </tr> <tr> <td><label for="uvw_text_8" id="uvw_text_8_lb">Text 8</label> </td> <td>:</td> <td><input type="text" id="uvw_text_8" name="uvw_text_8" /></td> </tr> <tr> <td><label for="xyz_text_9" id="xyz_text_9_lb">Text 9</label> </td> <td>:</td> <td><input type="text" id="xyz_text_9" name="xyz_text_9" /></td> </tr> <tr> <td><label for="klm_text_0" id="klm_text_0_lb">Text 10</label> </td> <td>:</td> <td><input type="text" id="klm_text_0" name="klm_text_0" value="10" /></td> </tr> </table> </form> </body> </html> Hey guys, I am wondering how to send text to a textarea when clicking on a link. Kinda like when clicking on a smiley or bbcode. I have a script, and it works, but only when the text to insert is on one line. Here is the code: Code: <script> function sendtext(e, text) { e.value += text } </script> Code: <img onClick="sendtext(document.myform.mytextarea, ':)')" src="smiley.gif"> Now I want to use this little script to insert an e-mail template which I am getting from the database into my textarea. Only, it works when the template is on one line, I am using this for my php code, which works, so no need to worry about that: Code: <img onClick="sendtext(document.myform.mytextarea, '<? echo ("$row['mytemplate']"); ?>')" src="smiley.gif"> When the "$row['mytemplate'];" is as follows: Code: Hey, this works It works, but when it's as follows: Code: Hey, it does not work Then it doesn't. So whenever there's a linebreak, it does not work. My question is, can someone help me with this, or a similar script, so I can add a piece of text to my textarea which has linebreaks in it? I hope you understand what I'm asking Thanks in advance for the help. I'm trying to make a jQuery slider, and I want the user (the person who installs it on their site) to be able to specify options easily. I know the Nivo slider does it from within the $(document).ready() event, but I can't figure out how to do it that way. I want it to be like this: Code: <script> $(document).ready(function() { myFunction({ option1: 'value1', option2: 'value2', etc: 'etc' }); }); </script> But how do I recover this data so I can use it later? Is it possible to send a checkbox value to the DB when checked and or unchecked. I mean when you Physically chage it's state. I am running a PHP project, the page I need this functionality on has a dynamically built table from the Database. What I need to do is send the value "1" to the DB if I check on one of the rows "Published" checkbox and vice versa, removing the value of 1 from the db and changing the state to unchecked. The reason I ask in the JS forum is that PHP is a server side language and as such may not submit the change in realtime. Any help and or suggestions is much appreciated. 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> 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; 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 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> Hey, First time poster... Apreciate any help here getting this thing to work (apoligise if its in the wrong section as it does cover php aswell) Problem is getting this form to work, it seems to go through ok, but it never makes it back to my mailbox. Its from a template that didnt explain how to get it to work. Codes.... the js in html head Code: <script type="text/javascript" src="js/forms.js"></script> the form html body Code: <form action="#" id="ContactForm"> <div class="success"> Contact form submitted!<br> <strong>We will be in touch soon.</strong> </div> <fieldset> <div class="wrapper"><label class="name"> <span class="bg"><input type="text" value="Name" class="input"></span> <span class="error">*This is not a valid name.</span> <span class="empty">*This field is required.</span> </label></div> <div class="wrapper"><label class="email"> <span class="bg"><input type="text" value="Email" class="input"></span> <span class="error">*This is not a valid email address.</span> <span class="empty">*This field is required.</span> </label></div> <div class="wrapper"><label class="phone"> <span class="bg"><input type="tel" value="Phone" class="input"></span> <span class="error">*This is not a valid phone number.</span> <span class="empty">*This field is required.</span> </label></div> <div class="wrapper"><label class="comment"> <span class="bg"><textarea rows="1" cols="1">Message</textarea></span> <span class="error">*The message is too short.</span> <span class="empty">*This field is required.</span> </label></div> <div class="btns relative"><a href="#" class="button1" data-type="reset"><img src="images/button_hover.png" alt=""><strong>Clear</strong></a><a href="#" class="button1" data-type="submit"><img src="images/button_hover.png" alt=""><strong>Submit</strong></a></div> </fieldset> </form> The Js code Code: (function($){ $.fn.extend({ forms:function(opt){ if(opt===undefined) opt={} this.each(function(){ var th=$(this), data=th.data('forms'), _={ errorCl:'error', emptyCl:'empty', invalidCl:'invalid', successCl:'success', successShow:'4000', mailHandlerURL:'submit.php', ownerEmail:'admin@bundesign.net', stripHTML:true, smtpMailServer:'localhost', targets:'input,textarea', controls:'a[data-type=reset],a[data-type=submit]', validate:true, rx:{ ".name":{rx:/^[a-zA-Z'][a-zA-Z-' ]+[a-zA-Z']?$/,target:'input'}, ".state":{rx:/^[a-zA-Z'][a-zA-Z-' ]+[a-zA-Z']?$/,target:'input'}, ".email":{rx:/^(("[\w-\s]+")|([\w-]+(?:\.[\w-]+)*)|("[\w-\s]+")([\w-]+(?:\.[\w-]+)*))(@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$)|(@\[?((25[0-5]\.|2[0-4][0-9]\.|1[0-9]{2}\.|[0-9]{1,2}\.))((25[0-5]|2[0-4][0-9]|1[0-9]{2}|[0-9]{1,2})\.){2}(25[0-5]|2[0-4][0-9]|1[0-9]{2}|[0-9]{1,2})\]?$)/i,target:'input'}, ".phone":{rx:/^\+?(\d[\d\-\+\(\) ]{5,}\d$)/,target:'input'}, ".fax":{rx:/^\+?(\d[\d\-\+\(\) ]{5,}\d$)/,target:'input'}, ".comment":{rx:/.{20}/,target:'textarea'} }, preFu:function(){ _.labels.each(function(){ var label=$(this), inp=$(_.targets,this), defVal=inp.attr('value'), trueVal=(function(){ var tmp=inp.is('input')?(tmp=label.html().match(/value=['"](.+?)['"].+/),!!tmp&&!!tmp[1]&&tmp[1]):inp.html() return tmp })() trueVal!=defVal &&inp.val(defVal=trueVal||defVal) label.data({defVal:defVal}) inp .bind('focus',function(){ inp.val()==defVal &&(inp.val(''),_.hideEmptyFu(label),label.removeClass(_.invalidCl)) }) .bind('blur',function(){ !inp.val() ?inp.val(defVal) :(_.isValid(label) ?_.showErrorFu(label) :_.hideErrorFu(label)), (_.isEmpty(label) ?_.showEmptyFu(label) :_.hideEmptyFu(label)) }) .bind('keyup',function(){ label.hasClass(_.invalidCl) &&_.isValid(label) ?_.showErrorFu(label) :_.hideErrorFu(label) }) label.find('.'+_.errorCl+',.'+_.emptyCl).css({display:'block'}).hide() }) _.success=$('.'+_.successCl,_.form).hide() }, isValid:function(el){ var ret=true, empt=_.isEmpty(el) if(empt) ret=false, el.addClass(_.invalidCl) else $.each(_.rx,function(k,d){ if(el.is(k)) d.rx.test(el.find(d.target).val()) ?(el.removeClass(_.invalidCl),ret=false) :el.addClass(_.invalidCl) }) return ret }, isEmpty:function(el){ var tmp return (tmp=el.find(_.targets).val())==''||tmp==el.data('defVal') }, validateFu:function(){ _.labels.each(function(){ var th=$(this) _.isEmpty(th) ?_.showEmptyFu(th) :_.hideEmptyFu(th) _.isValid(th) ?_.showErrorFu(th) :_.hideErrorFu(th) }) }, submitFu:function(){ _.validateFu() if(!_.form.has('.'+_.invalidCl).length) $.ajax({ type: "POST", url:_.mailHandlerURL, data:{ name:$('.name input',_.form).val()||'nope', email:$('.email input',_.form).val()||'nope', phone:$('.phone input',_.form).val()||'nope', fax:$('.fax input',_.form).val()||'nope', state:$('.state input',_.form).val()||'nope', comment:$('.comment textarea',_.form).val()||'nope', owner_email:_.ownerEmail, stripHTML:_.stripHTML }, success: function(){ _.showFu() } }) }, showFu:function(){ _.success.slideDown(function(){ setTimeout(function(){ _.success.slideUp() _.form.trigger('reset') },_.successShow) }) }, controlsFu:function(){ $(_.controls,_.form).each(function(){ var th=$(this) th .bind('click',function(){ _.form.trigger(th.data('type')) return false }) }) }, showErrorFu:function(label){ label.find('.'+_.errorCl).slideDown() }, hideErrorFu:function(label){ label.find('.'+_.errorCl).slideUp() }, showEmptyFu:function(label){ label.find('.'+_.emptyCl).slideDown() _.hideErrorFu(label) }, hideEmptyFu:function(label){ label.find('.'+_.emptyCl).slideUp() }, init:function(){ _.form=this _.labels=$('label',_.form) _.preFu() _.controlsFu() _.form .bind('submit',function(){ if(_.validate) _.submitFu() else _.form[0].submit() return false }) .bind('reset',function(){ _.labels.removeClass(_.invalidCl) _.labels.each(function(){ var th=$(this) _.hideErrorFu(th) _.hideEmptyFu(th) }) }) _.form.trigger('reset') } } if(!data) (typeof opt=='object'?$.extend(_,opt):_).init.call(th), th.data({cScroll:_}), data=_ else _=typeof opt=='object'?$.extend(data,opt):data }) return this } }) })(jQuery) the php ( this is possibly where the problem lies, but i assume it goes hand in hand with the JS, is reason why i posted it here as the js seemed really complex. Code: <?php $myemail = "admin@bundesign.net"; $name = $_POST["name"]; $email = $_POST["email"]; $comment = $_POST["comment"]; $phone = $_POST["phone"]; $from = "Bundesign Web <admin@bundesign.net>"; $subject = "Bundesign Web"; $message .= "$name <br> $email <br> $phone <br> $comment"; mail($myemail, $subject, $message,); ?> submit.php is located in the root and also i stuck it in the js folder just in case thats where it was looking. Thanks for any help, Chris. 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 How do I send an array created in jQuery or Javascript to PHP? (page will be redirected to PHP) I'm thinking of URL parameters right now, but wont that result to a long URL? Is there another optimized way of sending the array? Here's my script. Which doesn't work. Here's my script, this works fine... send_array_to_other_page.html Code: $(function(){ //DECLARE ARRAY var arr = new Array(); var i = 0; $('#form').submit(function(e){ e.preventDefault(); var value = $('#box').val(); var index = arr.length; var list = ''; //ADD VALUE TO ARRAY arr[index] = value; //OUTPUT VALUES IN ARRAY for (var index in arr){ list+=index+': '+arr[index]+'<br/>'; $('#arrLength').html(arr.length); } //DISPLAY ARRAY $('#display').html(list); $('#form').get(0).reset(); //RESET FORM }); $('#send').click(function(){ window.location = 'send_array_to_other_page_2.php?list='+arr; }); }); This doesn't. It outputs Array content lost. Id also like to point out the the url of this page is send_array_to_other_page_2.php. Its missing the ?list= PHP Code: <?php $arr = $_GET['list']; echo 'The contents of the array are still... <br/>'; if(isset($arr)){ print_r($arr); } else { echo 'Array content lost'; } ?> I am programatically trying to send multiple emails from within javascript code. I have read forums with different ideas and have not found a true solution. The problem I am having is as follows: - in one try - i am using window.location="mailto:"+emailList - this works great if it only needs to generate 1 email, but I am doing it in a loop. when it loops through the 2nd time, it does not create a 2nd email - in a 2nd try - i am using window.open("mailto:"+emailList - this does open multiple emails, but it also opens multiple windows. I am trying to find a way to either not have the windows open (only the multiple emails) or automatically close the extra windows. I am including my code below - note - the window.location try is listed, but commented out. Any help would be appreciated. if (emailListArray.length > jsNumEmails) { var j=1; for (var i=0; i<emailListArray.length; i++) { partialEmailList = partialEmailList + ";" + emailListArray[i]; if (j == jsNumEmails) { //window.location="mailto:"+partialEmailList; window.open("mailto:"+partialEmailList, "temp", "height=5, width=5, top=0, left=0"); j = 0; partialEmailList = ""; } //if j++; }//for } // if anything left in the partial list, then send that separately if (partialEmailList != "") { //window.location="mailto:"+partialEmailList; window.open("mailto:"+partialEmailList, "temp", "height=5, width=5, top=0, left=0"); } Hello, I would like to know how can I send the selection from a dropdown from a webpage to another. In the first page where I have the dropdown list, I have this: Code: <td valign="top" align="left" nowrap width="90%"> <input name="time" style="width:100%" /> </td> <td valign="top" align="left" nowrap width="50"> <select name="time2"> <option value="60">Minutes</option> <option value="3600">Hour</option> <option value="86400">Days</option> </select> </td> In the second page, where I want this selection to be dispalyed, I created this code: Code: <td width="188" valign="top" align="left" nowrap> <SCRIPT LANGUAGE="JavaScript">document.write(window.opener.document.form.elements["time"].value + " " + window.opener.document.form.elements["time2"].value);</SCRIPT> </td> The issue I have with this is that the value dispalyed for the "time2" element is the actual attribute value (for instance 60) and not the actual value (for instance "Minutes"). If anyone have a clue what I'm doing wrong, I appreciate your help. Regards, |