JavaScript - Javascript Comparison Tool Php Webform
Hello everyone, for starters, I'm NOT working with arrays...with that being said, I need your help...I created a webform in PHP that retrieves values from a mysql table and displays them with its own mysqli_fetch_array command, in that loop it generates a textbox for each record...so far so good.
The created textbox (input element) is so that the user can type in the sequential number of how to reorder the records...example Original Order of Records 1 Alpha 2 Bravo 3 Charlie 4 Delta 5 Echo and user needs it to be in this order User input sequential 2 Alpha 5 Bravo 1 Charlie 4 Delta 3 Echo the new order of the records will be saved on a temporary table in the database before insertion on the main table, kinnda like a preview for the new order, something like this: New Order of Records 1 Charlie 2 Alpha 3 Echo 4 Delta 5 Bravo Now what I need is a function that helps me display a message if the user duplicates a sequential unique, if they type in number 1 in 2 or more records, when I hit the button for the preview I need it to loop through all the input boxes and check their values, compare it with the other inputs and determine if there are duplicates or not....if there're no duplicates, continue with PHP code.....if there are duplicates, display an error so the user seeks for the duplicate and change it (inputs left in blank will not be considered for the insertion in the preview table) I already have this: Code: function checkall() { const t='texto'; var contar=<?php echo $contar; ?>; var text = "" var conta = 1; var contas= conta+1; text = t+conta; texto = t+contas; //var curElement = document.activeElement.value; var cv=document.forms['OrderPreview'][text].value; //var cv=document.forms['OrderPreview'][curElement].value; do { //var cv=document.forms['OrderPreview'][text].value; if (document.forms['OrderPreview'][texto].value=="") { return; } if (cv==document.forms['OrderPreview'][texto].value) { alert("Something Bad"); } conta++; contas++; text = t+conta; texto = t+contas; } while (conta<=contar) } Btw, the document.activeElement part of the code displays me "undefined" in the alert message, I still don't have a clue why, could you guide me with this please? I can't do but compare the 1st input with the rest of the fields, OR compare one field to the inmediate next field....it's driving me nuts Any help will be truly appreciated, thanks in advance Similar TutorialsMy code isn't working, the only part that is showing up in the webpage is the head. Can someone tell me what I am doing wrong. I typed it right out of the book; the way the book tells me to write it. Thank you. Code: <!DOCTYPE HTML> <html> <head> <title>Comparison Operators</title> </head> <body> <h1>Comparison Operators</h1> <script type="text/javascript"> var conditional Value; var value1 = "Don"; var value2 = "Dave"; value == value2 ? document.write( "<p>value1 equal to value2: true< br />") : document.write( "<p>value1 equal to value2: false<br />") value1 = 37; value2 = 26; conditional value = value1 == value2; document.write("value equal to value2: " +conditionalValue + "<br />"); conditionalValue = value1 != value2; document.write("value1 not equal to value2: " +conditionalValue + "<br />"); conditionalValue = value1 > value2; document.write("value1 greater than value2: " +conditionalValue + "<br />"); conditionalValue = value1 < value2; document.write("value1 less than value2: " +conditionalValue + "<br />"); conditionalValue = value1 >= value2; document.write("value1 greater than or equal to value2: " + conditionalValue + "<br />"); conditionalValue = value1 <= value2; document.write(value1 less than or equal to value2: " + conditionalValue + "<br />"); value1 = 21; value2 = 21; conditionalValue = value1 === value2; document.write( "value1 equal to value2 AND the same data type: " + conditionalValue + "<br />"); conditionalValue = value1 !== value2; document.write( "value1 not equal to value2 AND no the same data type: " + conditionalValue + "</p>"); </script> </body> </html> Hello all, I am enrolled in a class that requires a bit of JS/HTML coding; my final project is to create a simple page representing myself. See example. And yes, that is my teacher. I am allowed to utilize "templates or tools". I am using my macbook, but I have access to school windows computers. Any suggestions on what to use to complete this assignment are greatly appreciated. Hi, I've made a web based tool that times how long a web page takes to load in an iframe and today I redesigned it but now it has issues. When I load it in Chrome and Opera the new version works fine but in FF 3.6 and IE 8 only the footer area is displayed. I have added the links below - You'll be able to access the code via your browser's "View page Source" option. URLs: New test (With problem): http://browserspeedtest.camerongray....net/version31/ Old test (Works perfectly): http://browserspeedtest.co.cc Any help is greatly appreciated! Cameron Gray I have some code for a dropdown where when the 'Other' option is selected a textbox appears and the user can put in their info. What I'm wondering is, how can i set it up so if the Other option isn't selected the dropdown info is sent to my database Name field, and if the Other option is selected it sends the info that's typed in to the Name field in my database and does nothing with the actual 'Other' label in the dropdown? here's the code i have so far Code: <script language="JavaScript" type="text/javascript"> <!-- function getOther(sel,fld){ fld.style.display = (sel.selectedIndex==sel.options.length-1)?"inline":"none"; } //--> </script> <select name="Name" id="Name" onchange="getOther(this,this.form.oth);"> <option>Name 1 <option>Name 2 <option>Name 3 <option>Name 4 <option>Name 5 <option>Other </select> <br><input type="text" name="Other" style="display: none;"> Why alert('hua'); does not pop up ? Code: var cur_date = new Date(); cur_date.setSeconds(0); cur_date.setHours(0); cur_date.setMilliseconds(0); cur_date.setMinutes(0); alert(cur_date); alert(new Date(cur_date.getFullYear(),cur_date.getMonth(),cur_date.getDate())); if (new Date(cur_date.getFullYear(),cur_date.getMonth(),cur_date.getDay()) == cur_date ) { alert('hua'); } are these right ya? '3' !=='smith' true "test" == "test " true '2' != 'smith' true "exam" == "Exam" true 5 === "5 " false "t" > "T" false "y" >= "p" true "Happy" == "happy " true i have an iframe on my webpage and i am loading appropriate page in it by clicking appropriate button but when user logs out and at that time some page is opened in iframe corresponding to the login pages(like "edit profile") of user then at that moment i want to know that what page is loaded in iframe so that i close it(if it corresponds to pages of login like "edit profile") as user logs out and if it does not correspond to login pages then it remains as it is.For doing that i must know that what page is loaded in iframe and compare it in " if(condition){statement} in logout function" with the logion pages so that i know that if any of them is loaded in iframe and if loaded then close it.Can you help me with that by giving exact code example. I would like to compare dates in the format used in twitter, which is this: Wed Apr 08 14:30:10 +0000 2009 How do I do this? Do I need to convert to a timestamp first, and if so, how do I do this? G Hello, I try to learn JavaScript and I've just come across something that I can't work out. I use the book of John Pollock: JavaScript, A beginner's guide, Third Edition. So, page 360 and this piece of code: Code: function getname() { var the_text=window.prompt("Enter your first and last name",""); if (the_text.indexOf(" ") == -1) { window.alert("Put a space between your first and last name. Try again."); getname(); } var split_text= the_text.split(" "); if ((split_text[0].charAt(0) != "Z") || (split_text[0].charAt(0) != "z")) { var shorter_fn_string = split_text[0].substring(1,split_text[0].length); new_fn_name = "Z"+shorter_fn_string; } else { var shorter_fn_string = split_text[0].substring(1,split_text[0].length); new_fn_name = "W"+shorter_fn_string; } if ((split_text[1].charAt(0)!= "Z") || (split_text[1].charAt(0)!= "z")) { var shorter_ln_string= split_text[1].substring(1,split_text[1].length); new_ln_name="Z"+shorter_ln_string; } else { var shorter_ln_string= split_text[1].substring(1,split_text[1].length); new_ln_name="W"+shorter_ln_string; } window.alert("Now your name is "+new_fn_name+" "+new_ln_name+"!"); } getname(); the thing is it ain't working. If I type in the propmpt window let's say simon simon I will get an alert of zimon zimon but if I type in zimon zimon it won't change to wimon wimon. I suppouse it's because of != comparison operator. If I use == instead of != and change the code the other way round inside if block then it works. Code: function getname() { var the_text=window.prompt("Enter your first and last name",""); if (the_text.indexOf(" ") == -1) { window.alert("Put a space between your first and last name. Try again."); getname(); } var split_text= the_text.split(" "); if ((split_text[0].charAt(0) == "Z") || (split_text[0].charAt(0) == "z")) { var shorter_fn_string = split_text[0].substring(1,split_text[0].length); new_fn_name = "W"+shorter_fn_string; } else { var shorter_fn_string = split_text[0].substring(1,split_text[0].length); new_fn_name = "Z"+shorter_fn_string; } if ((split_text[1].charAt(0)== "Z") || (split_text[1].charAt(0)== "z")) { var shorter_ln_string= split_text[1].substring(1,split_text[1].length); new_ln_name="W"+shorter_ln_string; } else { var shorter_ln_string= split_text[1].substring(1,split_text[1].length); new_ln_name="Z"+shorter_ln_string; } window.alert("Now your name is "+new_fn_name+" "+new_ln_name+"!"); } getname(); Why is that? Regards, Simon I'm trying to get an emerge effect using javascript. Here is my code Code: var t; var s=0; function emerge() { document.getElementById('my_span').style.opacity=s; s=s+0.1; t=setTimeout("emerge()",250); if (s>1) { clearTimeout(t); } } } Works fine, does the things right. But if I use this code, I get error. Code: var t; var s=0; function emerge() { document.getElementById('my_span').style.opacity=s; s=s+0.1; t=setTimeout("emerge()",250); if (s==1) { clearTimeout(t); } } } The only thing I changed was comparison operator. I tried to debug by adding alert box Code: var t; var s=0; function emerge() { alert(document.getElementById('my_span').style.opacity); document.getElementById('my_span').style.opacity=s; s=s+0.1; t=setTimeout("emerge()",250); if (s>1) { alert("Opacity set to max"); clearTimeout(t); } } } For some reason, it does not enter the if block if I use "==" operator & the alert box keeps coming up with "1" in it. But works fine if I use ">" operator, enters the block and the last value it shows is "0.9". Can anyone explain as to why this happens? Hey, I was wondering what this tool is called: http://jsgame.mycdn.in/images/screen.png I assume it's some kind of text editor, I've seen it running in Windows and Linux. Thanks for your help Hello webmasters , Iam looking for "fonts picker" tool just like "color picker" ...please help me to find one.... i hope JQUERY has solution for this but not able to fix this.... guyzz plz help me find fonts picker to use it in user input forms...Any response appreciated... Thank you... I am using tooltip plug in on a site and when I use it on a blank template, it works then when I transfer it to the page I want to use it on it does not work. The site is Here is they javascript code: Code: this.imagePreview = function(){ /* CONFIG */ xOffset = 10; yOffset = 30; // these 2 variable determine popup's distance from the cursor // you might want to adjust to get the right result /* END CONFIG */ $("a.preview").hover(function(e){ this.t = this.title; this.title = ""; var c = (this.t != "") ? "<br/>" + this.t : ""; $("body").append("<p id='preview'><img src='../"+ this.href +"' alt='Image preview' />"+ c +"</p>"); $("#preview") .css("top",(e.pageY - xOffset) + "px") .css("left",(e.pageX + yOffset) + "px") .fadeIn("fast"); }, function(){ this.title = this.t; $("#preview").remove(); }); $("a.preview").mousemove(function(e){ $("#preview") .css("top",(e.pageY - xOffset) + "px") .css("left",(e.pageX + yOffset) + "px"); }); }; // starting the script on page load $(document).ready(function(){ imagePreview(); }); Here is the HTML code. Code: <ul> <li><a href="mailto:rragon@cumberland.k12.il.us">Mr. Russell Ragon</a> <a href="../../Images/staffbios/rragon.gif" class="preview"><img src="1s.jpg" alt="BIO" /></a></li> </ul> Here is the CSS code: Code: #preview{ position:absolute; border:1px solid #ccc; padding:5px; display:none; color:#fff; background-color: #333; } This is my first post on this forum so I hope the code is clear you can check out the site up above just hover over one of the names. I am only getting image preview instead of the image I want. Ont thing I did do was I took out the image so I could get the Alternate code. My objective here is to have a name and when you hover over it an image pops up and on the image will be a biography of the teacher. Thanks for any help. I just found this web scraping tool at http://www.heliumscraper.com and I was wonderin if anyone have used it. They say on the web page you can automate it with JavaScript.
A general question really, but does anyone have a good technique or source for creating disabled versions of tool bar buttons? Many thanks for any assistance, S Hi, I'm Jon. First of all excuse me if I posted this thread in the wrong forum, I really have no clue where to put this but I've had some minor experience with js so I hope it can be solved this way. I check websites and/or keywords in googles Keyword Tool External as a free service for some of my clients. The thing is that more and more clients like this service and it's becoming very time-consuming for me to do this for all of them. Is there a way to let my clients fill in the keywords or url they like researched in a form on my website, then let those words be researched and return a specified number of results in a pdf or something? My biggest concern is the captcha code. If I can't find a way to partially or fully automate this process, I'll be forced to either charge for or completely give up this service. Can anyone help me with some kind of solution? Thanks in advance. Jon Hi, I am working on a project and in that I have to create: Image-map tooltip (Mouseover) + Model window (On Click) Can anyone share the tutorials or any suggestions to start with. Thanks Vikrant Hello, I need to know that is there any script available which allows me to upload an image and after uploading it will allow me to crop an image like we do in photoshop via pen tool. In photoshop when we use pen tool, it apply nodes against the images and user can easily change nodes via mouse to change the position of cropping. Is there any type of script available which provides this functionality? Thanks I write code using ext js,openlayers and GeoExt for measuring length and area ,it is working inside inside of india in the world map but this measure tool is not working outside of india in the world map. My code for Measure length: To Load map: var projWGS84 = new OpenLayers.Projection("EPSG:4326"); var projSphericalMercator = new OpenLayers.Projection("EPSG:900913"); var bounds = new OpenLayers.Bounds(68.137, 6.783, 97.336, 37.086); bounds.transform(projWGS84, projSphericalMercator); map.maxExtent = bounds; var gphy = new OpenLayers.Layer.Google("Google Street", { 'sphericalMercator':true //maxExtent: new OpenLayers.Bounds(-20037508, -20037508,20037508, 20037508) } ); var osmLayer = new OpenLayers.Layer.OSM(); // Add the background images via WMS // Add the background images via WMS //map.addLayer(bglayer); // map.addControl(new OpenLayers.Control.MousePosition()); map.addLayers([gphy, osmLayer]); Measure Length: Measure = new Ext.SplitButton({ text:"Measure", iconCls:"icon-measure-length", toggleGroup:"navigate", group: "navigate", enableToggle:true, allowDepress:false, handler: function(button, event) { // allowDepress should deal with this first condition if(!button.pressed) { button.toggle(); } else { button.menu.items.itemAt(activeIndex).setChecked(t rue); } }, listeners: { toggle: function(button, pressed) { // toggleGroup should handle this if(!pressed) { button.menu.items.each(function(i) { i.setChecked(false); }); } }, render: function(button) { // toggleGroup should handle this Ext.ButtonToggleMgr.register(button); } }, menu: new Ext.menu.Menu({ items: [ new Ext.menu.CheckItem( new GeoExt.Action({ text: "Length", toggleGroup:"navigate", iconCls:"icon-measure-length", group: "navigate", enableToggle:true, allowDepress:false, map: map, control: new OpenLayers.Control.Measure(OpenLayers.Handler.Path , { eventListeners: { measu function(evt) { Ext.MessageBox.show({ title: 'Line length :', buttons: Ext.MessageBox.OK, width:200, msg:"Line Length: " + evt.measure.toFixed(2) + " " + evt.units }); } } }) }) ) } }) }) ) ] }) }) |