JavaScript - Small Piece Of Code..is This Possible?
I have a piece of code that pulls reviews and allows a business owner to drop the reviews on to their website. I need to limit the number of reviews and ideally I'd like to do that with just the snippet the biz owner drops into their site. Is this possible? Here's a sample of the code:
<div id="repagent_reviews"></div><script type="text/javascript" src="http://awebsite.com/anotherwebsite/wp-admin/admin-ajax.php?action=repagent_reviews_js&id=1182"></script> thanks! confused Similar TutorialsHi, below is some code I've found at w3schools site. It demonstrates the use of "onkeypress" event by allowing only non-numerical input. It works great and is mostly clear to me, except for the part I marked in red. Could someone please explain this part to me step by step? It's probably a noobish question, but I thought you could only use "return" inside a function. Are "return true" and "return false" just optional parameters to the "onkeypress" event? If so, where else can they be used? Also what information exactly does the "(event)" being passed into the function "noNumbers()" carry? <html> <body> <script type="text/javascript"> function noNumbers(e) { var keynum; var keychar; var numcheck; if(window.event) // IE8 and earlier { keynum = e.keyCode; } else if(e.which) // IE9/Firefox/Chrome/Opera/Safari { keynum = e.which; } keychar = String.fromCharCode(keynum); numcheck = /\d/; return !numcheck.test(keychar); } </script> <form> Type some text (numbers not allowed): <input type="text" onkeypress= "return noNumbers(event)" /> </form> I need to understand this code but i am not able to fully understand it to use it for myself. Anybody can you help please function getScore(form) { var score = 0; var currElt; var currSelection; for (i=0; i<numQues; i++) { currElt = i*numChoi; for (j=0; j<numChoi; j++) { currSelection = form.elements[currElt + j]; if (currSelection.checked) { if (currSelection.value == answers[i]) { score++; break; } } } } score = Math.round(score/numQues*100); // math.round function will return the whole number to the nearest specified value for example 1.9 will show as 2 form.percentage.value = score + "%"; // The score will be displayed in percentage var correctAnswers = ""; for (i=1; i<=numQues; i++) { correctAnswers += i + ". " + answers[i-1] + "\r\n"; } form.solutions.value = correctAnswers; } Any short explanation will be a great help. Here's the basic concept, its somewhat of a counter, and I think javascripts the way to go... Basically I'm looking to generate a running number... x + 11 = print the number The tricky part is, I need it to never stop, somewhat like a timer (example http://www.hashemian.com/tools/javascript-countdown.htm) but not a timer... Think the tally mark on McDonald's 99 billion served.. Any suggestions or ideas? I don't know anything about Javascript. My brother-in-law wanted me to update some pictures on his website. I found a piece of javascript code and am curious as to what it's function would be. Could someone please tell me what this piece of code is doing / what it's being used for. Thanks in advance. Here's the code: Code: <csscriptdict> <script><!-- function CSClickReturn () { var bAgent = window.navigator.userAgent; var bAppName = window.navigator.appName; if ((bAppName.indexOf("Explorer") >= 0) && (bAgent.indexOf("Mozilla/3") >= 0) && (bAgent.indexOf("Mac") >= 0)) return true; // dont follow link else return false; // dont follow link } CSStopExecution = false; function CSAction(array) { return CSAction2(CSAct, array); } function CSAction2(fct, array) { var result; for (var i=0;i<array.length;i++) { if(CSStopExecution) return false; var actArray = fct[array[i]]; if(actArray == null) return false; var tempArray = new Array; for(var j=1;j<actArray.length;j++) { if((actArray[j] != null) && (typeof(actArray[j]) == "object") && (actArray[j].length == 2)) { if(actArray[j][0] == "VAR") { tempArray[j] = CSStateArray[actArray[j][1]]; } else { if(actArray[j][0] == "ACT") { tempArray[j] = CSAction(new Array(new String(actArray[j][1]))); } else tempArray[j] = actArray[j]; } } else tempArray[j] = actArray[j]; } result = actArray[0](tempArray); } return result; } CSAct = new Object; CSAg = window.navigator.userAgent; CSBVers = parseInt(CSAg.charAt(CSAg.indexOf("/")+1),10); function IsIE() { return CSAg.indexOf("MSIE") > 0;} function CSIEStyl(s) { return document.all.tags("div")[s].style; } function CSNSStyl(s) { return CSFindElement(s,0); } function CSFindElement(n,ly) { if (CSBVers < 4) return document[n]; var curDoc = ly ? ly.document : document; var elem = curDoc[n]; if (!elem) { for (var i=0;i<curDoc.layers.length;i++) { elem = CSFindElement(n,curDoc.layers[i]); if (elem) return elem; }} return elem; } function CSSetImageURL(action) { var img = null; if (document.images) { if (!IsIE()) img = CSFindElement(action[1],0); else img = document.images[action[1]]; if (img) img.src = action[2]; } }function CSGotoLink(action) { if (action[2].length) { var hasFrame=false; for(i=0;i<parent.frames.length;i++) { if (parent.frames[i].name==action[2]) { hasFrame=true; break;}} if (hasFrame==true) parent.frames[action[2]].location = action[1]; else window.open (action[1],action[2],""); } else location = action[1]; } // --></script> </csscriptdict> <csactiondict> <script><!-- CSAct[/*CMP*/ 'B52BCE950'] = new Array(CSSetImageURL,/*CMP*/ 'cac logo',/*URL*/ 'Images/components/geebee.jpg'); CSAct[/*CMP*/ 'B527CA9F3'] = new Array(CSSetImageURL,/*CMP*/ 'cac logo',/*URL*/ 'Images/components/cutline.gif'); CSAct[/*CMP*/ 'B527CAD04'] = new Array(CSSetImageURL,/*CMP*/ 'cac logo',/*URL*/ 'Images/components/f-4.jpg'); CSAct[/*CMP*/ 'B527CAE85'] = new Array(CSSetImageURL,/*CMP*/ 'cac logo',/*URL*/ 'Images/components/cutline.gif'); CSAct[/*CMP*/ 'B527CBCF6'] = new Array(CSSetImageURL,/*CMP*/ 'cac logo',/*URL*/ 'Images/components/boeing-314.jpg'); CSAct[/*CMP*/ 'B527CBEF7'] = new Array(CSSetImageURL,/*CMP*/ 'cac logo',/*URL*/ 'Images/components/cutline.gif'); CSAct[/*CMP*/ 'B527CC588'] = new Array(CSGotoLink,/*URL*/ 'goldenage.htm',''); CSAct[/*CMP*/ 'B527CD869'] = new Array(CSGotoLink,/*URL*/ 'aboutus.html',''); CSAct[/*CMP*/ 'B527D7110'] = new Array(CSSetImageURL,/*CMP*/ 'cac logo',/*URL*/ 'Images/components/HE-111.jpg'); CSAct[/*CMP*/ 'B527D7281'] = new Array(CSSetImageURL,/*CMP*/ 'cac logo',/*URL*/ 'Images/components/cutline.gif'); CSAct[/*CMP*/ 'B527D73B2'] = new Array(CSGotoLink,/*URL*/ 'wwiiidmodels.htm',''); CSAct[/*CMP*/ 'B527D75D3'] = new Array(CSSetImageURL,/*CMP*/ 'cac logo',/*URL*/ 'Images/components/lancaster.jpg'); CSAct[/*CMP*/ 'B527D77E4'] = new Array(CSSetImageURL,/*CMP*/ 'cac logo',/*URL*/ 'Images/components/cutline.gif'); CSAct[/*CMP*/ 'B527D7895'] = new Array(CSGotoLink,/*URL*/ 'wwiiexpert.htm',''); CSAct[/*CMP*/ 'B527D9120'] = new Array(CSGotoLink,/*URL*/ 'modeler.html',''); CSAct[/*CMP*/ 'B527D9291'] = new Array(CSGotoLink,/*URL*/ 'faq.html',''); CSAct[/*CMP*/ 'B527D9372'] = new Array(CSGotoLink,/*URL*/ 'contact.html',''); CSAct[/*CMP*/ 'B527D94A3'] = new Array(CSGotoLink,/*URL*/ 'custom.htm',''); CSAct[/*CMP*/ 'B527D96E5'] = new Array(CSGotoLink,/*URL*/ 'seaplanes.htm',''); CSAct[/*CMP*/ 'B52D133826'] = new Array(CSGotoLink,/*URL*/ 'postwarmodels.htm',''); CSAct[/*CMP*/ 'B530F9380'] = new Array(CSSetImageURL,/*CMP*/ 'cac logo',/*URL*/ 'Images/components/F-104.jpg'); CSAct[/*CMP*/ 'B530F9501'] = new Array(CSSetImageURL,/*CMP*/ 'cac logo',/*URL*/ 'Images/components/cutline.gif'); // --></script> </csactiondict> Here's the website that it's on: http://www.aircraftmodels.com/index.htm Hi, I have this code: Code: window.addEvent('domready',function(){ document.id('cool').addEvent('click',function() { light = new LightFace.IFrame({ height:400, width:800, url: 'http://google.com', title: 'Google!' }).addButton('Close', function() { light.close(); },true).open(); }); }); It's a piece from something called the lightface iframe. What I want to do is to have this code on my javascript page, that's included on the main page where I want to call it. I call on it like this: Code: <a href="#" id="cool">Edit general info</a> However this only works if it's on the main page, not when I have it on my js page. So what I want to do is to turn it into a function, because that I know works. Could anyone help me with this? Thanks in advance for your time! Hi, can anyone help me with this? The following html is to upload an image, it works ok on firefox, but while using google chrome, nothing happened when I clicked "upload LOGO" button. .................................................................................................... .... <html> <body> <form method="post" action="action_start_initial_registration.php" name="initial_registration" id="initial_registration" enctype="multipart/form-data"> <input type="file" style="display:none" onchange="checkLogo()" name="input_logo_file" id="input_logo_file" value="input_logo_file"> <input type="text" name="logo_flag" id="logo_flag" value="0" style="display:none;"/> <a href="javascript:void(0);" onclick="input_logo_file.click()"><em>upload LOGO</em></a><br /> </form> <script type="text/javascript"> function checkLogo(){ document.getElementById("logo_flag").value="1"; document.getElementById("initial_registration").submit(); } </script> </body> </html> ............................................................................................. Hey all, I have this code on my site that simply says if we are open or not. Code: <script language="Javascript"> <!-- /* Credit must stay intact Visit java-scripts.net or http://wsabstract.com for this script */ now = new Date if (now.getHours() <21) { document.write("We are Currently : Open") } else if (now.getHours() <9) {* * document.write("We are currently : Closed")} else { * *document.write("We are currently : Closed")} //--> </script> I wish to know how I can change this code so that I can add some colour and change the size of the font. Any help would be great. ok i am trying to make a countdown timer from 20 seconds when i click start where am i going wrong with this Code: <html> <head> </head> <body> <script type="text/javascript"> function timer() { var milisec=0 var seconds=20 document.counter.d2.value=20 function display() { if (milisec<=0){ milisec=9 seconds-=1 } if (seconds<=-1){ milisec=0 seconds+=1 } else milisec-=1 document.counter.d2.value=seconds+"."+milisec setTimeout("display()",100) display() }} </script> <form name="counter"> <center> Text Timer<br> <input type="text" size="30" name="d2"> <br> <input type="button" onclick="timer()" value="click me to start"> </center> </form> </body> </html> sorry i think this is in the wrong section...how do i remove I'd be grateful if someone can help me fix this peice of JavaScript code... function gotoURL(){ var newURL = document.GotoForm.theURL.value if (newURL == "100BC" || newURL == "480BC" || newURL == "1642" || newURL == "1679" || newURL == "1752" || newURL == "future") { window.location.href = "date/" + newURL + ".php"; } else if (newURL == "100bc" || newURL == "480bc") { newURL.replace(/bc/g/, "BC"); } else if (newURL == "FUTURE") { newURL.replace(/FUTURE/g/, "future"); } else{ alert("You entered an invalid year, try inputting another year"); }} Thanks. Hello. I have created a button so that when a person click it, it should turn the text into Bold font weight - Fortunately it works, However i tried adding an alternative which is when the text is already turned into Bold font weight the person could click the button in order to switch the text into normal mode, simply cancel the Bold - Unfortunately it doesn't work at all - Can Some one review my little script and help me solve it out ? PHP Code: <script type="text/javascript"> function bold(id) { if (document.getElementById) { document.getElementById(id).style.fontWeight = 'bold'; } else if (document.all) { document.all[id].style.fontWeight = 'bold'; } } //@@@@@@@@@@@(Now the rest of the code down bellow is what i have added so that i could click an cancel the bold mode or (document.all) { document.all[id].style.fontWeight = 'normal'; } </script> and that's the image code : PHP Code: <img src="Bold.bmp"width="42" height="39" title="Bold Font" onclick="bold('bodytext')" style="cursor:pointer;" /> Hi all, I got a small problem. Please help me. Below is the code for toggle text. My problem is Whenever I click Toggle div 1 a Contents of div1 opens. I want a code to hide Contents of div1 when I click Toggle div 2(Shows only Contents of div2) or Toggle div 3 (Shows only Contents of div3) and vice versa. Code: <div align="left" id='div1' style='display:none'>Contents of div1</div> <div align="left" id='div2' style='display:none'>Contents of div2</div> <div align="left" id='div3' style='display:none'>Contents of div3</div> <button onclick="toggle(1)">Toggle div 1</button> <button onclick="toggle(2)">Toggle div 2</button> <button onclick="toggle(3)">Toggle div 3</button> <script> function toggle(x){ var divx = document.getElementById('div'+x) if (divx.style.display == 'none') { divx.style.display = 'block' } else { divx.style.display = 'none' } } </script> Hello all i've made Contact me form with JS validation , my qs is : i do not want the alert pop up small window a post text the alert in DIV i have read it's innerHTML here the JavaScript Code: function isEmpty( inputStr ) { if ( null == inputStr || "" == inputStr ) { return true; } return false; } // Vadate name function checkname (strng){ var error=""; if (strng == ""){ error = "Please Enter your name." } return error; } //Vadate last name function checkprename (strng){ var error=""; if (strng == ""){ error = " Please Enter your name" } return error; } function checkPhone (strng) { var error = ""; if (strng == "") { error = "Vous n'avez pas inscrit un numero de telephone.\n"; } var stripped = strng.replace(/[\(\)\.\-\ ]/g, ''); //strip out acceptable non-numeric characters if (isNaN(parseInt(stripped))) { error = "vous entrez le numero de telephone errone."; } if (!(stripped.length == 10)) { error = "vous entrez le numero de telephone errone.\n"; } return error; } //Validate Email function checkEmail (strng) { var error=""; if (strng == "") { error = "Vous n'avez pas entre une adresse email.\n"; } var emailFilter=/^.+@.+\..{2,3}$/; if (!(emailFilter.test(strng))) { error = "S'il vous plait entrer une adresse email valide.\n"; } else { //test email for illegal characters var illegalChars= /[\(\)\<\>\,\;\:\\\"\[\]]/ if (strng.match(illegalChars)) { error = "L'adresse email contient des caracteres illegaux.\n"; } } return error; } Now here in html Code: function checkWholeForm(theForm) { var why = ""; why += checkname(theForm.name.value); why += checkprename(theForm.prename.value); why += checkEmail(theForm.Email.value); why += checkPhone(theForm.Phone.value); if (why != "") { var leDiv = document.getElementById('errormsg'); var nouveauDiv = document.createElement('div'); var divIdName = 'errormsg'; nouveauDiv.setAttribute('id',divIdName); nouveauDiv.innerHTML = "u had Enter wrong information bla bla"; leDiv.appendChild(nouveauDiv); var nouveauDiv2 = document.createElement('div'); var divIdName = 'errormsg'; nouveauDiv2.setAttribute('id',divIdName); nouveauDiv2.innerHTML = ' '; leDiv.appendChild(nouveauDiv2); return false; } return true; } MY qs is how to let the innerHTML past past each error from the validate.js file which i call it erorr i mean near to input filed of phone it will be div id erorrmsg and in this div will past the error from the validate.js which it code from my start of this post thanks for advance Hello to all, I want to fuse these 2 scripts but don't know how: First script chains 2 selects DEMO: http://www.plus2net.com/php_tutorial/dd.php Second retains and displays values of form input fields if page refreshes DEMO: http://www.plus2net.com/php_tutorial/page-reload.php Code: <SCRIPT language=JavaScript> function reload(form) { var val=form.cat.options[form.cat.options.selectedIndex].value; self.location='dd.php?cat=' + val; } </script> I want to FUSE with this one: Code: <script type="text/javascript"> function reload() { var val1=document.form1.fname.value ; var val2=document.form1.mname.value ; var val3=document.form1.lname.value ; //// For radio button value to collect /// for(var i=0; i < document.form1.type.length; i++){ if(document.form1.type[i].checked) var val4=document.form1.type[i].value } self.location='validation4.php?fname=' + val1 + '&mname=' + val2 + '&lname=' + val3 + '&type=' + val4; } </script> Hi all, I found a small fading script online which suits my needs though I need some help changing it around a bit as it seems to only work once in a page (i.e. a second occurance of the code doesn't work though the first one continues). Also, I'm not quite sure how to put it into a .js external page and then call the specific function as many times as I want in the body and have it all work. Please advise on this issue (i.e. Putting the code in an external file and then calling the fadeIn() function as many times as I want in the body). Thanks. BTW, the concept is a fixed imaged with the js fading another image over the top of that first image in and out over and over again. All the images and application of the js will be the same for all occurrences on the page (don't know if that's relevant to the solution I'm asking for but throwing it in there just in case). Here is the code: Code: <html> <body style="background:#000;"> <div style="float:left;"> <img style="float:left;" id="me" src="fade_arrow2.png"/> <img style="float:left;margin-left:-44px;" src="fade_arrow1.png"/> <script type="text/javascript"> var element = document.getElementById('me') ; var duration = 4000; /* 1000 millisecond fade = 1 sec */ var steps = 20; /* number of opacity intervals */ var delay = 5000; /* 5 sec delay before fading out */ /* set the opacity of the element (between 0.0 and 1.0) */ function setOpacity(level) { element.style.opacity = level; element.style.MozOpacity = level; element.style.KhtmlOpacity = level; element.style.filter = "alpha(opacity=" + (level * 100) + ");"; } function fadeIn(){ for (i = 0; i <= 1; i += (1 / steps)) { setTimeout("setOpacity(" + i + ")", i * duration); } setTimeout("fadeOut()", delay); } function fadeOut() { for (i = 0; i <= 1; i += (1 / steps)) { setTimeout("setOpacity(" + (1 - i) + ")", i * duration); } setTimeout("fadeIn()", duration); } /* start the effect */ fadeIn(); </script> </div> </body> </html> first of all, hello all i found this forum while running out of ideas and being extremely desperate to fixing a probably small javascript error in a script. the script is supposed to open a small form window that allows the user to input an email address and update it to proceed. the form item is initially unchecked, but as the user clicks it and enter his email address, it updates the value of the email address and the box becomes "checkable". the problem is that with both IE and firefox, the box doesn't close again, doesn't get checkable and basically doesn't work. in the firefox debugging console, I found the following error: Quote: Error: document.getElementById(input_array[i]) is null Source File: sell_item.php Line: 1106 does anyone have an idea what could be wrong? the part responsible in the javascript for this section is: Code: <script language="javascript"> function pg_popup_open(id) { if (document.getElementById(id).style.display == 'block') { document.getElementById(id).style.display = 'none'; } else { document.getElementById(id).style.display = 'block'; } return false; } function pg_update_settings(id, input_array) { xmlHttp=GetXmlHttpObject(); if (xmlHttp==null) { alert ("Browser does not support HTTP Request"); return; } var url = '' + 'ajax_files/direct_payment_box.php'; var action = url + '?id=' + id + '&user_id=' + 100001; var chk_disabled = false; for ( var i in input_array ) { action += '&' + input_array[i] + '=' + document.getElementById(input_array[i]).value; if (document.getElementById(input_array[i]).value == '') { chk_disabled = true; } } xmlHttp.onreadystatechange = function() { if (xmlHttp.readyState == 4) { var response = xmlHttp.responseText; } }; xmlHttp.open("GET", action, true); xmlHttp.send(null); document.getElementById('checkbox_' + id).disabled = chk_disabled; if (chk_disabled == true) { document.getElementById('checkbox_' + id).checked = false; } document.getElementById(id).style.display = 'none'; return false; } </script> and the html code that is supposed to pop up the box is: Code: <input type="checkbox" name="payment_gateway[]" id="checkbox_pg_paypal" value="1" disabled> <span class="contentfont"><a href="javascript:;" onclick="pg_popup_open('pg_paypal');">PayPal</a></span> <script language="javascript"> var array_pg_paypal = new Array(); array_pg_paypal[0] = 'pg_paypal_email';</script> <div class="smallfont"><b>PayPal Email Address</b><br> <input type="text" name="pg_paypal_email" id="pg_paypal_email" value="" /></div> <div align="right"><input type="button" value="Proceed" onclick="pg_update_settings('pg_paypal', array_pg_paypal);" /></div> i understand this is asking a lot, but if someone has a spare second that is a javascript guru, i promise i will name my first born after you!! lol I have a form and the Js validation wont work on it. Here is the html PHP Code: <form name="frm" action="index.php" method="POST" onsubmit="return validateForm();"> <table width="100%" border="0" cellspacing="2" cellpadding="3" class="mainForm"> <tr> <td class="normalText" align="left" style="padding:0px 0px 0px 33px"> <table border="0" cellspacing="3" cellpadding="2"> <tr> <td class="normalHeading" colspan="2" style="padding-bottom:6px"> <div id="error_msg" class="txtErrorMsg" align="center"></div> <!-- <?php echo "<p id=\"error_msg\">".$message."</p>"?> --> </td> </tr> <tr > <td class="normalText" width="30%">First Name</td> <td><input type="text" name="firstName" id="firstName" class="input1" style="width:195px" maxlength="10"/></td> </tr> <tr> <td class="normalText">Last Name</td> <td><input type="text" name="lastName" id="lastName" class="input1" style="width:195px" maxlength="10"/></td> </tr> <tr> <td class="normalText">Mobile</td> <td><input type="text" name="mobile" id="mobile" class="input1" style="width:195px" maxlength="10" onkeypress="return fnIsIntNumber(event,this);"/></td> </tr> <tr> <td class="normalText">Email</td> <td><input type="text" name="email" id="email" class="input1" style="width:195px" onblur="IsEmail(this.vlaue)"/></td> </tr> <tr> <td class="normalText">Comments</td> <td> <textarea name="comments" id="comment" cols="22" rows="3" ></textarea> </td> </tr> <tr> <td class="normalText"> </td> <td valign="middle"><input class="send" type="image" value='submit' src="images/submit.gif" name="submit" /></td> </tr> </table> </td> </tr> </table> </form> and here is the JS PHP Code: var $j = jQuery.noConflict(); function isValidEmail(str) { return (str.indexOf(".") > 2) && (str.indexOf("@") > 0); } function validateForm(){ var firstName; var lastName; var email; var mobile; var comment; var error; firstName = $j('#firstName').val(); lastName = $j('#lastName').val(); email = $j('#email').val(); mobile = $j('#mobile').val(); comment = $j('#comment').val(); if(firstName=='' || firstName.length < 3){ error = 'Please Enter Your First Name'; $j('#errormsg').html('<p class="errors">'+ error +'</p>'); return false; } if(lastName=='' || lastName.length < 3){ error = 'Please Enter Your Second Name'; $j('#errormsg').html('<p class="errors">'+ error +'</p>'); return false; } if(email=='' || !isValidEmail(email)){ error = 'Please Enter Your Correct Email'; $j('#errormsg').html('<p class="errors">'+ error +'</p>'); return false; } //mob //$jmob_pattern = '^\d{10}$j'; if(mobile.length != 10 || isNaN(mobile)){ error = 'Please Enter Your Correct Mobile Number'; $j('#errormsg').html('<p class="errors">'+ error +'</p>'); return false; } if(comment.length < 10){ error = 'Please Enter A Comment More Than 10 Characters'; $j('#errormsg').html('<p class="errors">'+ error +'</p>'); return false; } return true; } Can anybody tell me what the problem is Hey guys I need a small help. I am new to Javascript. I want to save data from dropdownlist to XML file. Save function is working but I dont know how to load data list from dropdown to xml file. I can do with input element but dont know how to work with dropdown element. How to do this? Look at my codes below: HTML markup (index.html): FOCUS ON RED <body> <form name="reg" action="index.html" method="get"> Name: <input type="text" name="name_input" /> Pass: <input type="text" name="pass_input" /> <select id="language"> <option name="select_afrikaans">Afrikaans</option> <option name="select_english">English</option> </select> <br /> <input type="button" value="SAVE" onclick="javascriptk_click();" /> </form> </body> Javascript: function ok_click() { var xmlDoc = new ActiveXObject("Msxml2.DOMDocument.6.0"); xmlDoc.async = false; xmlDoc.load("data.xml"); if (xmlDoc.readyState == 4 && xmlDoc.parseError.errorCode == 0) { var root = xmlDoc.documentElement; var _input_name = xmlDoc.createTextNode(document.reg.name_input.value); var _input_pass = xmlDoc.createTextNode(document.reg.pass_input.value); var _select_afrikaans = xmlDoc.createTextNode(document.reg.select_afrikaans.value); var _select_english = xmlDoc.createTextNode(document.reg.select_english.value); var input_name = xmlDoc.createNode(1, "USER", ""); var input_pass = xmlDoc.createNode(1, "PASS", ""); var input_select = xmlDoc.createNode(1, "LANGUAGE", ""); input_name.appendChild(_input_name); input_pass.appendChild(_input_pass); select_afrikaans.appendChild(_select_afrikaans); select_english.appendChild(_select_english); var cust = xmlDoc.createNode(1, "CUST", ""); cust.appendChild(input_name); cust.appendChild(input_pass); cust.appendChild(select_afrikaans); cust.appendChild(select_english); root.appendChild(cust); SaveXML(xmlDoc, "data.xml"); alert("Save!"); } } // It is working fine function SaveXML(xmlDoc, filename) { var outputXML = new String(xmlDoc.xml); var mfObj = new ActiveXObject("Scripting.FileSystemObject"); var absPath = getPath(); var file = mfObj.CreateTextFile(absPath + filename, true); file.Write(outputXML); file.Close(); } //it is working fine function getPath() { var path = document.location; var str = new String(path); var end = str.lastIndexOf("/"); var absolutePath = str.substring(8, end) + "/"; absolutePath = absolutePath.replace(/ /g, " "); return absolutePath; } XML File: <?xml version="1.0"?> <DATA> <CUST> <USER>natalie</USER> <PASS>80</PASS> </CUST> ........ here should display xml data from dropdown list.....how? </DATA> Your help would much appreciated. Thank you very much Regards Natz Hi ! I would like to ask u for help me with simple, non-comercial project. I want to create simple drag and drop game for my Horner's method website which I creating, and I need help, because I know only basics of javascript. Rules of the game. Drag and drop numbers from right table to matching fields in left table (with clone number, numbers in polynomials can reapeat ). We have polynomial: W(x) = x3 + x2 - 10x + 8 ( I will try to do random polynomial and binomial each time later). and binomial : x - 5 And we need to fill empty fields with appropriate numbers from second table (drag and drop). How it is looking now : For now I can only drag the numbers, and I need help because I don't know how to match numbers with appropriate fields. I mean I would like to match correct numbers with specific place in table. (and disable this number if it's correct). I used jquery.ui to do drag table-cells. This is my HTML code: Code: <div class="col-sm-8"> <table class="game-table"> <tr> <td class="up">SCHEMAT HORNERA</td> <td class="up makeMeDroppable">(Upuść tutaj)</td> <td class="up">(Upuść tutaj)</td> <td class="up">(Upuść tutaj)</td> <td class="up">(Upuść tutaj)</td> </tr> <tr> <td class="up">(Upuść tutaj)</td> <td class="down">(Upuść tutaj)</td> <td class="down">(Upuść tutaj)</td> <td class="down">(Upuść tutaj)</td> <td class="down">(Upuść tutaj)</td> </tr> </table> </div> <div class="col-sm-4"> <table id="Cyfry"> <tr> <td class="makeMeDraggable">-1</td> <td class="makeMeDraggable">-2</td> <td class="makeMeDraggable">0</td> <td class="makeMeDraggable">1</td> </tr> <tr> <td class="makeMeDraggable">2</td> <td class="makeMeDraggable">3</td> <td class="makeMeDraggable">4</td> <td class="makeMeDraggable">5</td> </tr> <tr> <td class="makeMeDraggable">6</td> <td class="makeMeDraggable">7</td> <td class="makeMeDraggable">8</td> <td class="makeMeDraggable">9</td> </tr> </table> </div> And my jquery code for drag Code: $( init ); function init() { $('.makeMeDraggable').draggable( { cursor: 'move', ****containment: 'document', ****helper: "clone" } ); $('.makeMeDroppable').droppable( { drop: handleDropEvent } ); } Can u help me, please? Reply With Quote 01-21-2015, 02:50 AM #2 Old Pedant View Profile View Forum Posts Supreme Master coder! Join Date Feb 2009 Posts 28,310 Thanks 82 Thanked 4,754 Times in 4,716 Posts Not to ask a silly question or two, but: (a) Why do you limit the possible drag values to only -2 through 9? (b) Why drag numbers when it's so easy to type them in? How would I make this into one Loop using all same variables? Right now I can only get his program to work with separate loops Here is the Coding Code: script type="text/javascript"> for (var i=0; i<date.length; i++){ document.write("<td>"+date[i]+"</td>");} </script> </td> </tr> <tr> <script type="text/javascript"> for (var i=0; i<amount.length; i++){ document.write("<tr>"+"<td>"+amount[i]+"</td>"+"</tr>");} </script> </tr> <tr> <script type="text/javascript"> for (var i=0; i<firstName.length; i++){ document.write("<tr>"+"<td>"+firstName[i]+"</td>"+"</tr>");} </script> </tr> <tr> <script type="text/javascript"> for (var i=0; i<lastName.length; i++){ document.write("<tr>"+"<td>"+lastName[i]+"</td>"+"</tr>");} </script> </tr> <tr><td></td></tr> </table> </div> </script> Suggestions or examples to make this one loop I have no idea what to change in order to do this so I'm hoping someone can help Basically this is a menu I have which I'm using in wordpress. Wordpress puts 'current' on the current page, so the menu knows which list item to keep highlighted. On one of my pages however, it is hidden from the menu, therefor NONE of the list items contain 'current'. It makes the menu look bad when you are on this page. What I'd like to do to this code, is add a very small feature that checks if none of the list items have 'current'. If none of the li's contain current, then just apply it to li:first-child (which is my home button). I'm not familiar with javascript, but I feel that would be doable from just the script that I'm pasting below. Code: /** * LavaLamp - A menu plugin for jQuery with cool hover effects. * @requires jQuery v1.1.3.1 or above * * http://gmarwaha.com/blog/?p=7 * * Copyright (c) 2007 Ganeshji Marwaha (gmarwaha.com) * Dual licensed under the MIT and GPL licenses: * http://www.opensource.org/licenses/mit-license.php * http://www.gnu.org/licenses/gpl.html * * Version: 0.2.0 * Requires Jquery 1.2.1 from version 0.2.0 onwards. * For jquery 1.1.x, use version 0.1.0 of lavalamp */ (function(jQuery) { jQuery.fn.lavaLamp = function(o) { o = jQuery.extend({ fx: "linear", speed: 500, click: function(){} }, o || {}); return this.each(function() { var me = jQuery(this), noop = function(){}, jQueryback = jQuery('<li class="back"><div class="left"></div></li>').appendTo(me), jQueryli = jQuery("li", this), curr = jQuery("li.current", this)[0] || false; if (curr == false){jQuery(".back").remove();return false;} jQueryli.not(".back").not("#nav ul li").hover(function() { move(this); }, noop); jQuery(this).hover(noop, function() { move(curr); }); jQueryli.click(function(e) { setCurr(this); return o.click.apply(this, [e, this]); }); setCurr(curr); function setCurr(el) { jQueryback.css({ "left": el.offsetLeft+"px", "width": el.offsetWidth+"px" }); curr = el; }; function move(el) { jQueryback.each(function() { jQuery(this).dequeue(); } ).animate({ width: el.offsetWidth, left: el.offsetLeft }, o.speed, o.fx); }; }); }; })(jQuery); |