JavaScript - What Am I Doin Wrong? I Would Like The Result To Go To My Email
<html>
<head> <title></title> <script language="JavaScript"> <!-- function multiply() { // Get values from form var num1, num2; num1 = parseInt(document.calcForm.num1.value); num2 = parseInt(document.calcForm.num2.value); // Compute the product. var product = num1*num2*50; // Display product in form. document.calcForm.output.value = product; } //--> </script> </head> <body> <? if($_POST[comments]!=""){ mail("myemailaddress", $_POST[subject], "From Email: $_POST[youremail] $_POST[comments] "); echo " Thanks for your comment"; } ?> <h1 align="center">Price</h1> <form name="calcForm"> <p>Please Enter the dimensions</p> <p>Width: <input type="text" name="num1" size="10"></p> <p>Length: <input type="text" name="num2" size="10"></p> <input type="button" value="number" onClick="multiply()"> <hr /> <p>result; <input type="text" name="output" size="20" readonly></p> <p> <input type="submit" name="button" id="button" value="Finish" /> </p> </form> </body> </html> Similar TutorialsUsing the 'easy scroll' JS, I'm trying to scroll content inside a div. Two problems with this: 1) Links do not take you to the targeted element (Jumps halfway between other divs, takes you to wrong section...etc). 2) Content does not slide within the limits of the main border (some slide half way, some fit in perfectly). Turning off Java, the links take you to the right content and are aligned perfectly, but otherwise I'm messing up the JS! Am I using the wrong script for this effect? Code: <div style="padding:20px; text-align:center"><a href="#1">1</a> <a href="#2">2</a> <a href="#3">3</a> <a href="#4">4</a></div> <div class="wrapper" style="margin:0 auto; height:500px; width:850px; border:1px black solid; overflow:hidden"> <div id="1" style="height:500px; width:800px; background:aqua; border:1px blue solid">1</div> <div id="2" style="height:500px; width:800px; background:lime; border:1px blue solid">2</div> <div id="3" style="height:500px; width:800px; background:orange; border:1px blue solid">3</div> <div id="4" style="height:500px; width:800px; background:pink; border:1px blue solid">4</div> </div> <script type='text/javascript' src='http://ajax.googleapis.com/ajax/libs/jquery/1.4.3/jquery.min.js'></script> <script type="text/javascript"> $(function(){ $('a[href*=#]').click(function() { if (location.pathname.replace(/^\//,'') == this.pathname.replace(/^\//,'') && location.hostname == this.hostname) { var $target = $(this.hash); $target = $target.length && $target || $('[name=' + this.hash.slice(1) +']'); if ($target.length) { var targetOffset = $target.offset().top; $('html,.wrapper').animate({scrollTop: targetOffset}, 1000); return false; } } }); }); </script> Hi guys. I'm a mediocre website designer i know html , at JS i'm to noob to actualy make something of my own just Edit, i'm still learning and atm i'm working on a web project and I'm struggling to find a way to Filter email addresses to redirect my New Members to their e-mail provider, for example if they would register newmmember@hotmail.com to be forwarded to www.hotmail.com so they would login and activate their account, or if they enter @yahoo.com to be forwarded there . Can you please point out a few things i'm eager to learn how to Forward User to email provider after he creates his account . Or how can i forward email to URL inside my webpage , this could help me with another ideea i have, again this would have to be filtered @yahoo.com , @hotmail.com etc , to be forwarded to a local URL inside the site depending on what Email Provider they enter . I know this is a lot to ask but if you could point me out on the right path i would really appreciate all your help . Cheers
Hi, Im using the old nopcard scripts on my site. It does every thing right except it does not send a Email to my to my email adres. I dont know how to correct this because i dont know Javascript. I include the script if anybody know how to alter it so that it will send the info to my email adres as well. Thank you very much for your previous help. Kees Meyer Oudtshoorn South Africa. The checkout.pl script : #!/usr/bin/perl #=====================================================================|| # NOP Design JavaScript Shopping Cart || # PERL CGI Checkout Module || # || # For more information on SmartSystems, or how NOPDesign can help you || # Please visit us on the WWW at http://www.nopdesign.com || # || # Javascript portions of this shopping cart software are available as || # freeware from NOP Design. You must keep this comment unchanged in || # your code. For more information contact FreeCart@NopDesign.com. || # || # JavaScript Shop Module, V.4.4.0 || #=====================================================================|| # || # Function: Writes available form elements from the NOP || # Free Cart (http://www.nopdesign.com/freecart) || # and other form elements to an email file, and || # send user confirmation || # || #=====================================================================|| require 5.001; ######################################################################## # # # User defined variables: # # $header - string value containing the complete # # path of the HTML page header # # $footer - string value containing the complete # # path of the HTML page footer # # $mailprogram - string value containing the complete path to # # the sendmail binary on the system. # # $youremail - string value containing the email address to # # send catalog orders in EMAIL or BOTH modes # # **Don't forget to put a \ before the @ in your # # email address. ie. spam\@nopdesign.com*** # # $returnpage - URL to send user when checkout is complete # # $csvfilename - string value containing the complete # # path of the user database. # # $csvquote - string value containing what to use for quotes # # in the csv file (typically "" or \") # # $mode - string value containing 'EMAIL', 'FILE' or # # 'BOTH' to determine if the script should send # # an email to you with the new order, write the # # order to a CSV file, or do both. # ######################################################################## $header = "header.html"; $footer = "footer.html"; $mailprogram = "/usr/lib/sendmail -t"; $returnpage = "/"; $youremail = "support\@ebookstore.co.za"; $csvfilename = "orders.csv"; $csvquote = "\"\""; $mode = "BOTH"; #These are required fields. I recommend enforcing these by javascript, #but let's just make sure here as well. @required = ( 'b_first', 'b_last', 'b_addr', 'b_city', 'b_state', 'b_zip', 'b_phone', 'b_email' ); ############################################################## #FUNCTION: urlDecode # #RETURNS: The decoded string. # #PARAMETERS: An encoded string. # #PURPOSE: Decodes a URL encoded string. # ############################################################## sub urlDecode { my ($string) = @_; $string =~ tr/+/ /; $string =~ s/%([\dA-Fa-f][\dA-Fa-f])/pack ("C", hex($1))/eg; $string =~ s/['"]/\'/g; return ($string); } ############################################################## #FUNCTION: processCGI # #RETURNS: # #PARAMETERS: # #PURPOSE: Retrieves form data submitted via the 'GET' # # method and decodes it. You may then access # # the passed in variables via calls to $[name] # # where [name] is the name of the form element. # ############################################################## sub processCGI { local ($cgiData, $key, $value, $pair, @pairs); if ($ENV{'REQUEST_METHOD'} eq 'GET') { $cgiData = $ENV{'QUERY_STRING'}; } else { $cgiData = <STDIN>; } @pairs = split (/&/, $cgiData); foreach $pair (@pairs) { ($key, $value) = split (/\=/, $pair); $key = &urlDecode($key); $value = &urlDecode($value); if(defined ${$key}){ ${$key} .= ", ".$value; }else{ ${$key} = $value; } } } ############################################################## #FUNCTION: doFormError # #RETURNS: # #PARAMETERS: A error message string. # #PURPOSE: Generates an HTML page indicating a form # # submission error occurred. # ############################################################## sub doFormError { my ($errString) = @_; open (HEAD, $header); @LINES = <HEAD>; close HEAD; print "Content-type: text/html\n\n"; print @LINES; print "<FONT SIZE=+2>The form you submitted was not complete.<BR><BR></FONT>"; print "$errString<BR><BR>\n"; print "<INPUT TYPE=BUTTON ONCLICK='history.back()' VALUE=' Return to the checkout page '><HR>"; open (FOOT, $footer); @LINES = <FOOT>; close FOOT; print @LINES; exit; } ############################################################## #FUNCTION: doError # #RETURNS: # #PARAMETERS: A error message string. # #PURPOSE: Generates an HTML page indicating an error # # occurred. # ############################################################## sub doError { my ($errString) = @_; print "Content-type: text/html\n\n"; open (HEAD, $header); @LINES = <HEAD>; close HEAD; print @LINES; print "$errString<BR><BR>\n"; open (FOOT, $footer); @LINES = <FOOT>; close FOOT; print @LINES; exit; } ############################################################## #FUNCTION: invalidE # #RETURNS: 1 if invalid, 0 if valid. # #PARAMETERS: An email address variable. # #PURPOSE: Checks to see if a submitted email address is # # of the valid form 'x@y'. # ############################################################## sub invalidE { my ($szEmail) = @_; my ($user, $host); $szEmail =~ tr/A-Z/a-z/; if ($szEmail =~ /\s/) { return 1; } ($user, $host) = split (/\@/, $szEmail); if ($host =~ /compuserve/i) { ; } else { if (! $user =~ /\D/) { return 1; } if (! $host =~ /\D/) { return 1; } if (substr ($user,0,1) !~ /[a-z]/) { return 1; } } if ($szEmail =~ /\w+\@[\w|\.]/) { return 0; } else { return 1; } } sub populateDateVar { (Taken out because Text to long for email) "===================================================================== \n"; print MAIL "$QUANTITY_1 \R$PRICE_1 $ID_1 - $NAME_1 $ADDTLINFO_1 \n"; if( $NAME_2 ) {print MAIL "$QUANTITY_2 \R$PRICE_2 $ID_2 - $NAME_2 $ADDTLINFO_2 \n";} if( $NAME_3 ) {print MAIL "$QUANTITY_3 \R$PRICE_3 $ID_3 - $NAME_3 $ADDTLINFO_3 \n";} if( $NAME_4 ) {print MAIL "$QUANTITY_4 \R$PRICE_4 $ID_4 - $NAME_4 $ADDTLINFO_4 \n";} if( $NAME_5 ) {print MAIL "$QUANTITY_5 \R$PRICE_5 $ID_5 - $NAME_5 $ADDTLINFO_5 \n";} if( $NAME_6 ) {print MAIL "$QUANTITY_6 \R$PRICE_6 $ID_6 - $NAME_6 $ADDTLINFO_6 \n";} if( $NAME_7 ) {print MAIL "$QUANTITY_7 \R$PRICE_7 $ID_7 - $NAME_7 $ADDTLINFO_7 \n";} if( $NAME_8 ) {print MAIL "$QUANTITY_8 \R$PRICE_8 $ID_8 - $NAME_8 $ADDTLINFO_8 \n";} if( $NAME_9 ) {print MAIL "$QUANTITY_9 \R$PRICE_9 $ID_9 - $NAME_9 $ADDTLINFO_9 \n";} if( $NAME_10 ){print MAIL "$QUANTITY_10 \R$PRICE_10 $ID_10 - $NAME_10 $ADDTLINFO_10 \n";} if( $NAME_11 ){print MAIL "$QUANTITY_11 \R$PRICE_11 $ID_11 - $NAME_11 $ADDTLINFO_11 \n";} if( $NAME_12 ){print MAIL "$QUANTITY_12 \R$PRICE_12 $ID_12 - $NAME_12 $ADDTLINFO_12 \n";} if( $NAME_13 ){print MAIL "$QUANTITY_13 \R$PRICE_13 $ID_13 - $NAME_13 $ADDTLINFO_13 \n";} print MAIL "===================================================================== \n"; print MAIL "SUBTOTAL: $SUBTOTAL \n"; print MAIL "TOTAL: $TOTAL \n"; print MAIL "\n"; print MAIL "\n\n"; print MAIL "Comments: \n"; print MAIL "--------- \n"; print MAIL "$comment \n"; print MAIL " \n"; close MAIL; } if( $mode eq "BOTH" || $mode eq "FILE") { $csvcomments = $comment; #$csvcomments =~ s/\"/$csvquote/ig; open (CSVF,">>$csvfilename"); print CSVF "\""; print CSVF "$months[$month] $day, $year $hour:$min:$sec"; print CSVF "\",\""; print CSVF "$b_first"; print CSVF "\",\""; print CSVF "$b_last"; print CSVF "\",\""; print CSVF "$b_addr"; print CSVF "\",\""; print CSVF "$b_addr2"; print CSVF "\",\""; print CSVF "$b_city"; print CSVF "\",\""; print CSVF "$b_state"; print CSVF "\",\""; print CSVF "$b_zip"; print CSVF "\",\""; print CSVF "$b_phone"; print CSVF "\",\""; print CSVF "$b_fax"; print CSVF "\",\""; print CSVF "$b_email"; print CSVF "\",\""; print CSVF "$s_first"; print CSVF "\",\""; print CSVF "$s_last"; print CSVF "\",\""; print CSVF "$s_addr"; print CSVF "\",\""; print CSVF "$s_addr2"; print CSVF "\",\""; print CSVF "$s_city"; print CSVF "\",\""; print CSVF "$s_state"; print CSVF "\",\""; print CSVF "$s_zip"; print CSVF "\",\""; print CSVF "$s_phone"; print CSVF "\",\""; print CSVF "$QUANTITY_1"; print CSVF "\",\""; print CSVF "\R$PRICE_1"; print CSVF "\",\""; print CSVF "$ID_1"; print CSVF "\",\""; print CSVF "$NAME_1"; print CSVF "\",\""; print CSVF "$ADDTLINFO_1"; print CSVF "\",\""; print CSVF "$QUANTITY_2"; print CSVF "\",\""; print CSVF "\R$PRICE_2"; print CSVF "\",\""; print CSVF "$ID_2"; print CSVF "\",\""; print CSVF "$NAME_2"; print CSVF "\",\""; print CSVF "$ADDTLINFO_2"; print CSVF "\",\""; print CSVF "$QUANTITY_3"; print CSVF "\",\""; print CSVF "\R$PRICE_3"; print CSVF "\",\""; print CSVF "$ID_3"; print CSVF "\",\""; print CSVF "$NAME_3"; print CSVF "\",\""; print CSVF "$ADDTLINFO_3"; print CSVF "\",\""; print CSVF "$QUANTITY_4"; print CSVF "\",\""; print CSVF "\R$PRICE_4"; print CSVF "\",\""; print CSVF "$ID_4"; print CSVF "\",\""; print CSVF "$NAME_4"; print CSVF "\",\""; print CSVF "$ADDTLINFO_4"; print CSVF "\",\""; print CSVF "$QUANTITY_5"; print CSVF "\",\""; print CSVF "\R$PRICE_5"; print CSVF "\",\""; print CSVF "$ID_5"; print CSVF "\",\""; print CSVF "$NAME_5"; print CSVF "\",\""; print CSVF "$ADDTLINFO_5"; print CSVF "\",\""; print CSVF "$QUANTITY_6"; print CSVF "\",\""; print CSVF "\R$PRICE_6"; print CSVF "\",\""; print CSVF "$ID_6"; print CSVF "\",\""; print CSVF "$NAME_6"; print CSVF "\",\""; print CSVF "$ADDTLINFO_6"; print CSVF "\",\""; print CSVF "$QUANTITY_7"; print CSVF "\",\""; print CSVF "\R$PRICE_7"; print CSVF "\",\""; print CSVF "$ID_7"; print CSVF "\",\""; print CSVF "$NAME_7"; print CSVF "\",\""; print CSVF "$ADDTLINFO_7"; print CSVF "\",\""; print CSVF "$QUANTITY_8"; print CSVF "\",\""; print CSVF "\R$PRICE_8"; print CSVF "\",\""; print CSVF "$ID_8"; print CSVF "\",\""; print CSVF "$NAME_8"; print CSVF "\",\""; print CSVF "$ADDTLINFO_8"; print CSVF "\",\""; print CSVF "$QUANTITY_9"; print CSVF "\",\""; print CSVF "\R$PRICE_9"; print CSVF "\",\""; print CSVF "$ID_9"; print CSVF "\",\""; print CSVF "$NAME_9"; print CSVF "\",\""; print CSVF "$ADDTLINFO_9"; print CSVF "\",\""; print CSVF "$QUANTITY_10"; print CSVF "\",\""; print CSVF "\R$PRICE_10"; print CSVF "\",\""; print CSVF "$ID_10"; print CSVF "\",\""; print CSVF "$NAME_10"; print CSVF "\",\""; print CSVF "$ADDTLINFO_10"; print CSVF "\",\""; print CSVF "$QUANTITY_11"; print CSVF "\",\""; print CSVF "\R$PRICE_11"; print CSVF "\",\""; print CSVF "$ID_11"; print CSVF "\",\""; print CSVF "$NAME_11"; print CSVF "\",\""; print CSVF "$ADDTLINFO_11"; print CSVF "\",\""; print CSVF "$QUANTITY_12"; print CSVF "\",\""; print CSVF "\R$PRICE_12"; print CSVF "\",\""; print CSVF "$ID_12"; print CSVF "\",\""; print CSVF "$NAME_12"; print CSVF "\",\""; print CSVF "$ADDTLINFO_12"; print CSVF "\",\""; print CSVF "$QUANTITY_13"; print CSVF "\",\""; print CSVF "\R$PRICE_13"; print CSVF "\",\""; print CSVF "$ID_13"; print CSVF "\",\""; print CSVF "$NAME_13"; print CSVF "\",\""; print CSVF "$ADDTLINFO_13"; print CSVF "\",\""; print CSVF "$SUBTOTAL"; print CSVF "\",\""; print CSVF "$TOTAL"; print CSVF "\",\""; print CSVF "$SHIPPING"; print CSVF "\",\""; print CSVF "$comment"; print CSVF "\"\n"; close CSVF; } # Send email conformation to the customer..... open (MAIL,"|$mailprogram"); print MAIL "To: $b_email\n"; print MAIL "From: $youremail\n"; print MAIL "Subject: Order Confirmation\n"; print MAIL "\n\n"; print MAIL "A new order has been received. A summary of this order appears below.\n"; print MAIL "\n"; print MAIL "Order Date: $months[$month] $day, $year $hour:$min:$sec \n"; print MAIL " \n"; print MAIL "Bill To: \n"; print MAIL "-------- \n"; print MAIL " $b_first $b_last \n"; print MAIL " $b_addr \n"; print MAIL " $b_addr2 \n"; print MAIL " $b_city, $b_state $b_zip \n"; print MAIL " $b_phone \n"; print MAIL " $b_fax \n"; print MAIL " $b_email \n"; print MAIL " \n"; print MAIL " \n"; print MAIL "-------- \n"; if ( $s_addr eq "" ) { print MAIL " Use Billing Address\n"; } else { print MAIL " $s_first $s_last \n"; print MAIL " $s_addr \n"; print MAIL " $s_addr2 \n"; print MAIL " $s_city, $s_state $s_zip \n"; print MAIL " $s_phone \n"; } print MAIL " \n"; print MAIL " \n"; print MAIL "Qty Price(\R) Product ID - Product Name\n"; print MAIL "===================================================================== \n"; print MAIL "$QUANTITY_1 \R$PRICE_1 $ID_1 - $NAME_1 $ADDTLINFO_1 \n"; if( $NAME_2 ) {print MAIL "$QUANTITY_2 \R$PRICE_2 $ID_2 - $NAME_2 $ADDTLINFO_2 \n";} if( $NAME_3 ) {print MAIL "$QUANTITY_3 \R$PRICE_3 $ID_3 - $NAME_3 $ADDTLINFO_3 \n";} if( $NAME_4 ) {print MAIL "$QUANTITY_4 \R$PRICE_4 $ID_4 - $NAME_4 $ADDTLINFO_4 \n";} if( $NAME_5 ) {print MAIL "$QUANTITY_5 \R$PRICE_5 $ID_5 - $NAME_5 $ADDTLINFO_5 \n";} if( $NAME_6 ) {print MAIL "$QUANTITY_6 \R$PRICE_6 $ID_6 - $NAME_6 $ADDTLINFO_6 \n";} if( $NAME_7 ) {print MAIL "$QUANTITY_7 \R$PRICE_7 $ID_7 - $NAME_7 $ADDTLINFO_7 \n";} if( $NAME_8 ) {print MAIL "$QUANTITY_8 \R$PRICE_8 $ID_8 - $NAME_8 $ADDTLINFO_8 \n";} if( $NAME_9 ) {print MAIL "$QUANTITY_9 \R$PRICE_9 $ID_9 - $NAME_9 $ADDTLINFO_9 \n";} if( $NAME_10 ){print MAIL "$QUANTITY_10 \R$PRICE_10 $ID_10 - $NAME_10 $ADDTLINFO_10 \n";} if( $NAME_11 ){print MAIL "$QUANTITY_11 \R$PRICE_11 $ID_11 - $NAME_11 $ADDTLINFO_11 \n";} if( $NAME_12 ){print MAIL "$QUANTITY_12 \R$PRICE_12 $ID_12 - $NAME_12 $ADDTLINFO_12 \n";} if( $NAME_13 ){print MAIL "$QUANTITY_13 \R$PRICE_13 $ID_13 - $NAME_13 $ADDTLINFO_13 \n";} print MAIL "===================================================================== \n"; print MAIL "SUBTOTAL: $SUBTOTAL \n"; print MAIL "TOTAL: $TOTAL \n"; print MAIL "\n"; print MAIL "\n\n"; print MAIL "Comments: \n"; print MAIL "--------- \n"; print MAIL "$comment \n"; print MAIL " \n"; close MAIL; print "Content-type: text/html\n\n"; open (HEAD, $header); @LINES = <HEAD>; close HEAD; print @LINES; print "<h2>Thank you</h2>"; print "Thank you for your order."; print "Please contact us at $youremail if you have any problems questions or concerns. Thank U again for your support Kees Meyer."; print "<P>"; print "<A HREF=\"$returnpage\" rel="nofollow" target=_top>Return Home</A>"; print "<P>"; open (FOOT, $footer); @LINES = <FOOT>; close FOOT; print @LINES; exit; I will tell you now that I am not a javascript programmer and this is a very basic question. Please don't flame. I have been writing a web site and have found 2 functions that work and do what I want them to do, but I want to combine them. The first function will grab the window size.(it actually prints it out to the screen and I know how to get that to stop by taking out the last 2 lines) What I want to do with the results from the function alertSize() is exactly what the function res() does though. I want it to take the window size and jump to the appropriate web directory. What I don't know is if I can write that all as one function or if I have to pass the results of function alertSize() to function res(). Or how to do it for that matter, I don't even know what this is called in programming lingo. I am not asking for an answer here I would just like someone to point me in the right direction that I may learn a little more about what it is I want to do so I can get this to work. Giving me a search term would be a BIG help. Here is the first function. Code: // <script language="JavaScript"> //--> function alertSize() { var myWidth = 0, myHeight = 0; if( typeof( window.innerWidth ) == 'number' ) { //Non-IE myWidth = window.innerWidth; myHeight = window.innerHeight; } else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) { //IE 6+ in 'standards compliant mode' myWidth = document.documentElement.clientWidth; myHeight = document.documentElement.clientHeight; } else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) { //IE 4 compatible myWidth = document.body.clientWidth; myHeight = document.body.clientHeight; } window.alert( 'width = ' + myWidth ); window.alert( 'height = ' + myHeight ); } // </script> //--> and the second function. Code: // <script language="JavaScript"> //--> function res() { alert('Screen Resolution Is '+screen.width+' by '+screen.height); } if ((screen.width>=1280) && (screen.height>=1024)) { window.location="/12/index.html"; } else if ((screen.width>=1024) && (screen.height>=768)) { window.location="/10/index.html"; } else if ((screen.width>=800) && (screen.height>=600)) { window.location="lowres1.html"; } else if ((screen.width>=640) && (screen.height>=480)) { window.location="lowres2.html"; } else { window.location="lowres3.html"; } // </script> //--> Hi there, i have a dynamic form that is populated via a sql query (WHERE $AVAILABLE_PRODUCT > 0) hence the javascript that is called onchange has dynamic field names. i used numbers. the for loop works fine: Code: var numberOfFields = document.order_form.elements.length; for (var i=1; i<numberOfFields-3; i=i+4) { if (document.order_form.elements[i].value > document.order_form[i+3].value) { alert(document.order_form.elements[i].value + ' > ' + document.order_form[i+3].value); } .... } Alert Box shows: 3 > 17 or similar (where 17 is the number of items on stock, and three the number of items ordered.) all other calculations with that form work fine. any idea? 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> Good day to you all, I'm working on a form which would display the result in the same div that the form is. Here is my code so far: PHP Code: <form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post"> <textarea name="html"></textarea><br /> <input type="submit" onclick="load('<?php echo $_SERVER['PHP_SELF']; ?>','page');"/><br /> </form> Preview:<br /> <?php if(isset($_POST['html'])) echo stripslashes($_POST['html']); ?> <script type="text/javascript"> function ahah(url, target) { document.getElementById(target).innerHTML = ' Fetching data...'; if (window.XMLHttpRequest) { req = new XMLHttpRequest(); } else if (window.ActiveXObject) { req = new ActiveXObject("Microsoft.XMLHTTP"); } if (req != undefined) { req.onreadystatechange = function() {ahahDone(url, target);}; req.open("GET", url, true); req.send(""); } } function ahahDone(url, target) { if (req.readyState == 4) { // only if req is "loaded" if (req.status == 200) { // only if "OK" document.getElementById(target).innerHTML = req.responseText; } else { document.getElementById(target).innerHTML=" Error:\n"+ req.status + "\n" +req.statusText; } } } function load(name, div) { ahah(name,div); return false; } </script> My problem is when I click on the button , the text in my text area don't show. Can somebody help me. Thanks! I wrote quiz using HTML and JavaScrip. Score is accumulated in a variable called myScore. Now I want to email the result of myScore to an email address. How do I go about doing this? I don't want to use the mailto: command since that require that user actually press the send command to send the email. I want this done automatically after user finishes the quiz. Please explain all replied in details since I am new to JavaScript and still learning. I am trying to set up a small legend type html. What I am trying to accomplish is to give the user a description depending on the abbv they pick from the drop down. This all works fine, however I now want to improve this to actually give them a link to a site if they want to research the description further. I can get it to work if I do document.write but I want the link to go into the text box. I also thought about making a button to the side that would probably need some sort of function to call each url. That may come down the road but the simpler way would be nice. I have a js called abbs there is actually two ways to do the drop downs but I am only concerned with adding links to the top one. On the CCVT option I have added a link but the only way I can get it to work is through document.write. Here is my JS code: Code: function findMEAN(){ var abb = document.listNAME.abbWRD.value; if (abb == "AEP"){ abbs = ("American Electric Power") ;} else if (abb == "A"){ abbs = ("AMP") ;} else if (abb == "AC"){ abbs = ("ALTERNATING CURRENT") ;} else if (abb == "ACI"){ abbs = ("AMERICAN CONCRETE INSTITUTE") ;} else if (abb == "ACB"){ abbs = ("AIR CIRCUIT BREAKER") ;} else if (abb == "AISC"){ abbs = ("AMERICAN INSTITUTE OF STEEL CONSTRUCTION") ;} else if (abb == "ANSI"){ abbs = ("AMERICAN NATIONAL STANDARDS INSTITUTE") ;} else if (abb == "ARO"){ abbs = ("AUTOMATIC RECLOSING OPERATION") ;} else if (abb == "ASCE"){ abbs = ("AMERICAN SOCIETY OF CIVIL ENGINEERS") ;} else if (abb == "ASTM"){ abbs = ("AMERICAN SOCIETY FOR TESTING AND MATERIAL") ;} else if (abb == "AUX"){ abbs = ("AUXILUARY") ;} else if (abb == "AWG"){ abbs = ("AMERICAN WIRE GAUGE") ;} else if (abb == "BCT"){ abbs = ("BUSHING CURRENT TRANSFORMER") ;} else if (abb == "BIL"){ abbs = ("BASIC INSULATION LEVEL") ;} else if (abb == "BOM"){ abbs = ("BILL OF MATERIAL") ;} else if (abb == "BPD"){ abbs = ("BUSHING POTENTIOAL DEVICE") ;} else if (abb == "BPLC"){ abbs = ("BROADBAND POWER LINE CARRIER") ;} else if (abb == "BT"){ abbs = ("BUS TIE") ;} else if (abb == "CAB"){ abbs = ("CABLE") ;} else if (abb == "CAT#"){ abbs = ("CATALOG NUMBER") ;} else if (abb == "CB"){ abbs = ("CIRCUIT BREAKER") ;} else if (abb == "CCVT"){ abbs = ("COUPLING CAPACITOR VOLTAGE TRANSFORMER") ; abbslnk = "<p>Link: " + abbs.link("http://www.abb.com/product/db0003db002618/c12573e7003302adc1256ffd001d1256.aspx") + "</p>";} else if (abb == "CS"){ abbs = ("CIRCUIT SWITCHER") ;} else if (abb == "CT"){ abbs = ("CURRENT TRANSFORMER") ;} else if (abb == "CVT"){ abbs = ("CAPACITOR VOLTAGE TRANSFORMER") ;} else if (abb == "DC"){ abbs = ("DIRECT CURRENT") ;} else if (abb == "DEB"){ abbs = ("DOUBLE END BREAK") ;} else if (abb == "DMS"){ abbs = ("DATA MANAGEMENT SYSTEM/DIGITAL METERING SYSTEM") ;} else if (abb == "FDN"){ abbs = ("FOUNDATION") ;} else if (abb == "FMP"){ abbs = ("FIELD MARKED PRINT") ;} else if (abb == "GIS"){ abbs = ("GAS INSULATED SYSTEM") ;} else if (abb == "GND,GRDG"){ abbs = ("GROUND(ING)") ;} else if (abb == "GOAB"){ abbs = ("GAS OPREATED AIR BREAK") ;} else if (abb == "GOS"){ abbs = ("GANG OPREATED SWITCH") ;} else if (abb == "IFC"){ abbs = ("ISSUE FOR CONSTRUCTION") ;} else if (abb == "KA"){ abbs = ("KILO AMP") ;} else if (abb == "KCM"){ abbs = ("KILO(1000) CIRCULAR-MILS") ;} else if (abb == "KV"){ abbs = ("KILOVOLT") ;} else if (abb == "KVAR"){ abbs = ("KILOVOLT-AMPERES REACTIVE") ;} else if (abb == "LTC"){ abbs = ("LOAD TAP CHANGER") ;} else if (abb == "MLSE"){ abbs = ("MOST LIMITING SIGNIFICANT ELEMENT") ;} else if (abb == "MOAB"){ abbs = ("MOTOR OPERATED AIR BREAK") ;} else if (abb == "MOD"){ abbs = ("MOTOR OPERATED DISCONNECT") ;} else if (abb == "MR"){ abbs = ("MATERIAL REQUEST") ;} else if (abb == "MVAR"){ abbs = ("MEGAVOLT AMPERE REACTIVE") ;} else if (abb == "N.C."){ abbs = ("NORMALLY CLOSED") ;} else if (abb == "N.O."){ abbs = ("NORMALLY OPEN") ;} else if (abb == "NEMA"){ abbs = ("NATIONAL ELECTRICAL MANUFACTURER\'S ASSOCIATION") ;} else if (abb == "OCB"){ abbs = ("OIL CIRCUIT BREAKER") ;} else if (abb == "OEC"){ abbs = ("OUTSOURCED ENGINEERING COMPANY") ;} else if (abb == "OLD"){ abbs = ("ONE LINE DIAGRAM") ;} else if (abb == "OSHA"){ abbs = ("OCCUPATIONAL SAFETY AND HEALTH ADMINISTRATION") ;} else if (abb == "P&C"){ abbs = ("PROTECTION & CONTROL") ;} else if (abb == "PCIS"){ abbs = ("PROTECTION AND CONTROL INFORMATION SYSTEM") ;} else if (abb == "PCSS"){ abbs = ("PROTECTION & CONTROL SUPPORT SERVICES") ;} else if (abb == "PED"){ abbs = ("PROTECTION EXECUTION DOCUMENT") ;} else if (abb == "POP"){ abbs = ("PHASE OVER PHASE") ;} else if (abb == "PRA"){ abbs = ("PROJECT ROUTING & APPROVAL") ;} else if (abb == "PT"){ abbs = ("POTENTIAL TRANSFORMER") ;} else if (abb == "RIM"){ abbs = ("RELAY INSTRUMENTATION & METERING") ;} else if (abb == "RMS"){ abbs = ("ROOT MEAN SQUARE") ;} else if (abb == "RPA"){ abbs = ("R(TU) POINT ASSIGNMENT") ;} else if (abb == "RTU"){ abbs = ("REMOTE TERMINAL UNIT") ;} else if (abb == "S/N"){ abbs = ("SERIAL NUMBER") ;} else if (abb == "SA"){ abbs = ("SURGE ARRESTOR") ;} else if (abb == "SCADA"){ abbs = ("SUPERVISORY CONTROL AND DATA ACQUISITION") ;} else if (abb == "XF"){ abbs = ("TRANSFORMER") ;} else if (abb == "WD"){ abbs = ("WIRING DIAGRAM") ;} else if (abb == "VCB"){ abbs = ("VACUUM CIRCUIT BREAKER") ;} else if (abb == "V"){ abbs = ("VOLT") ;} else if (abb == "TCR"){ abbs = ("TRANSMISSION CONSTRUCTION REPRESENTATIVE") ;} else if (abb == "SW"){ abbs = ("SWITCH") ;} else if (abb == "SOW"){ abbs = ("SCOPE OF WORK") ;} else if (abb == "SESS"){ abbs = ("STATION ENGINEERING SUPPORT SERVICES") ;} { var result=document.getElementById("resultbox"); result.value = abbslnk } Here is my HTML code: Code: <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> <title>ACRONYMS</title> <script type= "text/javascript" src="abbs.js"> </script> <style type="text/css" media="Screen"> fieldset { border: 5px solid #555555; padding: 20px; width:350px; word-wrap: normal; } </style> </head> <body> <fieldset style="width:410px; height: 250px"> <h2>DESCRIPTION BY ABBV</h2> <form name = "listNAME"> <select name="abbWRD"> <option value=A>A</option> <option value=AC>AC</option> <option value=ACB>ACB</option> <option value=ACI>ACI</option> <option value=AEP>AEP</option> <option value=AISC>AISC</option> <option value=ANSI>ANSI</option> <option value=ARO>ARO</option> <option value=ASCE>ASCE</option> <option value=ASTM>ASTM</option> <option value=AUX>AUX</option> <option value=AWG>AWG</option> <option value=BCT>BCT</option> <option value=BIL>BIL</option> <option value=BOM>BOM</option> <option value=BPD>BPD</option> <option value=BPLC>BPLC</option> <option value=BT>BT</option> <option value=CAB>CAB</option> <option value=CAT#>CAT#</option> <option value=CB>CB</option> <option value=CCVT>CCVT</option> <option value=CS>CS</option> <option value=CT>CT</option> <option value=CVT>CVT</option> <option value=DC>DC</option> <option value=DEB>DEB</option> <option value=DMS>DMS</option> <option value=FDN>FDN</option> <option value=FMP>FMP</option> <option value=GIS>GIS</option> <option value=GND,GRDG>GND,GRDG</option> <option value=GOAB>GOAB</option> <option value=GOS>GOS</option> <option value=IFC>IFC</option> <option value=KA>KA</option> <option value=KCM>KCM</option> <option value=KV>KV</option> <option value=KVAR>KVAR</option> <option value=LTC>LTC</option> <option value=MLSE>MLSE</option> <option value=MOAB>MOAB</option> <option value=MOD>MOD</option> <option value=MR>MR</option> <option value=MVAR>MVAR</option> <option value=N.C.>N.C.</option> <option value=N.O.>N.O.</option> <option value=NEMA>NEMA</option> <option value=OCB>OCB</option> <option value=OEC>OEC</option> <option value=OLD>OLD</option> <option value=OSHA>OSHA</option> <option value=P&C>P&C</option> <option value=PCIS>PCIS</option> <option value=PCSS>PCSS</option> <option value=PED>PED</option> <option value=POP>POP</option> <option value=PRA>PRA</option> <option value=PT>PT</option> <option value=RIM>RIM</option> <option value=RMS>RMS</option> <option value=RPA>RPA</option> <option value=RTU>RTU</option> <option value=S/N>S/N</option> <option value=SA>SA</option> <option value=SCADA>SCADA</option> <option value=SESS>SESS</option> <option value=SOW>SOW</option> <option value=SW>SW</option> <option value=TCR>TCR</option> <option value=V>V</option> <option value=VCB>VCB</option> <option value=WD>WD</option> <option value=XF>XF</option> </select> </form><br> <input value="Click for Description" onclick="findMEAN()" type="button"> </br></br> <input type="text" name="myresultbox" id="resultbox" style="width:400px; height:75px;"> </fieldset><br> <fieldset style="width:350px; height: 250px"> <h2>ABBV BY DESCRIPTION</h2> <form name = "listDESC"> <select name="abbABB"> <option value=A>AMP</option> <option value=AC>ALTERNATING CURRENT</option> <option value=ACB>AIR CIRCUIT BREAKER</option> <option value=ACI>AMERICAN CONCRETE INSTITUTE</option> <option value=AEP>AMERICAN ELECTRICAL POWER</option> <option value=AISC>AMERICAN INSTITUTE OF STEEL CONSTRUCTION</option> <option value=ANSI>AMERICAN NATIONAL STANDARDS INSTITUTE</option> <option value=ARO>AUTOMATIC RECLOSING OPERATION</option> <option value=ASCE>AMERICAN SOCIETY OF CIVIL ENGINEERS</option> <option value=ASTM>AMERICAN SOCIETY FOR TESTING AND MATERIAL</option> <option value=AUX>AUXILUARY</option> <option value=AWG>AMERICAN WIRE GAUGE</option> <option value=BCT>BUSHING CURRENT TRANSFORMER</option> <option value=BIL>BASIC INSULATION LEVEL</option> <option value=BOM>BILL OF MATERIAL</option> <option value=BPD>BUSHING POTENTIOAL DEVICE</option> <option value=BPLC>BROADBAND POWER LINE CARRIER</option> <option value=BT>BUS TIE</option> <option value=CAB>CABLE</option> <option value=CAT#>CATALOG NUMBER</option> <option value=CB>CIRCUIT BREAKER</option> <option value=CCVT>COUPLING CAPACITOR VOLTAGE TRANSFORMER</option> <option value=CS>CIRCUIT SWITCHER</option> <option value=CT>CURRENT TRANSFORMER</option> <option value=CVT>CAPACITOR VOLTAGE TRANSFORMER</option> <option value=DC>DIRECT CURRENT</option> <option value=DEB>DOUBLE END BREAK</option> <option value=DMS>DATA MANAGEMENT SYSTEM/DIGITAL METERING SYSTEM</option> <option value=FDN>FOUNDATION</option> <option value=FMP>FIELD MARKED PRINT</option> <option value=GIS>GAS INSULATED SYSTEM</option> <option value=GND,GRDG>GROUND(ING)</option> <option value=GOAB>GAS OPREATED AIR BREAK</option> <option value=GOS>GANG OPREATED SWITCH</option> <option value=IFC>ISSUE FOR CONSTRUCTION</option> <option value=KA>KILOAMP</option> <option value=KCM>KILO(1000) CIRCULAR-MILS</option> <option value=KV>KILOVOLT</option> <option value=KVAR>KILOVOLT-AMPERES REACTIVE</option> <option value=LTC>LOAD TAP CHANGER</option> <option value=MLSE>MOST LIMITING SIGNIFICANT ELEMENT</option> <option value=MOAB>MOTOR OPERATED AIR BREAK</option> <option value=MOD>MOTOR OPERATED DISCONNECT</option> <option value=MR>MATERIAL REQUEST</option> <option value=MVAR>MEGAVOLT-AMPERES REACTIVE</option> <option value=N.C.>NORMALLY CLOSED</option> <option value=N.O.>NORMALLY OPEN</option> <option value=NEMA>NATIONAL ELECTRICAL MANUFACTURER'S ASSOCIATION</option> <option value=OCB>OIL CIRCUIT BREAKER</option> <option value=OEC>OUTSOURCED ENGINEERING COMPANY</option> <option value=OLD>ONE LINE DIAGRAM</option> <option value=OSHA>OCCUPATIONAL SAFETY AND HEALTH ADMINISTRATION</option> <option value=P&C>PROTECTION AND CONTROL</option> <option value=PCIS>PROTECTION AND CONTROL INFORMATION SYSTEM</option> <option value=PCSS>PROTECTION AND CONTROL SUPPORT SERVICES</option> <option value=PED>PROTECTION EXECUTION DOCUMENT</option> <option value=POP>PHASE OVER PHASE</option> <option value=PRA>PROJECT ROUTING AND APPROVAL</option> <option value=PT>POTENTIAL TRANSFORMER</option> <option value=RIM>RELAY INSTRUMENTATION AND METERING</option> <option value=RMS>ROOT MEAN SQUARE</option> <option value=RPA>R(TU) POINT ASSIGNMENT</option> <option value=RTU>REMOTE TERMINAL UNIT</option> <option value=S/N>SERIAL NUMBER</option> <option value=SA>SURGE ARRESTOR</option> <option value=SCADA>SUPERVISORY CONTROL AND DATA ACQUISITION</option> <option value=SESS>STATION ENGINEERING SUPPORT SERVICES</option> <option value=SOW>SCOPE OF WORK</option> <option value=SW>SWITCH</option> <option value=TCR>TRANSMISSION CONSTRUCTION REPRESENTATIVE</option> <option value=V>VOLT</option> <option value=VCB>VACUUM CIRCUIT BREAKER</option> <option value=WD>WIRING DIAGRAM</option> <option value=XF>TRANSFORMER</option> </select> </form><br> <input value="Click for ABBV" onclick="findABB()" type="button"> </br></br> <input type="text" name="myresultbox2" id="resultbox2" style="width:200px; height:75px;"> </fieldset><br> </body> </html> So in summary everything is working just want to make the result in the result box be able to be clinked to a specific link assigned. Thank you in advance. When I hit the submit button, the result are display on a new page. how do I force it to stay on the same page, here's my code. Code: <HTML> <HEAD> <TITLE>Test Input</TITLE> <script type="text/javascript"> function addtext() { var newtext = document.myform.inputbox.value; document.writeln(newtext); } </script> </HEAD> <BODY> <FORM NAME="myform">Enter something in the box: <BR> <INPUT TYPE="text" NAME="inputbox" VALUE=""> <INPUT TYPE="button" NAME="button" Value="Check" onClick="addtext()"> </FORM> </BODY> </HTML> any comments or suggestions would be greatly appreciated. Hello ! I am trying to create an auto suggest drop down. I have some ASP and Javascript code that I am using as an Autosuggest. Trouble is, the result displays on the main page, not under the text box like a drop down menu. I need help in getting the results to display correctly underneath the textbox. I have trawlled the internet and have loads and loads of code samples but I cant see the wood for the trees and I am really struggling with editing this code so that it displays correctly. clienthint.asp Code: <%@LANGUAGE="VBSCRIPT" CODEPAGE="65001"%> <html> <head> <script src="clienthint.js"></script> </head> <body> <% 'this displays the value of the textbox after the form is submitted If trim(Request("txt1")) <> "" Then Response.Write "You entered:" Response.Write "<b>" & Request("txt1") & "</b><br /><br />" End If %> <form name="form1" action="clienthint.asp" method="post"> Enter Word: <input type="text" name="txt1" id="txt1" onKeyUp="showHint(this.value,'txt1','form1',true)"> <input type="submit" name="submit" value="submit"> </form> <p>Suggestions: <span id="txtHint"></span></p> </body> </html> clienthint.js Code: var xmlHttp function showHint(str, box, thisForm, autoSubmit) { if (str.length==0) { document.getElementById("txtHint").innerHTML=""; return; } xmlHttp=GetXmlHttpObject() if (xmlHttp==null) { alert ("Your browser does not support AJAX!"); return; } var url="gethint.asp"; url=url+"?q="+str; url=url+"&b="+box; url=url+"&f="+thisForm; url=url+"&a="+autoSubmit; url=url+"&sid="+Math.random(); xmlHttp.onreadystatechange=stateChanged; xmlHttp.open("GET",url,true); xmlHttp.send(null); } function stateChanged() { if (xmlHttp.readyState==4) { document.getElementById("txtHint").innerHTML=xmlHttp.responseText; } } function GetXmlHttpObject() { var xmlHttp=null; try { // Firefox, Opera 8.0+, Safari xmlHttp=new XMLHttpRequest(); } catch (e) { // Internet Explorer try { xmlHttp=new ActiveXObject("Msxml2.XMLHTTP"); } catch (e) { xmlHttp=new ActiveXObject("Microsoft.XMLHTTP"); } } return xmlHttp; } //this function allows for Clickable suggestions function setTextBox(thisText,thisBox,thisForm,autoSubmit){ document.getElementById(thisBox).value = thisText //this autoSubmits the form after a suggestion is clicked - it is not working :( //if(autoSubmit=='true'){ // alert(thisForm); // document.getElementById(thisForm).submit(); //} } gethint.asp Code: <%@LANGUAGE="VBSCRIPT" CODEPAGE="65001"%> <% response.expires=-1 Dim rsWords Dim rsWords_numRows Dim q Dim b Dim hint q=ucase(request.querystring("q")) b=(request.querystring("b")) f=(request.querystring("f")) a=(request.querystring("a")) hint="" Set rsWords = Server.CreateObject("ADODB.Recordset") rsWords.ActiveConnection = "Provider=SQLOLEDB; Data Source=JAGUAR\SQLEXPRESS; Initial Catalog=67625252; User ID=SFSDFSDF; Password=KJHSDHFJHDF" rsWords.Source = "SELECT * FROM Rmatable WHERE (RMA_ID LIKE'" + q + "%') ORDER BY RMA_ID" rsWords.CursorType = 2 rsWords.CursorLocation = 2 rsWords.LockType = 3 rsWords.Open() rsWords_numRows = 0 If Not rsWords.EOF Then Do While Not rsWords.EOF If trim(hint) = "" Then hint = "<a href=""javascript:setTextBox('" & rsWords("RMA_ID") & "','" & b & "','" & f & "','" & a & "');"">" & rsWords("RMA_ID") & "</a>" Else hint = hint & " , <a href=""javascript:setTextBox('" & rsWords("RMA_ID") & "','" & b & "','" & f & "','" & a & "');"">" & rsWords("RMA_ID") & "</a>" End If rsWords.MoveNext() Loop End If if trim(hint)="" then response.write("no suggestion") else response.write(hint) end if rsWords.Close() Set rsWords = Nothing %> Can any one help me out please, i have two forms result and i need a function to sum and display the two forms result into one <html> <HEAD> <SCRIPT LANGUAGE="JavaScript"> function sum() { var one = parseFloat(document.myform.cost.value) var two = parseFloat(document.myform.insurance.value) var prod = one * two document.myform.amount.value=custRound(prod,2); } function custRound(x,places) { return (Math.round(x*Math.pow(10,places)))/Math.pow(10,places) } var Cost, GST, PST, Grand_Total; function tally() { Cost = 0; if (document.orderform.Item1.checked) { Cost = Cost + 26.15; } if (document.orderform.Item2.checked) { Cost = Cost + 26.10; } if (document.orderform.Item3.checked) { Cost = Cost + 26; } if (document.orderform.Item4.checked) { Cost = Cost + 26; } if (document.orderform.Item5.checked) { Cost = Cost + 26.44; } if (document.orderform.Item6.checked) { Cost = Cost + 26.01; } if (document.orderform.Item7.checked) { Cost = Cost + 26; } if (document.orderform.Item8.checked) { Cost = Cost + 26; } if (document.orderform.Item9.checked) { Cost = Cost + 25; } GST = (Cost * 0.07); PST = (Cost * 0.07); Cost = dollar(Cost); GST = dollar(GST); PST = dollar(PST); Grand_Total = parseFloat(Cost) + parseFloat(GST) + parseFloat(PST) ; Grand_Total = dollar(Grand_Total); document.orderform.Total.value = "$" + Cost; document.orderform.GST.value = "$" + GST; document.orderform.PST.value = "$" + PST; document.orderform.GrandTotal.value = "$" + Grand_Total; } function dollar (amount) { amount = parseInt(amount * 100); amount = parseFloat(amount/100); if (((amount) == Math.floor(amount)) && ((amount - Math.floor (amount)) == 0)) { amount = amount + ".00" return amount; } if ( ((amount * 10) - Math.floor(amount * 10)) == 0) { amount = amount + "0"; return amount; } if ( ((amount * 100) - Math.floor(amount * 100)) == 0) { amount = amount; return amount; } return amount; } </SCRIPT> </HEAD> <BODY> <H1 ALIGN = CENTER> in</H1> <H2 ALIGN = CENTER> PLEASE GET A QUOTE</H2> <FORM NAME="myform"> <P><B>VALUE OF Vehicle:</B> <input type="text" name="cost" onClick="sum()"> <P><B>Type of Insurance</B> <select name="insurance"> <option value="1.175" selected>Comprehensive</option> <option value="1.00">Third party only </option> <option value="0.75">Third party and thift</option> </select> <BR><input type="button" value="Get Quote" onClick="sum()" name="button"> <P>YOUR QUOTE </P> <input type="text" onClick="sum()" name="amount"> </FORM> </CENTER> <form method="post" name="orderform" action="mailto:ioduwa@yahoo.com" enctype="text/plain""> <table border="0"> <tr><td colspan="4"> <p><input type="checkbox" name="Item1" value="Item1_chosen" onclick="tally()"> Item One <p><input type="checkbox" name="Item2" value="Item2_chosen" onclick="tally()"> Item Two <p><input type="checkbox" name="Item3" value="Item3_chosen" onclick="tally()"> Item Three <p><input type="checkbox" name="Item4" value="Item4_chosen" onclick="tally()"> Item Four <p><input type="checkbox" name="Item5" value="Item5_chosen" onclick="tally()"> Item Five <p><input type="checkbox" name="Item6" value="Item6_chosen" onclick="tally()"> Item Six <p><input type="checkbox" name="Item7" value="Item7_chosen" onclick="tally()"> Item Seven <p><input type="checkbox" name="Item8" value="Item8_chosen" onclick="tally()"> Item Eight <p><input type="checkbox" name="Item9" value="Item9_chosen" onclick="tally()"> Item Nine </td></tr> <tr> <td> Total <input type="text" name="Total" value="$0" size="7"></td> <td> PST (7%) <input type="text" name="PST" value="$0" size="6"></td> <td colspan="2"> GST (7%) <input type="text" name="GST" value="$0" size="6"></td> </tr> <tr> <td> Grand Total <input type="text" name="GrandTotal" value="$0" size="8"></td> </tr> <tr> <td>Company Name:</td> <td colspan="3"><input type="Text" name="Company" size="35" maxlength="40"></td> </tr> <tr> <td>Contact Name:</td> <td colspan="3">First <input type="Text" name="FirstName" size="15" maxlength="20"> Last <input type="Text" name="LastName" size="15" maxlength="20"></td> </tr> <tr> <td>Address</td> <td><input type="Text" name="Street" size="20" maxlength="40"></td> </tr> <tr> <td>City</td> <td><input type="Text" name="City" size="20" maxlength="20"> </td> <td>Province/State:</td> <td><input type="Text" name="Province" size="20" maxlength="40"></td> </tr> <tr> <td>Country:</td> <td><input type="Text" name="Country" size="20" maxlength="20"></td> <td>Code:</td> <td><input type="Text" name="Code" size="9" maxlength="10"></td> </tr> <tr> <td>Phone:</td> <td><input type="Text" name="Area" size="3" maxlength="5"> <input type="Text" name="Phone" size="8" maxlength="10"></td> <td>Fax:</td> <td><input type="Text" name="AreaFax" size="3" maxlength="5"> <input type="Text" name="Fax" size="8" maxlength="10"></td> </tr> <tr> <td>Email Address:</td> <td colspan=2><input type="Text" name="Email" size="30" maxlength="30"></td> </tr> <tr><td colspan="4" height="3"><hr></td></tr> <tr><td colspan="2" align="center"><input type="Submit" value="Send Order"></td> <td colspan="2" align="center"><input type="RESET" value="Reset Order"></td></tr> </table> </form> </html> Finally got my favorite system to work but there is 1 little detail left... When an item is in the favorites, the php file echoes: "Already Favorited!" how can I get that response? I have no experience with js whatsoever.. first time I used it. (obvious since I use code that i found on the tubes and modded it) This is my code: PHP Code: /* ---------------------------- */ /* XMLHTTPRequest Enable */ /* ---------------------------- */ function createObject() { var request_type; var browser = navigator.appName; if(browser == "Microsoft Internet Explorer"){ request_type = new ActiveXObject("Microsoft.XMLHTTP"); }else{ request_type = new XMLHttpRequest(); } return request_type; } var http = createObject(); var nocache = 0; function insert() { // Optional: Show a waiting message in the layer with ID login_response document.getElementById('insert_response').innerHTML = "Adding..." // Required: verify that all fileds is not empty. Use encodeURI() to solve some issues about character encoding. var user_id= encodeURI(document.getElementById('user_id').value); var item_id = encodeURI(document.getElementById('item_id').value); var cat_id = encodeURI(document.getElementById('cat_id').value); // Set te random number to add to URL request nocache = Math.floor(Math.random()); // Pass the login variables like URL variable http.open('get', 'http://animekyun.com/scripts/favorite.php?user_id='+user_id+'&item_id=' +item_id+'&cat_id=' +cat_id); http.onreadystatechange = insertReply; http.send(null); } function insertReply() { if(http.readyState == 4){ var response = http.responseText; document.getElementById('insert_response').innerHTML = 'Favorited'+response; } } Apparently this http.responseText is not working propperly since it's not returning anything Hello all, I am new to these forms, and new to Javascript as well. I have gone through some lessons, and have been trying to write a simple script on my own. Here is what I am trying to do: I am calculating a volume, and want to display the result of that calculation. I then want to take the result and multiply it by 2 and display that as well. Here is what I have so far: Code: function volume (l, w, h) { return l * w * h; } console.log("Volume = " + volume (2, 2, 2)); So far so good... but I cant figure out how to then take that result that was displayed in the console and save it as a variable (if that would be the correct way to do it) so that I can modify the result by 2. I have tried several things with no luck. How can I save the result of a function or pass it to another function? Thanks in advance! Can anyonle pls explain me why the return function is not returning the result as intended? I appreciate you help OUTPUT ====== Student : Doe,John eMail : johndoe@gmail.com Course ID : COIN-070B.01 -------------------------------- function task() { var title = ["Assignment1", "Assignment2", "Assignment3", "Assignment4", "Assignment5", "Mid Term", "Finals"]; var points = [30, 30, 28, 27, 29, 41, 45]; for (var i = 0; i < points.length; i++) { titlePoints += title[i] + (" : " + points[i] + "\n"); } return titlePoints; } Code: <head> <title>Variable - Examples 1</title> <script type="text/javascript"> function Student(firstName, lastName, email,courseID){ this.firstName = firstName; this.lastName = lastName; this.email = email; this.courseID = courseID; this.assignments = task; } Student.prototype = { constructor : Student, toString : studentInfo }; function task(){ var title = ["Assignment1","Assignment2","Assignment3","Assignment4","Assignment5","Mid Term", "Finals"] var points = [30, 30, 28, 27, 29,41,45]; var titlePoints = ""; for (var i=0; i < points.length; i++){ titlePoints += title[i] + " : " + points[i] + "\n"; } return titlePoints; } function studentInfo(){ return "Student : " + this.lastName + "," + this.firstName + "<br>"+ "eMail : " + this.email + "<br>" + "Course ID : " + this.courseID + "<br>" + "--------------------------------" + "<br>" + this.assignments; } var student = new Student("John", "Doe", "johndoe@gmail.com","COIN-070B.01"); </script> </head> <body> <script type="text/javascript"> document.writeln(student.toString()); </script> </body> </html> Hey Forum, I have this little script working great when all if's are seperated. what i need is to have the script read if one of these fields has a value then result=true. as you see the script now i have this seperated in many different if's for all three text fields. I need to put all text fields like they were one, thanks Code: function ValidateLink(Form) { var result = true; if (formMyLocations.cellAddress.value.length == 0) { alert('Cell address is empty on the locations page'); result = false; } if (formMyLocations.homeAddress.value.length == 0) { alert('Home address is empty on the locations page'); result = false; } if (formMyLocations.carAddress.value.length == 0) { alert('Car address is empty on the locations page'); result = false; } return result; } Hi.. I have this function: Code: function doz(oText){ var P27_max = document.getElementById("P27_max").value; //var P27_max_convert = parseFloat(P27_max) + parseFloat(1); var P27_max_convert = ((parseFloat(P27_max) * parseFloat(1000)) / parseFloat(0.00) / parseFloat(12)); if( !isNaN(P27_max_convert) ){ var P27_maxdoz = document.getElementById("P27_maxdoz").value = P27_max_convert.toFixed(2); } var P28_max = document.getElementById("P28_max").value; // var P28_max_convert = parseFloat(P28_max) + parseFloat(2); var P28_max_convert = ((parseFloat(P28_max) * parseFloat(1000)) / parseFloat(22.00) / parseFloat(12)); if( !isNaN(P28_max_convert) ){ var P28_maxdoz = document.getElementById("P28_maxdoz").value = P28_max_convert.toFixed(2); } } my output is Infinity.. what's wrong in my computation : var P28_max_convert = ((parseFloat(P28_max) * parseFloat(1000)) / parseFloat(22.00) / parseFloat(12)); Thank you Hi, I have this code to get hints (PHP file): Code: <?php include("include/session.php"); $GetNames = "SELECT firstname, lastname, username FROM users"; $GetNamesConnect = $database->query($GetNames); While($row = mysql_fetch_array($GetNamesConnect)) { $a[$row['username']] = $row['firstname'] . " " . $row['lastname']; } //get the q parameter from URL $q=$_GET["q"]; //lookup all hints from array if length of q>0 if (strlen($q) > 0) { $hint=""; for($i=0; $i<count($a); $i++) { if (strtolower($q)==strtolower(substr($a[$i],0,strlen($q)))) { if ($hint=="") { $hint=$a[$i]; } else { $hint=$hint.", ".$a[$i]; } } } } // Set output to "no suggestion" if no hint were found // or to the correct values if ($hint == "") { $response="no suggestion"; } else { $id = $row['username']; $response= "<a href='profile.php?user=$row['username']'>$hint</a>"; } //output the response echo $response; ?> This is the display part (Javascript/Ajax) 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> <script type="text/javascript"> function showHint(str) { if (str.length==0) { document.getElementById("txtHint").innerHTML=""; return; } if (window.XMLHttpRequest) {// code for IE7+, Firefox, Chrome, Opera, Safari xmlhttp=new XMLHttpRequest(); } else {// code for IE6, IE5 xmlhttp=new ActiveXObject("Microsoft.XMLHTTP"); } xmlhttp.onreadystatechange=function() { if (xmlhttp.readyState==4 && xmlhttp.status==200) { document.getElementById("txtHint").innerHTML=xmlhttp.responseText; } } xmlhttp.open("GET","gethint.php?q="+str,true); xmlhttp.send(); } </script> </body> </html> What I want to do it to limit the names suggested to 10, how would I do this? |