JavaScript - Javascript Converts Php String To Octal
Here is the code:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html lang="EN" dir="ltr" xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="content-type" content="text/html;charset= utf8_unicode_ci"> <title>Why???</title> <script type="text/javascript"> function pass_var(a) alert (a); </script> </head> <body> <?php $a="0150233"; print <<<HERE $a <input type="submit" onclick="javascript: pass_var($a)"> HERE; ?> </body> </html> $a is "0150233". But javascript converts it to 53403. How can I keep value 0150233 in js (and retain string type). Similar TutorialsI need to have a javascript that converts ascii character to octal, example Bobby would be 102157142142171 I do not write java script, but i thought this would be fun for someone that does write java script. I wrote this microday clock some time ago (with some difficulty) as a project, and now I'm attemtping to make an octal version. I'm still learning JavaScript, so I'm not sure exactly which line/s to edit and what script to add to make it fuctional. if anyone here can show me the most concise script needed to convert the output of this JavaClock from decimal to octal it would be very much appreciated the original script to be converted is shown below : ------------------------------------------------------------ Code: <HTML> <HEAD> <META NAME="JAVACLOCK"> <META HTTP=EQUIV="Content-Type" CONTENT="text/html; charset=iso-8859-1"> <META NAME="microday clock" INDEX="all"> <META HTTP-EQUIV="Content-Style-Type" CONTENT="text/css"> <STYLE> BODY { font-family: Digital Readout Expanded; } </STYLE> <TITLE>microday clock</TITLE> </HEAD> <BODY BGCOLOR=BLACK TEXT=BLUE ALIGN=CENTER LINK=ROYALBLUE VLINK=VIOLET> <DIV ALIGN=CENTER> <span id="clock"> <SCRIPT LANGUAGE="JavaScript"> <!-- Begin function Clock() { Now = new Date(); var DecTime = Now.getTime()/86400000 + 1004472; DecTime = '<FONT SIZE=5><FONT COLOR="#3399FF">' + DecTime.toString().substring(1,4) + ' ' + DecTime.toString().substring(4,7) + '</FONT> <FONT COLOR="#33CC00">' + DecTime.toString().substring(8,11) + ' ' + DecTime.toString().substring(11,14) + '</FONT>' if (document.all) document.all.clock.innerHTML=DecTime else if (document.getElementById) document.getElementById("clock").innerHTML=DecTime else document.write(DecTime) } if (!document.all&&!document.getElementById) Clock() function Increment() { if (document.all||document.getElementById) setInterval("Clock()",86) } window.onload=Increment // End --> </script> </span> Hello, I have the following Javascript function: Code: function loadReviews(){ var url='http://search.twitter.com/search.json?callback=?&q=test'; jQuery.getJSON(url,function(json){ jQuery.each(json.results,function(i,review){ jQuery("#divroller_container").append('<div class="reviews" id=item'+i+'>'+review.text+'<br>Reviewed By: '+review.from_user+'</div>'); }); start(30000, 1); }); } I'm trying to use this in a PHP page. I tried to make do an echo ' and then display the Javascript but I'm struggling on how to convert the following line to PHP to that it still works like it should in Javascript: Code: jQuery("#divroller_container").append('<div class="reviews" id=item'+i+'>'+review.text+'<br>Reviewed By: '+review.from_user+'</div>'); I still need the Javascript variables to function the same etc. Any help would be greatly appreciated. Thanks in advance! How to handle String in Javascript
string check in javascript do suggest me something ....... if you have any two words like , "me" and "you". I have an input box with an I.D. of "q" on my website... By entering javascript into the URL bar I can change the place holder text (client side) to say "test" javascript:void(document.getElementById('q').value='test'); Now if I wanted to make it say test (but in bold with html) how would I do that?? I tried: javascript:void(document.getElementById('q').value='<b>test'); But that won't work.. it's a string! I don't know much javascript... Thanks all! Hey, Im using Google Maps and when the user moves the map I have an event listener to return a string of routeIDs that are within the bounds of the map. Later on in the page I have a PHP MySQL statement where it Has [ICODE] SELECT * FROM routes WHERE [ICODE] , and after the WHERE I want to add this string. Basically as the user moves the map around, the list of available routes in bounds should change. How can I do this without redirecting pages at all, as that destroys the functionality of the google map? A typical return of the string would be [ICODE] id = 32 OR id = 58 OR id = 70 [ICODE] etc Any ideas? Thanks all, Rick I am throughly confused....why does this seemingly simple deal not work? Code: <script type="text/javascript"> <!-- window.onbeforeunload = function (){ var checkboxImg = new Image(); var checkboxImgUrl = "checkbox.php%3Flonger%3D" + reviews-chk-longer.checked + "%26discrete%3D" + reviews-chk-discrete.checked + "%26natural%3D" + reviews-chk-natural.checked + "%26thicker%3D" + reviews-chk-thicker.checked + "%26permanent%3D" + reviews-chk-permanent.checked + "%26stamina%3D" + reviews-chk-stamina.checked + "%26harder%3D" + reviews-chk-harder.checked + "%26vascularity%3D" + reviews-chk-vascularity.checked + "%26drive%3D" + reviews-chk-drive.checked + "%26guarantee%3D" + reviews-chk-guarantee.checked + "%26trials%3D" + reviews-chk-trials.checked + "%26affordable%3D" + reviews-chk-affordable.checked; alert(checkboxImgUrl); checkboxImg.src = checkboxImgUrl; } // --> </script> I get no alert when I do this....however the same thing without all of the added strings works fine, ie: Code: <script type="text/javascript"> <!-- window.onbeforeunload = function (){ var checkboxImg = new Image(); var checkboxImgUrl = "checkbox.php"; alert(checkboxImgUrl); checkboxImg.src = checkboxImgUrl; } // --> </script> Can anyone please help? I tried using .concat and that didn't help either Hi I am trying to create a query string similar to the one available he http://andrewu.co.uk/tools/request/e.../example1.html The problem that I am having is that I have more than one button on my page and even though my id's are unique all of my data is displaying on the action page at the same time. The code that i am using for my buttons is: Code: <label for="name_1">Name:</label> <input type="text" name="name1" id="name_1" tabindex="1" size="40" value="Donald Duck" /> <br /> <br /> <input type="submit" id='view1' value="Submit" tabindex="2" /> <label for="name_1">Name:</label> <input type="text" name="name2" id="name_2" tabindex="1" size="40" value="Mickey Mouse" /> <br /> <br /> <input type="submit" id='view2' value="View" tabindex="2" /> I have a lot more than 2 buttons on my page. when a button is clicked I would like to be able to get the values from the query string and only see the values for the button that was clicked like this one: http://andrewu.co.uk/tools/request/e...ndrew+Urquhart but instead I am getting Name: Donald Duck, Name: Mickey Mouse. What would I have to add or change to obtain just one Name to display at a time but have it be different depending on which button is pressed? Hi everyone, I have a hunch that my function is not returning the string value. Below runs some information about the code: getvalues_2() - A function that recognizes the value of the string selected by the user from the drop down list and sends it to a variable. Variable name is 'groom_profession' here. Based on the value (text) returned, it assigns a particular number to the variable 'profession' in this case. But, I have been noticing that irrespective of the value chosen from the drop down list, the variable 'profession' is assigned a default value from the switch case statement. I know the variable (textval_2) is able to store the correct value from the drop down list with the help of an alert command. But, it fails while returning the value. I even tried initializing the string in the function body but to no avail. What could be wrong here? Following is the code for one of the drop-down lists: Code: <b> Groom's current Profession </b> <FORM NAME="Profession"> <SELECT NAME="Groomprofession" onchange = "getvalues_2()"> <OPTION VALUE="c1">Select </OPTION> <OPTION VALUE="c2">Doctor </OPTION> <OPTION VALUE="c3">Engineer </OPTION> <OPTION VALUE="c4">Lawyer </OPTION> <OPTION VALUE="c5">CA </OPTION> <OPTION VALUE="c6">IAS </OPTION> <OPTION VALUE="c7">Engineer + MBA </OPTION> <OPTION VALUE="c8">Family Business </OPTION> <OPTION VALUE="c9">None of the above </OPTION> </SELECT> </FORM> Following is the code for function getvalues_2() declaration: Code: <script type = "text/javascript"> function getvalues_2() { var val_2 = document.Profession.Groomprofession.value; var si_2 = document.Profession.Groomprofession.selectedIndex; if (si_2 != 0) { var textval_2 = " "; textval_2 = document.Profession.Groomprofession.options[si_2].text; //alert (val_2); // for testing //alert (textval_2); // for testing return (textval_2); } } </script> Following is the code for the switch case statement: Code: <script type="text/javascript"> var profession; groom_profession = getvalues_2(); switch(groom_profession) { case "Engineer" : profession = 1.8; break; case "Doctor" : profession = 1.9; break; case "Lawyer" : profession = 1.65; break; case "CA" : profession = 1.7; break; case "IAS" : profession = 2.0; break; case "Family Business" : profession = 1.5; break; case "Engineer + MBA" : profession = 1.95; break; case "None of the above" : profession = 1.95; break; default: profession = 0.6; } </script> The website has a total of 11 drop-down lists (so 11 functions like getvalues, and 11 switch case statements. I thought if I could get one to work, the others might follow suit too). I would be really grateful if someone could look into my problem and suggest where I am going wrong. Thanks a lot! Why do I get both the greedy and non-greedy? How do I extract "somestring" only? I'm on IE7. thanks Code: <script type="text/javascript"> var x = "(EVAL)(H:somestring)Some other Text here"; var full =(x.match(/\(H\:(.*?)\)/g)); // produces "(H:somestring)" as expected alert(full); var inside = (x.match(/\(H\:(.*)\)/)); // produces "(H:somestring),somestring" .. I only want "somestring" alert(inside); </script> From this string: "(EVAL)(H:somestring)Other Text here" I need to extract (H:somestring) and somestring into variables where somestring will could be and set of characters. Below is not working. Code: <script type="text/javascript"> var x = "(EVAL)(H:pines)Some other Text here"; alert(x.match(/H\:(.*?)/g)); </script> Thanks for any help or information. Hello. I need help PLEASE ! I need to convert a string Quote: lalaw|lalaw1|lalaw2|lalaw3 in to Array The values I have in variable "tables" I want to create variable list which takes values from "tables" Than I want to split this, and put each value in to new array: I've started with: Code: var list = "tables"; var listArray = list.split("|"); for(i=0; i < listArray.length;i++) { //? how to put now values in to array? } Best Regards Leos Hi all, can anyone tell me why the connection string for the jscript doesn't work but vbscript does? I'm using IE7 only. ------------------------------------ Code Start ----------------------------- <html> <head> <title></title> <script language="vbscript"> Sub GetVBscriptData() Set oADOCon = CreateObject("ADODB.Connection") Set oRecSet = Createobject("ADODB.recordset") oADOCon.ConnectionString = "Provider=SQLOLEDB;Server=PIBDKM894\SQLEXPRESS;Database=SOEAudit;Uid=SOEAuditAdmin;Pwd=password" oADOCon.Open oRecSet.Open "SELECT * FROM Customers", oADOCon sList = "" Do Until oRecSet.EOF sList = sList & oRecSet("NewFirstName") & vbCrLf oRecSet.MoveNext Loop MsgBox sList End Sub </script> <script language="javascript"> function GetJScriptData() { var oADOCon = new ActiveXObject("ADODB.Connection"); var oRecSet = new ActiveXObject("ADODB.Recordset"); var ConnectionString = "Provider=SQLOLEDB;Server=PIBDKM894\SQLEXPRESS;Database=SOEAudit;Uid=SOEAuditAdmin;Pwd=password" ; oADOCon.Open(ConnectionString); oRecSet.Open("SELECT * FROM Customers",oADOCon); var sList = ""; while (!oRecSet.EOF){ sList = sList + oRecSet("NewFirstName"); oRecSet.MoveNext(); } alert(sList); } </script> </head> <body> <input type="button" onclick="GetVBscriptData()" value=" Get some data via vbscript"> <input type="button" onclick="GetJScriptData()" value=" Get some data via javascript"> </body> </html> ------------------------------------- Code End ------------------------------ The error I receive is: Message: [DBNETLIB][ConnectionOpen (Connect()).]SQL Server does not exist or access denied. Line: 26 (opening the javascript connection) I can only presume it's the syntax of the connection string. Any ideas how to alter the string to get it connecting? Thanks in advance, t-racer Hi, I have a javascript program that currently takes the contents of a *.txt file and converts it to a string-type variable using a hidden iframe. For my pruposes it would be much nicer to read a *.csv file instead, however the method I'm using creates the "open/save file" pop-up window. All files are client-side and in the same folder on one computer; this is NOT server-side or internet-based. It is simply javascript used in an HTA file as programming code. The *.csv does not need to be edited, just read. I need to know how to convert the text of this *.csv file into a string variable. I have heard of using "xmlHTTPRequest (AJAX)" but am not familiar with how to use this. Any advice or code would be greatly appreciated. Hi all, I'm slowly learning javascript, but this one is beyond me. Basically, I need some javascript code that will produce a hash when the user inputs something into a text box. So, the user inputs a string into a text field. Before the hash is produced, javascript takes this string, and adds a SPECIFIC (obviously I need to specify this) string to the end of the user entered string. So the string that is passed through the md5 generator is USER STRING+SPECIFIC STRING. This will then obviously produce a hash string. What I then need to do, is take this hash string, along with the USER STRING (that was input by the user) and adds both these strings into a url. Basically, I'm wanting to produce a url which looks something like this http://www.examplesite.com/ 'USERSTRING' & 'Generated Hash String'.html I've spent days upon days researching this...but its beyond my capabilities at the moment. Hi I want to pass a strings from JS client to PHP server and vice versa. Problem is that I can't find a simple method of escaping them that gives consistent results. I've tried escape, unescape, urlencode and urldecode, but there are problems with some characters eg + From what I've read, JSON is the most reliable way to do this. I've figured out how to use json_encode to get a php string to a javascript variable, but I can't go the other way. How do I get the JSON string that represents a javascript object? Thanks for any help. I wasn't quite sure where to post this request as its JSON, javascript and php, so please tell me if I'm in the wrong place. The code is JScript .NET, which is basically a .NET version of Javascript. Regardless of language, Anyone with appending type of skill can answer my question. The problem is, when I keep issuing the request it keeps appending over and over again Code: if (oSession.uriContains("search?q=")) { var str = oSession.fullUrl; var sAppend = "+test1+test2+test3"; if (!oSession.uriContains(sAppend)) { oSession.fullUrl = str.replace( "search?q=","search?q="+sAppend); } } Can you please give me an example? I'm still new to programming. Thank you Hi, I have a page with an iframe in it. I need my script to search the contents of the iframe for a specified string, and click the link within it. Here is my coding. Code: <script> setTimeout(function() { window.location.reload(); }, 2000); // 2 seconds, e.g. $(document).ready(function() { $('a[href*="13468100"]', $("game").contents()).closest('tr').find('.fightActionInnerInner').parent("a").trigger("click"); }); </script> </head> <body> <iframe src="http://vl.storm8.com/hitlist.php" width="100%" height="800px" id="game"></iframe> In the post below is the content of the iframe. At the moment the script doesn't want to click the link, it just refreshes the page. Can anyone advise? |