Jump to content

Search the Community

Showing results for tags 'string'.

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


Forums

  • W3Schools
    • General
    • Suggestions
    • Critiques
  • HTML Forums
    • HTML/XHTML
    • CSS
  • Browser Scripting
    • JavaScript
    • VBScript
  • Server Scripting
    • Web Servers
    • Version Control
    • SQL
    • ASP
    • PHP
    • .NET
    • ColdFusion
    • Java/JSP/J2EE
    • CGI
  • XML Forums
    • XML
    • XSLT/XSL-FO
    • Schema
    • Web Services
  • Multimedia
    • Multimedia
    • FLASH

Find results in...

Find results that contain...


Date Created

  • Start

    End


Last Updated

  • Start

    End


Filter by number of...

Joined

  • Start

    End


Group


AIM


MSN


Website URL


ICQ


Yahoo


Jabber


Skype


Location


Interests


Languages

Found 11 results

  1. Hi all i need to duplicate a string using javascript problem is the string was taken from an xml node so, lots of things can go wrong. this is the string: <RunList Class="Parameter" Pages="0 ~ 3" Run="1" xmlns="http://www.CIP4.org/JDFschema_1_1"> <LayoutElement> <FileSpec URL="file://xxx/xxx/Jobs/xxx/xxx/xxx/xxx/xxx/xxx.pdf"></FileSpec> </LayoutElement> </RunList> any sugetions? thanks guy
  2. I have a use case where my content editable div accepts only string inside it but it shows the html elements as they are supposed to be shown on website but as per the configurations mentioned in package. They have mentioned the attributes but not click events. Now, if I have string as `some text here <button onclick=someFunction()>button</button>`. Here someFunction is directly being called without triggering button because I think it is in string. How can I call `someFunction()` only when button is clicked.
  3. function loadDoc(n_file) { var xhttp = new XMLHttpRequest(); xhttp.onreadystatechange = function() { if (this.readyState == 4 && this.status == 200) { var myObj = JSON.parse(this.responseText); var parametr = "september" var neco = myObj.september.17[0].dayname; var neco2 = "myObj." + parametr + ".17[0].dayname"; debugger; x = zacinajiciDen(neco); than i have this in my variables: neco1: "pa" neco2: "myObj.september17[0].dayname" i would like to have value "pa" inside like in neco1 but i would like to be able to change name of month. Is it possible Hi all, I have a simple problem. I would like to have a value of Object "myObj.september17[0].dayname" in my variable neco2. but there is of course more month which i need access and i need to changing this variable but when i use "myObj." + parametr + "17[0].dayname"; it is saved a string to variable instead of value. I am very new in JS, learning two days now so please be patient with me.
  4. Hi, i'm reading back and forward but not really coming t a solution. I would like to grab the content of an input field (not inside a form) i am using for date, but just as string. the needed output format is always DD/MM/YYYY so said : 12.02.16 or 2016 12.2.16 or 2016 12-02-16 and so on should all result in 12/02/2016 if there would be a timestamp behind it just needs to be cutted off. I really thought this would be easier :-) But it isn't Maybe somebody could point out a good article or solution for me. Thx. I'm really struggling with the regular expressions :-) var txt='31-12/2016'; var re1='(\\d)'; // Any Single Digit 1 var re2='(\\d)'; // Any Single Digit 2 var re3='(.)'; // Any Single Character 3 var re4='(\\d)'; // Any Single Digit 1 var re5='(\\d)'; // Any Single Digit 2 var re6='(.)'; // Any Single Character 4 var re7='((??:[1]{1}\\d{1}\\d{1}\\d{1})|(?:[2]{1}\\d{3})))(?![\\d])'; // Year 1 var p = new RegExp(re1+re2+re3+re4+re5+re6+re7,["i"]); var m = p.exec(txt); if (m !== null) { var c1=m[1]; var c2=m[2]; var c3="/"; var d1=m[4]; var d2=m[5]; var c4="/"; var year1=m[7]; alert(c1+c2+c3+d1+d2+c4+year1+"\n"); } else { alert("Please check format"); }
  5. I want to transfer a string (several values ) into a php array. I know explode is used to do that. But is explode the only way or are there other ways to do this in php?
  6. Hello, I'm currently learning JavaScript and I plan to work a lot with arrays. I store all arrays in external files and use JSON to access them. Now I wanted to read the names of all arrays that are nested in one main array to create a navigation list but I don't know how to do that. This is an example of a JSON file I use: {"MainArray":[ {"SubArray1":[{ ... }] }, {"SubArray2":[{ ... }] }, {"SubArray3":[{ ... }] } ]} How do I get the names of all SubArrays? I tried this // arr is a JSON-parsed string function myFunction(arr) { var out = ""; var i; for(i = 0; i < arr.MainArray.length; i++) { out += arr.MainArray[i].toString() + '<br>'; } document.getElementById("aso").innerHTML = out; } but it only creates a list of "[object Object]" items. Should I create another JSON file where all array names are listed instead?
  7. Hey, so I have a code where you click a button, it tells you to translate a word, then tells you if you are correct or incorrect. I am adding something so that when you get a word correct, it goes on the left side, when you get a word wrong, it goes on the left side. My code works, aside from one thing. When you get a word right, it lists it on the left side, but the next word replaces the previous word. Here is one of my functions: function spanishLocation(){ var num = Math.floor(Math.random() * locations.length); var locations_obj = locations[num]; var answer = prompt("Translate: " + locations_obj.spanish).toLowerCase(); if (answer == locations_obj.english){ document.getElementById("icorrect").innerHTML = "Correct"; document.getElementById("AddCorrect").innerHTML = locations_obj.spanish + ": " + locations_obj.english; document.getElementById("CorrectAnswer").innerHTML = ""; } else{ document.getElementById("icorrect").innerHTML = "Incorrect"; document.getElementById("CorrectAnswer").innerHTML = locations_obj.english; } } How do I change the document.getElementById("AddCorrect").innerHTML = locations_obj.spanish + ": " + locations_obj.english; so that it adds the word and its translation to a div, rather than replacing it? Does that make sense?
  8. Hi! My problem is that I've made a function with "var kgTotales = 0". But when I sum "kgTotales = kgTotales + 2" the result is "02", it returns a string and not a number. I use this var in a bucle so the result is "kgTotales = 02...." and next to it the next numbers I want to sum. This is the code: <script type="text/javascript"> function multiplicar() { var contador1; var contador2 = 2; var contador3 = 1; var n1; var n2; var id1; var id2; var id3; var kgTotales = 0; var precioTotal = 0; for(contador1=1; contador1 < 60; (contador1)+2){ id1="n" +(contador1); id2="n" +(contador2); id3="result" +(contador3); contador1=(contador1)+2; contador2=(contador2)+2; contador3++; n1=document.getElementById(id1).value; n2=document.getElementById(id2).value; document.getElementById(id3).value = (n1*n2); precioTotal = precioTotal + (n1*n2); kgTotales = kgTotales+n2; document.getElementById("precioTotal").value = precioTotal + " Euros"; document.getElementById("kgTotales").value = kgTotales + " Kg"; } } </script> And this is the result: I don't understand why it happens because precioTotal is a similar var and also shows a sum and works well. I hope someone could helps me. Regards!
  9. I am trying to process a string which contains various data relating to an elearning record; Moodle SCORM suspend_data if you're familiar with it Since I do not have access to server side SQL/CLR functions through the Moodle interface, I am attempting to reference, and extract, the relevant information from the string by explicitly referencing the character locations of the information I need in the string and then converting them as required so they can be summed e.g. SELECT prefix_user.username,........ ((CASE(SUBSTRING(value_rep,237,1)) WHEN 'c' THEN 1 ELSE 0 END) + ........(CASE(SUBSTRING(value_rep,3659,1)) WHEN 'c' THEN 1 ELSE 0 END)) AS "# Videos watched"........FROM ((prefix_user LEFT JOIN (SELECT prefix_scorm_scoes_track.userid, Replace(value,"''","'XX'") AS value_repFROM prefix_scorm_scoes_track WHERE (((prefix_scorm_scoes_track.element)='cmi.suspend_data'))) AS vid ON prefix_user.id = vid.userid The string contains multiple occurrences of the string patterns '','n' and 'nn' where n is any digit 0-9 which I need to replace with the same string pattern e.g. 'XX', so that the total length of the string as a whole remains the same. I Initially thought that the pattern would always exist as '' or 'nn' so it was relatively simple to use a REPLACE(value,"''","XX") I understand it's not possible to use regex in the REPLACE function and have been investigating the use of PATINDEX with STUFF, but understand this is inly suitable for operating on 1 occurrence of a pattern. The report can be output to a CSV for viewing in Excel, so my conclusion is currently to carry out post-processing with Excel VBA where I will have access to loops and other functions. Is what I am trying to achieve possible without the use of a function on the SQL server?
  10. Hello guys, i need some basic info here. I need to build string, which must be builded into "'%name%'", when name is a variable. Using concat, its easy to do that:String myString = "'%" + name + "%'";how to do that with String.format() ?I`m trying to do like: String myString = String.format("'%%s%'", name); << it appears a problem with "%'" tag. how to avoid that ? How to use double %`s in the quotas ?Any suggestions ? Linas.
  11. function keyE(e,n,v) {// some function here}; function editProp(n) {// the caller is a button with function onClick="editProp('userID')"// n = 'userID'var dStr = document.getElementById(n).innerHTML;document.getElementById('f_' + n).innerHTML = '<input type="text" name="i_' + n + '" id="i_userID" value="' + dStr+ '" onkeypress="keyE(event,' + n + ',this.value)" />'; //error heredocument.getElementById('i_' + n).focus();document.getElementById('i_' + n).setSelectionRange(0,dStr.length);} // debug with Mozilla Firefox 15.0.1 Developer Tools The editProp(n) function generate error and I don't know how to fix it. The error is at document.getElementById('f_' + n).innerHTML = '<input type="text" name="i_' + n + '" id="i_userID" value="' + dStr+ '" onkeypress="keyE(event,' + n + ',this.value)" />'; The phrase onkeypress="keyE(event,' + n + ',this.value)" generate error "userID is not defined". userID is a string defined in n variable but it detect it as a variable. How to fix it? Thanks for any help provided.
×
×
  • Create New...