JavaScript - Converting Coupon Code Text To Uppercase
This is pretty basic. I have a coupon code text box and need to ensure whatever the user enters is converted to uppercase before it is validated. The problem is, someone else wrote the code and I have no idea where or how to put in the code to change the text to uppercase. I would appreciate your help.
Payment.php: PHP Code: <input type="text" name="coupon" id="coupon-input" class="coupon-input" placeholder="Enter coupon code" style="color:#000;"> <input class="bt2 apply-btn" type="button" value="Apply" id="apply-btn"> <script> // When the browser is ready... $(function(){ $("#apply-btn").click(function(){ $("#apply-btn").attr("disabled", "disabled"); $("#apply-btn").val('Checking'); $("#amount").val(<?php echo number_format($item_price, 2); ?>); $(".form-product-details").html('<b>$<span id="input_14_1001_price"><?php echo number_format($item_price, 2); ?></span></b>'); $.ajax({ url: 'validate-coupon.php', type: "POST", data: {val: $("#coupon-input").val(), amt:$("#amount").val()}, dataType: 'JSON', success: function(res) { $("#apply-btn").val('Apply'); $("#apply-btn").prop("disabled", false); if(res.type=='error'){ $("#msg").html("<span style='color:red;font-weight:bold;'>Invalid Coupon.</span>"); } else { $("#msg").html("<span style='color:green;font-weight:bold;'>Coupon is valid.</span>"); $(".form-product-details").html('<b><span style="text-decoration:line-through">$<?php echo number_format($item_price, 2); ?></span> $<span id="input_14_1001_price" class="underlined">'+res.amt+'</span><br /><span>'+res.msg+'</span></b>'); $("#amount").val(res.amt); } } }); }); }); </script> validate-coupon.php: PHP Code: $coupon = array( array("code" => "COUPON50", 'value'=>'50', 'type'=>'P'), ); if(isset($_POST['val']) && $_POST['val']!='' && isset($_POST['amt']) && $_POST['amt']!=''){ $matched = false; foreach($coupon as $coup){ if($coup['code']==$_POST['val']){ $matched = true; $amt = $_POST['amt']; if($coup['type']=='P'){ $new_amt = $amt - ($amt/100)*$coup['value']; $msg = $coup['value']."% off coupon code applied"; } else if($coup['type']=='F'){ $new_amt = $amt - $coup['value']; $msg = "$".$coup['value']." off coupon code applied"; } break; } } if($matched){ echo json_encode(array("type" => "success", 'amt'=>number_format($new_amt, 2), 'msg'=>$msg)); } else { echo json_encode(array("type" => "error")); } } else { echo json_encode(array("type" => "error")); } exit; Similar TutorialsThis should be simple, but I can't quite get it to work without some kind of side-effect. I've checked the forum and there doesn't seem to be anything that directly relates. What I want to do is convert the text that a user is typing to uppercase as they type it. What I have so far: function convertToUppercase(aControl) { var cursorKeys ="8;46;37;38;39;40;33;34;35;36;45;"; if (cursorKeys.indexOf(event.keyCode+";") == -1) { aControl.value = aControl.value.toUpperCase(); } } <input onkeyup="convertToUppercase(this)"/> The problem that I have is that this moves the cursor to the end of the line after every character. If you want to go and add something to the middle of what you've typed, you can type one character and then the cursor jumps to the end. e.g. inserting "abc" between the "R" and "E" of "FRED" gets you: FRAEDBC What I need is either: 1) ability to get the cursor/caret position and restore it after I set the uppercase string -- or -- 2) ability to intercept the keystroke in the event and make it uppercase before the browser adds it naturally to the input's value. Solution should be browser-independent (if at all possible). I'm mostly interested in IE though. Thanks, Chris Hello, I need your help. How can I convert the following code to Javascript: Code: 'SEARCH BY FILE NUMBER IN FILE NUMBER WHEN THE ENTER KEY IS PRESSED Private Sub h1_KeyDown(ByVal KeyCode As msforms.ReturnInteger, ByVal Shift As Integer) If KeyCode = vbKeyReturn Then KeyCode = 0 Call btn_search_Click End If End Sub Thanks for all your help in advance J I have written a card trick in C++. The purpose of the card trick is the player picks 4 cards and then based on the 4 cards they pick 4 more cards. The player can then switch the card and the computer does some math to determine how to which card was switched. Right now all i can figure out is how to display and flip the card. This is the program I have written in C++ Code: #include <iostream> #include <string> using namespace std; int main() { int num[4]; char suite[4]; int code[4]; int mycode[4]; int code2[4]; int mycode2[4]; int i=0; int error=0; int k=4; int pick; cout<<"Welcome to our card trick. I believe that given some cards I would be able to tell you which card you switched. Dont believe me! Well lets play. First I will let you pick four cards, then I will pick four cards. Next I will pick four cards. Then you will have the opportunity to pick a card to switch. Then I will tell you which card you switched. Promise I wont peek! Lets begin."<<endl; for(i=0; i<4; i++){ cout<<"Enter card number"<<endl; cin>>num[i]; cout<<"Enter suit"<<endl; cin>>suite[i]; } for(i=0; i<4; i++){ if (suite[i]=='D'||suite[i]=='H') code[i]=1; else code[i]=0; cout<<code[i]; } mycode[0]=code[0]+code[2]+code[3]; mycode[0]=mycode[0] % 2; mycode[1]=code[0]+code[1]+code[3]; mycode[1]=mycode[1] % 2; mycode[2]=code[0]+code[1]+code[2]; mycode[2]=mycode[2] % 2; mycode[3]=code[1]+code[2]+code[3]+1; mycode[3]=mycode[3] % 2; for(i=0; i<4; i++){ cout<<mycode[i]; } cout<<endl; cout<<"Which position would you like to switch out for a new card? Position 0-7."<<endl; cin>>pick; switch (pick){ case 0: if(code[pick]==1) code[pick]=0; else code[pick]=1; break; case 1: if(code[pick]==1) code[pick]=0; else code[pick]=1; break; case 2: if(code[pick]==1) code[pick]=0; else code[pick]=1; break; case 3: if(code[pick]==1) code[pick]=0; else code[pick]=1; break; case 4: pick=pick-4; if(mycode[pick]==1) mycode[pick]=0; else mycode[pick]=1; break; case 5: pick=pick-4; if(mycode[pick]==1) mycode[pick]=0; else mycode[pick]=1; break; case 6: pick=pick-4; if(mycode[pick]==1) mycode[pick]=0; else mycode[pick]=1; break; case 7: pick=pick-4; if(mycode[pick]==1) mycode[pick]=0; else mycode[pick]=1; break; } //copying into switched for(i=0; i<4; i++){ code2[i]=code[i]; } for(i=0; i<4; i++){ mycode2[i]=mycode[i]; } cout<<"Switched: "; for(i=0; i<4; i++){ cout<<code2[i]; } for(i=0; i<4; i++){ cout<<mycode2[i]; } cout<<endl; cout<<"New: "; mycode[0]=code[0]+code[2]+code[3]; mycode[0]=mycode[0] % 2; mycode[1]=code[0]+code[1]+code[3]; mycode[1]=mycode[1] % 2; mycode[2]=code[0]+code[1]+code[2]; mycode[2]=mycode[2] % 2; mycode[3]=code[1]+code[2]+code[3]+1; mycode[3]=mycode[3] % 2; for(i=0; i<4; i++){ cout<<code[i]; } for(i=0; i<4; i++){ cout<<mycode[i]; } cout<<endl; //Decoding for(i=0; i<3; i++){ if (mycode2[i] != mycode[i]){ error=error+1; k=k+1; } } switch (error){ case 0: cout<<"The final position was switched."<<endl; break; case 1: cout<<"The card was switched from position "<<k<<endl; break; case 2: k=k-4; cout<<"The card was switched from position "<<k<<endl; break; case 3: cout<<"The card was switched from the zero position."<<endl; break; } return 0; } This is the what I have so far for javascript. Code: <html> <head> <script language="JavaScript"> { //These are the first button graphics thumb1= new Image(); thumb1.src = "75/back-blue-75-3.png"; hover1 = new Image(); hover1.src = "75/clubs-2-75.png"; //These are the second button graphics thumb2= new Image(); thumb2.src = "75/back-blue-75-3.png"; hover2 = new Image(); hover2.src = "75/clubs-q-75.png"; //These are the third button graphics thumb3= new Image(); thumb3.src = "75/back-blue-75-3.png"; hover3 = new Image(); hover3.src = "75/clubs-a-75.png"; thumb4= new Image(); thumb4.src = "75/back-blue-75-3.png"; hover4 = new Image(); hover4.src = "75/diamonds-2-75.png"; thumb5= new Image(); thumb5.src = "75/back-blue-75-3.png"; hover5 = new Image(); hover5.src = "75/joker-b-75.png"; thumb6= new Image(); thumb6.src = "75/back-blue-75-3.png"; hover6 = new Image(); hover6.src = "75/spades-a-75.png"; thumb7= new Image(); thumb7.src = "75/back-blue-75-3.png"; hover7 = new Image(); hover7.src = "75/clubs-3-75.png"; thumb8= new Image(); thumb8.src = "75/back-blue-75-3.png"; hover8 = new Image(); hover8.src = "75/hearts-a-75.png"; thumb9= new Image(); thumb9.src = "75/back-blue-75-3.png"; hover9 = new Image(); hover9.src = "75/hearts-k-75.png"; thumb10= new Image(); thumb10.src = "75/back-blue-75-3.png"; hover10 = new Image(); hover10.src = "75/diamonds-6-75.png"; thumb11= new Image(); thumb11.src = "75/back-blue-75-3.png"; hover11 = new Image(); hover11.src = "75/diamonds-10-75.png"; thumb12= new Image(); thumb12.src = "75/back-blue-75-3.png"; hover12 = new Image(); hover12.src = "75/spades-5-75.png"; thumb13= new Image(); thumb13.src = "75/back-blue-75-3.png"; hover13 = new Image(); hover13.src = "75/joker-r-75.png"; thumb14= new Image(); thumb14.src = "75/back-blue-75-3.png"; hover14 = new Image(); hover14.src = "75/clubs-j-75.png"; thumb15= new Image(); thumb15.src = "75/back-blue-75-3.png"; hover15 = new Image(); hover15.src = "75/clubs-6-75.png"; thumb16= new Image(); thumb16.src = "75/back-blue-75-3.png"; hover16 = new Image(); hover16.src = "75/hearts-5-75.png"; thumb17= new Image(); thumb17.src = "75/back-blue-75-3.png"; hover17 = new Image(); hover17.src = "75/diamonds-k-75.png"; thumb18= new Image(); thumb18.src = "75/back-blue-75-3.png"; hover18 = new Image(); hover18.src = "75/diamonds-8-75.png"; thumb19= new Image(); thumb19.src = "75/back-blue-75-3.png"; hover19 = new Image(); hover19.src = "75/hearts-9-75.png"; thumb20= new Image(); thumb20.src = "75/back-blue-75-3.png"; hover20 = new Image(); hover20.src = "75/spades-j-75.png"; thumb21= new Image(); thumb21.src = "75/back-blue-75-3.png"; hover21 = new Image(); hover21.src = "75/hearts-2-75.png"; thumb22= new Image(); thumb22.src = "75/back-blue-75-3.png"; hover22 = new Image(); hover22.src = "75/hearts-q-75.png"; thumb23= new Image(); thumb23.src = "75/back-blue-75-3.png"; hover23 = new Image(); hover23.src = "75/clubs-8-75.png"; thumb24= new Image(); thumb24.src = "75/back-blue-75-3.png"; hover24 = new Image(); hover24.src = "75/clubs-k-75.png"; thumb25= new Image(); thumb25.src = "75/back-blue-75-3.png"; hover25 = new Image(); hover25.src = "75/diamonds-a-75.png"; thumb26= new Image(); thumb26.src = "75/back-blue-75-3.png"; hover26 = new Image(); hover26.src = "75/spades-2-75.png"; thumb27= new Image(); thumb27.src = "75/back-blue-75-3.png"; hover27 = new Image(); hover27.src = "75/spades-q-75.png"; thumb28= new Image(); thumb28.src = "75/back-blue-75-3.png"; hover28 = new Image(); hover28.src = "75/clubs-7-75.png"; thumb28= new Image(); thumb28.src = "75/back-blue-75-3.png"; hover28 = new Image(); hover28.src = "75/diamonds-j-75.png"; thumb28= new Image(); thumb28.src = "75/back-blue-75-3.png"; hover28 = new Image(); hover28.src = "75/diamonds-3-75.png"; thumb29= new Image(); thumb29.src = "75/back-blue-75-3.png"; hover29 = new Image(); hover29.src = "75/hearts-j-75.png"; thumb30= new Image(); thumb30.src = "75/back-blue-75-3.png"; hover30 = new Image(); hover30.src = "75/clubs-4-75.png"; thumb31= new Image(); thumb31.src = "75/back-blue-75-3.png"; hover31 = new Image(); hover31.src = "75/spades-3-75.png"; thumb32= new Image(); thumb32.src = "75/back-blue-75-3.png"; hover32 = new Image(); hover32.src = "75/spades-k-75.png"; thumb33= new Image(); thumb33.src = "75/back-blue-75-3.png"; hover33 = new Image(); hover33.src = "75/diamonds-4-75.png"; thumb34= new Image(); thumb34.src = "75/back-blue-75-3.png"; hover34 = new Image(); hover34.src = "75/spades-10-75.png"; thumb35= new Image(); thumb35.src = "75/back-blue-75-3.png"; hover35 = new Image(); hover35.src = "75/clubs-5-75.png"; thumb36= new Image(); thumb36.src = "75/back-blue-75-3.png"; hover36 = new Image(); hover36.src = "75/clubs-9-75.png"; thumb37= new Image(); thumb37.src = "75/back-blue-75-3.png"; hover37 = new Image(); hover37.src = "75/diamonds-7-75.png"; thumb38= new Image(); thumb38.src = "75/back-blue-75-3.png"; hover38 = new Image(); hover38.src = "75/diamonds-q-75.png"; thumb39= new Image(); thumb39.src = "75/back-blue-75-3.png"; hover39 = new Image(); hover39.src = "75/spades-6-75.png"; thumb40= new Image(); thumb40.src = "75/back-blue-75-3.png"; hover40 = new Image(); hover40.src = "75/spades-9-75.png"; thumb41= new Image(); thumb41.src = "75/back-blue-75-3.png"; hover41 = new Image(); hover41.src = "75/diamonds-9-75.png"; thumb42= new Image(); thumb42.src = "75/back-blue-75-3.png"; hover42 = new Image(); hover42.src = "75/hearts-3-75.png"; thumb43= new Image(); thumb43.src = "75/back-blue-75-3.png"; hover43 = new Image(); hover43.src = "75/hearts-10-75.png"; thumb44= new Image(); thumb44.src = "75/back-blue-75-3.png"; hover44 = new Image(); hover44.src = "75/diamonds-5-75.png"; thumb45= new Image(); thumb45.src = "75/back-blue-75-3.png"; hover45 = new Image(); hover45.src = "75/spades-7-75.png"; thumb46= new Image(); thumb46.src = "75/back-blue-75-3.png"; hover46 = new Image(); hover46.src = "75/spades-4-75.png"; thumb47= new Image(); thumb47.src = "75/back-blue-75-3.png"; hover47 = new Image(); hover47.src = "75/hearts-8-75.png"; thumb48= new Image(); thumb48.src = "75/back-blue-75-3.png"; hover48 = new Image(); hover48.src = "75/hearts-4-75.png"; thumb49= new Image(); thumb49.src = "75/back-blue-75-3.png"; hover49 = new Image(); hover49.src = "75/hearts-7-75.png"; thumb50= new Image(); thumb50.src = "75/back-blue-75-3.png"; hover50 = new Image(); hover50.src = "75/spades-8-75.png"; thumb51= new Image(); thumb51.src = "75/back-blue-75-3.png"; hover51 = new Image(); hover51.src = "75/hearts-6-75.png"; } //This is the function that calls for change in buttons function imageflip(thumbnailID,imageName) { document.images[thumbnailID].src = eval(imageName + ".src"); } </script> <title>Hey there! Welcome to my world!</title> </head> <body> <font face="arial" size="7"> Pick 4 cards!</font><br><br> <a href="#" onClick="imageflip('icon1','hover1')"> <img src="75/back-blue-75-3.png" border="0" name="icon1"/></a> <a href="#" onClick="imageflip('icon2','hover2')"> <img src="75/back-blue-75-3.png" border="0" name="icon2"/></a> <a href="#" onClick="imageflip('icon3','hover3')"> <img src="75/back-blue-75-3.png" border="0" name="icon3"/></a> <a href="#" onClick="imageflip('icon4','hover4')"> <img src="75/back-blue-75-3.png" border="0" name="icon4"/></a> <a href="#" onClick="imageflip('icon5','hover5')"> <img src="75/back-blue-75-3.png" border="0" name="icon5"/></a> <a href="#" onClick="imageflip('icon6','hover6')"> <img src="75/back-blue-75-3.png" border="0" name="icon6"/></a> <a href="#" onClick="imageflip('icon7','hover7')"> <img src="75/back-blue-75-3.png" border="0" name="icon7"/></a> <a href="#" onClick="imageflip('icon8','hover8')"> <img src="75/back-blue-75-3.png" border="0" name="icon8"/></a> <a href="#" onClick="imageflip('icon9','hover9')"> <img src="75/back-blue-75-3.png" border="0" name="icon9"/></a> <a href="#" onClick="imageflip('icon10','hover10')"> <img src="75/back-blue-75-3.png" border="0" name="icon10"/></a> <a href="#" onClick="imageflip('icon11','hover11')"> <img src="75/back-blue-75-3.png" border="0" name="icon11"/></a> <a href="#" onClick="imageflip('icon12','hover12')"> <img src="75/back-blue-75-3.png" border="0" name="icon12"/></a> <a href="#" onClick="imageflip('icon13','hover13')"> <img src="75/back-blue-75-3.png" border="0" name="icon13"/></a> <a href="#" onClick="imageflip('icon14','hover14')"> <img src="75/back-blue-75-3.png" border="0" name="icon14"/></a> <a href="#" onClick="imageflip('icon15','hover15')"> <img src="75/back-blue-75-3.png" border="0" name="icon15"/></a> <a href="#" onClick="imageflip('icon16','hover16')"> <img src="75/back-blue-75-3.png" border="0" name="icon16"/></a> <a href="#" onClick="imageflip('icon17','hover17')"> <img src="75/back-blue-75-3.png" border="0" name="icon17"/></a> <a href="#" onClick="imageflip('icon18','hover18')"> <img src="75/back-blue-75-3.png" border="0" name="icon18"/></a> <a href="#" onClick="imageflip('icon19','hover19')"> <img src="75/back-blue-75-3.png" border="0" name="icon19"/></a> <a href="#" onClick="imageflip('icon20','hover20')"> <img src="75/back-blue-75-3.png" border="0" name="icon20"/></a> <a href="#" onClick="imageflip('icon21','hover21')"> <img src="75/back-blue-75-3.png" border="0" name="icon21"/></a> <a href="#" onClick="imageflip('icon22','hover22')"> <img src="75/back-blue-75-3.png" border="0" name="icon22"/></a> <a href="#" onClick="imageflip('icon23','hover23')"> <img src="75/back-blue-75-3.png" border="0" name="icon23"/></a> <a href="#" onClick="imageflip('icon24','hover24')"> <img src="75/back-blue-75-3.png" border="0" name="icon24"/></a> <a href="#" onClick="imageflip('icon25','hover25')"> <img src="75/back-blue-75-3.png" border="0" name="icon25"/></a> <a href="#" onClick="imageflip('icon26','hover26')"> <img src="75/back-blue-75-3.png" border="0" name="icon26"/></a> <a href="#" onClick="imageflip('icon27','hover27')"> <img src="75/back-blue-75-3.png" border="0" name="icon27"/></a> <a href="#" onClick="imageflip('icon28','hover28')"> <img src="75/back-blue-75-3.png" border="0" name="icon28"/></a> <a href="#" onClick="imageflip('icon29','hover29')"> <img src="75/back-blue-75-3.png" border="0" name="icon29"/></a> <a href="#" onClick="imageflip('icon30','hover30')"> <img src="75/back-blue-75-3.png" border="0" name="icon30"/></a> <a href="#" onClick="imageflip('icon31','hover31')"> <img src="75/back-blue-75-3.png" border="0" name="icon31"/></a> <a href="#" onClick="imageflip('icon32','hover32')"> <img src="75/back-blue-75-3.png" border="0" name="icon32"/></a> <a href="#" onClick="imageflip('icon33','hover33')"> <img src="75/back-blue-75-3.png" border="0" name="icon33"/></a> <a href="#" onClick="imageflip('icon34','hover34')"> <img src="75/back-blue-75-3.png" border="0" name="icon34"/></a> <a href="#" onClick="imageflip('icon35','hover35')"> <img src="75/back-blue-75-3.png" border="0" name="icon35"/></a> <a href="#" onClick="imageflip('icon36','hover36')"> <img src="75/back-blue-75-3.png" border="0" name="icon36"/></a> <a href="#" onClick="imageflip('icon37','hover37')"> <img src="75/back-blue-75-3.png" border="0" name="icon37"/></a> <a href="#" onClick="imageflip('icon38','hover38')"> <img src="75/back-blue-75-3.png" border="0" name="icon38"/></a> <a href="#" onClick="imageflip('icon39','hover39')"> <img src="75/back-blue-75-3.png" border="0" name="icon39"/></a> <a href="#" onClick="imageflip('icon40','hover40')"> <img src="75/back-blue-75-3.png" border="0" name="icon40"/></a> <a href="#" onClick="imageflip('icon41','hover41')"> <img src="75/back-blue-75-3.png" border="0" name="icon41"/></a> <a href="#" onClick="imageflip('icon42','hover42')"> <img src="75/back-blue-75-3.png" border="0" name="icon42"/></a> <a href="#" onClick="imageflip('icon43','hover43')"> <img src="75/back-blue-75-3.png" border="0" name="icon43"/></a> <a href="#" onClick="imageflip('icon44','hover44')"> <img src="75/back-blue-75-3.png" border="0" name="icon44"/></a> <a href="#" onClick="imageflip('icon45','hover45')"> <img src="75/back-blue-75-3.png" border="0" name="icon45"/></a> <a href="#" onClick="imageflip('icon46','hover46')"> <img src="75/back-blue-75-3.png" border="0" name="icon46"/></a> <a href="#" onClick="imageflip('icon47','hover47')"> <img src="75/back-blue-75-3.png" border="0" name="icon47"/></a> <a href="#" onClick="imageflip('icon48','hover48')"> <img src="75/back-blue-75-3.png" border="0" name="icon48"/></a> <a href="#" onClick="imageflip('icon49','hover49')"> <img src="75/back-blue-75-3.png" border="0" name="icon49"/></a> <a href="#" onClick="imageflip('icon50','hover50')"> <img src="75/back-blue-75-3.png" border="0" name="icon50"/></a> <a href="#" onClick="imageflip('icon51','hover51')"> <img src="75/back-blue-75-3.png" border="0" name="icon51"/></a> </body> </html> Hello, I need your help converting the code below from VBA to Javascript. I am basically attempting to export a recordset to an excel file. VBA: Code: '------------------------------------------------------- Public Sub ExportTOExcel() '------------------------------------------------------- Set oExcel = CreateObject("Excel.Application") Set oBook = oExcel.Workbooks.Add Set oSheet = oBook.Worksheets(1) Dim j As Long Dim lngCol As Long Dim lngRow As Long Dim Field As Object rs.MoveFirst lngRow = 1 With oSheet Do While Not rs.EOF lngCol = 0 For Each Field In rs.Fields lngCol = lngCol + 1 .Cells(lngRow, lngCol) = Field.Value Next lngRow = lngRow + 1 rs.MoveNext Loop End With oBook.SaveAs "C:\Book5.xls" Workbooks.Open fileName:="C:\Book5.xls" End Sub Thanks for everyones help in advance, Cheers, J Hello, I am new javascript and I need your help converting the following code from VBScript to Javascript please. <script language="vbscript"> function CDO_Mail_Small_Text_2() Set iMsg = CreateObject("CDO.Message") Set iConf = CreateObject("CDO.Configuration") iConf.Load -1 ' CDO Source Defaults Set Flds = iConf.Fields With Flds .Item("http://schemas.microsoft.com/cdo/configuration/smtpusessl") = True .Item("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate") = 1 .Item("http://schemas.microsoft.com/cdo/configuration/sendusername") = "myemailadress@gmail.com" .Item("http://schemas.microsoft.com/cdo/configuration/sendpassword") = "mypassword" .Item("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "smtp.gmail.com" .Item("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2 .Item("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 465 .Update End With strbody = "Hi there" & vbNewLine & vbNewLine & _ "This is line 1" & vbNewLine & _ "This is line 2" & vbNewLine & _ "This is line 3" & vbNewLine & _ "This is line 4" With iMsg Set .Configuration = iConf .To = "jason.kelly@tc.gc.ca" .CC = "" .BCC = "" '.ReplyTo = "Reply@something.nl" .From = """ARealName"" <ARealName@gmail.com>" .Subject = "Important message" .TextBody = strbody .Send End With end function </script> Much thanks and appreciation for all your help and support. Cheers, J Hi everyone, I've been trying to amend this so that when I paste text in with a mouse it changes to uppercase automatically. Does anyone know how this can be done? Code: <html> <head> <script type="text/javascript"> function upperCase(x) { var y=document.getElementById(x).value; document.getElementById(x).value=y.toUpperCase(); } </script> </head> <body> Enter your name: <input type="text" id="fname" onchange="upperCase(this.id)" /> </body> </html> Thanks Hi there, I would like to sort the items regardless of uppercase/lowercase after moving them to another listbox. Here is my code, and I cannot figure out what is wrong with it. 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>Untitled Page</title> <script language="javascript" type="text/javascript"> function MoveItem(unselectedLst, selectedLst) { var unselectedEmail = document.getElementById(unselectedLst); var selectedEmail = document.getElementById(selectedLst); var uValue = unselectedEmail.value; var sValue = selectedEmail.value; if ((uValue != null) && (sValue != null)) { if( unselectedEmail.options.selectedIndex >= 0 ) { var newOption = new Option(); // Create a new instance of ListItem newOption.text = unselectedEmail.options[unselectedEmail.options.selectedIndex].text; newOption.value = unselectedEmail.options[unselectedEmail.options.selectedIndex].value; selectedEmail.options[selectedEmail.length] = newOption; //Append the item in selectedEmail unselectedEmail.remove(unselectedEmail.options.selectedIndex); //Remove the item from unselectedEmail //sort items in listbox in alpha order arrTexts = new Array(); for(i=0; i<unselectedEmail.length; i++) { arrTexts[i] = unselectedEmail.options[i].text; } arrTexts.sort(); for(i=0; i<unselectedEmail.length; i++) { unselectedEmail.options[i].text = arrTexts[i]; unselectedEmail.options[i].value = arrTexts[i]; } //sort items in listbox in alpha order arrayTexts = new Array(); for(i=0; i<selectedEmail.length; i++) { arrayTexts[i] = selectedEmail.options[i].text; } arrayTexts.sort(); for(i=0; i<selectedEmail.length; i++) { selectedEmail.options[i].text = arrayTexts[i]; selectedEmail.options[i].value = arrayTexts[i]; } } } else { alert('Select Item From The List. '); } } </script> </head> <body> <table width="300"> <tr> <td> <select id="ListBox1" name="ListBox1" size="6"> <option>One</option> <option>Two</option> <option>Three</option> </select> </td> <td> <p> <input onclick="MoveItem('ListBox1', 'ListBox2');" type="button" value="->" /> </p> <p> <input onclick="MoveItem('ListBox2', 'ListBox1');" type="button" value="<-" /> </p> </td> <td> <select id="ListBox2" name="ListBox2" size="6"> <option>allalong@msn.com</option> <option>boys@hotmail.com</option> <option>cy@yahoo.com</option> <option>bread@hotmail.com</option> <option>eetApple@ymail.com</option> <option>applepie@gmail.com</option> </select> </td> </tr> </table> </body> </html> hi guys im really new to javascript and ive got stuck, function resizeText(multiplier) { if (document.body.style.fontSize == "") { document.body.style.fontSize = "17px"; } document.body.style.fontSize = parseFloat(document.body.style.fontSize) + (multiplier * 0.2) + "5px"; } here is my code it currently incresaes the font size and decreases it with use of 2 buttons on my page, but i want it to only increase in series of 2px at a time with a total of 4 clicks then it must revert to the original size. is that clear ? can anyone help me ? cheers. ant I work at a college radio station and our brand new website just went live, but we're having one particular issue... We have a set list of shows that air each day, and on the site we have a marquee tag on the homepage that scrolls through showing each show and its broadcast time. Right now we're stuck changing this schedule each day by hand, but it's tough considering we're all college students ourselves and sometimes our own schedules simply don't allow the time. Is there a code that would allow this kind of a daily update to happen automatically? The format for the schedule is such: 4 - 5 pm // "Show 01" 5 - 6 pm // "Show 02" 6 - 8 pm // "Show 03" 8 - 10 pm // "Show 04" 10 - 12 am // "Show 05" Any help would be very much appreciated! This might be a little complicated. I'll try to be as clear as possible. I got some help from Old Pedant a little while ago and the code worked great. The problem came after I tried some code that will highlight (select) text in a DIV: Code: <script type="text/javascript"> function selectNode (node) { var selection, range, doc, win; if ((doc = node.ownerDocument) && (win = doc.defaultView) && typeof win.getSelection != 'undefined' && typeof doc.createRange != 'undefined' && (selection = window.getSelection()) && typeof selection.removeAllRanges != 'undefined') { range = doc.createRange(); range.selectNode(node); selection.removeAllRanges(); selection.addRange(range); } else if (document.body && typeof document.body.createTextRange != 'undefined' && (range = document.body.createTextRange())) { range.moveToElementText(node); range.select(); } } </script> Code: <div id="bb1"></div> <form> <input type="button" value="Click Here to Highlight Data" onclick="window.selectNode(document.getElementById('bb1'));" style="margin-left:4px; font-weight:bold; font-family: Verdana, Arial, Helvetica, sans-serif; font-size:14px;"> </form> It works great with Firefox and Internet Explorer, but there is a problem with Opera. The contents of the DIV is selected, but so is everything after the DIV. Below is a link to the page, but be sure to turn down your speaker volume before you visit the page so you won't have a heart attack: http://www.randomterrain.com/atari-2...music-toy.html The DIV is empty when the page loads. To put content in the DIV, jump down to All Sounds and left click on a couple of the numbers than run from 0 to 31, then jump down to the DIV. When you click on the "Click Here to Highlight Data" button, you'll see that more than the contents of the DIV is selected. I hope someone can figure out how to make the code work properly with Opera. Thanks. I have been looking around for a while on google and have come accross a few things but still am unable to find the exact codes. I am trying to have a page setup so that when the user clicks a button it will add preset text to a form box and keep the chronological order of buttons that are clicked. This is going to be used for my ambulance service to assist dispatch so basically i am looking for preset buttons that the dispatcher can click disp. and have the dispatch and time added to a list in the form box that can later be copied and emailed to our cell phones. Thanks for any help. I am looking for a javascript code for this idea under this message ---------------------------------------------------------------------------------------------------------------------------------------------------- I want to create a kind of shopping website so when you click on a image or text it will add some text to a textarea,, it will include the name of item and price of an item Not sure if this should be in the ASP forum or this one (probably could go either), so here goes. I don't know hardly any - probably best to say dont know any at all - javascript. However I have a need to convert some code from asp to js. the code is checking to see if certain variables are null and if so counting how many of those variables are as such. the ASP looks like this: Code: <% Dim counter counter = 0 if a <> "" then classcounter = classcounter + 1 if b <> "" then classcounter = classcounter + 1 if c <> "" then classcounter = classcounter + 1 if d <> "" then classcounter = classcounter + 1 if e <> "" then classcounter = classcounter + 1 if f <> "" then classcounter = classcounter + 1 %> I need to know how to convert this to js so I can show this number to the user without sending data to the server first. I have searched the net for something similar but I am not having much luck finding any examples that do what I would like it to do (maybe this is not something that can/should be done in js?). I hope this makes sense...thanks! Code: <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=windows-1252"> </head> <script type = "text/javascript"> var strCurrency = new Array(6); strCurrency[0]="Pound"; strCurrency[1]="Marc"; strCurrency[2]="Franc"; strCurrency[3]="Dollar"; strCurrency[4]="Nordic"; strCurrency[5]="Fivesmon"; var dblExchangeRate = new Array(6); dblExchangeRate[0]="1"; dblExchangeRate[1]="74"; dblExchangeRate[2]="8.54"; dblExchangeRate[3]="6.25"; dblExchangeRate[4]="98.1"; dblExchangeRate[5]="1.32"; function convertNumbers { } </SCRIPT> I want to see what the function would look like to be able to convert into different currencies by using arrays. I know that this would be a useless way to do it as they are updated every day, but it's for personal education purposes. (Note: The website contained a textbox in which to enter the amount in pounds, a drop-down box allowing the user to select currency, a button to click to convert, and another text box showing amount of money after converting.) Any help is greatly appreciated. I am trying to convert following pesudocose to javascript. Dont know where am i messing it up. Any help will be great PSEUDOCODE: Program TaxCalc Read purchase If(purchase>=0 AND purchase<=7) tax=0 else if(purchase>=8 AND purchase<=21) tax=1 else if(purchase>=22 AND purchase<=35) tax=2 else if(purchase>=36 AND purchase<=49) tax=3 else if(purchase>=50 AND purchase<=64) tax=4 else if(purchase>=65 AND purchase<=78) tax=5 else if(purchase>=79 AND purchase<=92) tax=6 else if(purchase>=93 AND purchase<=99) tax=7 else print error the number should be >=0 and <=99 print tax End Program JAVASCRIPT that I have so far <html> <body> <script type="text/javascript"> // Program name: Tax Calculation // Purpose: Find tax for amounts under $1 // Name: Niral Patel // Date: 2/15 START //Declare variables var purchase; //Amount to be entered by user var tax; //Tax to be calculated //Welcome the user //Ask them to enter an amount less than a dollar document.write("This program will help you calculate tax" + BR); document.write("Please enter the amount, the amount has to be less than a dollar" + BR); purchase = prompt("Enter the amount for which tax is to be calculated:",ES); purchase = parseInt(purchase) if (purchase >= 0 ) { tax = 0 } else if (purchase >= 7 ) { tax = 0 } else if (purchase >= 21 ) { tax = 2 } else if (purchase >= 35 ) { tax = 3 } else if (purchase >= 49) { tax = 4 } else if (purchase >= 64 ) { tax = 5 } else if (purchase >= 78 ) { tax = 6 } else if (purchase >= 92 ) { tax = 7 } else if (purchase >= 93 ) { tax = 6 } else if (purchase >= 99 ) { tax = 6 } else { document.write("Number should be between 0 and 99." +BR); } display tax; Stop </script> </body> </html> Hi, I was wondering - how can I convert something that a user draws inside canvas? Say, they draw a square, how could I convert that to print "You have drawn a square" - this would be posted to a text file. Thanks in advance. deleted
ok, quick and to the point. I have this... Code: <a href="www.mylink.com" class="myclass">click</a> and I wanna change it to a javascript function that can be called via the SAME tag, but with this link: Code: <a href="javascript: myfunction()">click</a> Here's what i have so far: Code: <head> <script type="text/javascript"> function myfunction() { window.location.href='www.mylink.com'; } </script> </head> <body> <a href="javascript: myfunction()">click</a> </body> this works to the point where it only opens the link, but now i can't figure out how to add the class to it. I tried adding it inside the body tag, but it doesn't work. So, I'm wondering if it's possible to set the class in the javascript. Thanks in advance for the help, I really appreciate it I am having an issue with converting my decimal to a percentage... any suggestions? Thanks - it's probably an easy solution, but I am lost below is my code (cost * .06) is where the issue is - Thanks! var cost = prompt("What is the cost of your purchase?", "") document.write("Return Value: "+cost,("<br />")); var salestax = cost * .06 document.write("Return Value: "+salestax,("<br />")); var total = cost + salestax document.write(cost + salestax); I have some data on the client side in javascript arrays that I display to user in a html table on the webpage. I want to give an option to the user to save the data in excel. I thought of a solution that involves: 1. Create an http request and post the data as json 2. On server using jsp convert the json data to html table 3. Set the response headers to open the response in excel This solution works, but does not look optimal. Why to send a http request to server when all the data is there on client side. I tried creating a new document on the client side and open that in a new window. That does not open the document in excel as the response header is not set. Any suggestions on how to achieve this. I want to avoid http request to server. Thanks, Pawinder |