JavaScript - If 2 Drop Downs True - Action
i'm trying to make a form where if 2 particular options are chosen from 2 dropdown boxes, it puts a value in a text field. Its not working and i hope you can help
so far i've got Code: if (document.profile_quote.thickness.selectedIndex == "3" && document.profile_quote.machine.selectedIndex == "1") document.profile_quote.cutspeed.value = "34444" Similar TutorialsHi, Im trying to create a drop down menu using the following code JS Code: function showMenu(theMenu) { thisMenu = document.getElementById(theMenu); var str = theMenu; if (thisMenu.className == str.slice(4)+'_off') { thisMenu.className = str.slice(4)+'_on'; } else { thisMenu.className = str.slice(4)+'_off'; } } function hideMenu(theMenu) { thisMenu = document.getElementById(theMenu); var str = theMenu; if (thisMenu.className == str.slice(4)+'_on') { thisMenu.className = str.slice(4)+'_off'; } else { thisMenu.className = str.slice(4)+'_on'; } } CSS Code: #wrapper { width: 770px; margin:10px auto; border:none; text-align:left; position:relative; z-index:0; } #wrapper div.1_off { /* visibility:hidden; z-index:-1; */ width:100px; position:absolute; top:40px; left:10px; height:70px; width:200px; margin:0px; visibility:visible; z-index:1; } #wrapper div.2_off { visibility:hidden; z-index:-1; } #wrapper div.1_on { width:100px; position:absolute; top:40px; left:10px; height:70px; width:200px; margin:0px; visibility:visible; z-index:1; background-color:#000; } #wrapper div.2_on { width:100px; position:absolute; top:40px; left:110px; height:70px; width:200px; margin:0px; visibility:visible; z-index:1; background-color:#000; } with the anchors tags onmouseover/out containting the relevant JS functions: Code: <a href="" onmouseover="showMenu('menu1')">Hello</a></td><td name="dropdown"> <a href="" onmouseover="showMenu('menu2')">Goodbye</a> and these divs nested within the wrapper div: Code: <div id="menu1" class="1_off">Yes</div><div id="menu2" class="2_off">No</div> Unfortunately the JS does not seem to be changing class of the div attributes. Any help would be greatly appreciated. Thanks Sol I have a date of birth drop down for 'Day', 'Month' and a text field for Year. How can I get the select value of the drop down and year text field into a single text field, separated by '-'? The single text field would need to update if someone changed the drop down / year selections. Hope someone can help - I'm stumped! I am using the following code to show / hide form elements within a div based upon the drop down choice. Does anyone know how this code can be amended to use multiple drop downs within one form? Code: <html> <head> <title>Show and Hide</title> <script> //********************************************* // Function that Shows an HTML element //********************************************* function showDiv(divID) { var div = document.getElementById(divID); div.style.display = ""; //display div } //********************************************* // Function that Hides an HTML element //********************************************* function hideDiv(divID) { var div = document.getElementById(divID); div.style.display = "none"; // hide } //***************************************************************************** // Function that Hides all the Div elements in the select menu Value //***************************************************************************** function hideAllDivs() { //Loop through the seclect menu values and hide all var selectMenu = document.getElementById("selectMenu"); for (var i=0; i<=selectMenu.options.length -1; i++) { hideDiv(selectMenu.options[i].value); } } //********************************************* // Main function that calls others to toggle divs //********************************************* function toggle(showID) { hideAllDivs(); // Hide all showDiv(showID); // Show the one we asked for } </script> </head> <body onload="hideAllDivs();"> <select id="selectMenu" onchange="toggle(this.options[this.options.selectedIndex].value)"> <option value="formNumber1"> Show Form 1 </option> <option value="formNumber2"> Show Form 2 </option> <option value="formNumber3"> Show Form 3 </option> <option value="formNumber4"> Show Form 4 </option> </select> <div id="formNumber1"> I am Form Number one. Any content within this div will be showed</div> <div id="formNumber2"> I am Form Number two. Any content within this div will be showed</div> <div id="formNumber3"> I am Form Number three. Any content within this div will be showed</div> <div id="formNumber4"> I am Form Number four. Any content within this div will be showed</div> </body> </html> Thanks in advance! Hi guys, it's a bit of a large question but I've been messing around with code for a while, and nothing seems to work... Basically, I need to make, a 'dynamic theme changer'. Basically what I need to do is have several drop down boxes, each one with some colours available as options. When you select one, it automatically (without refreshing the page) updates a certain element's style. For example, if you selected green as one colour and red as another, the element linked to the first drop-down would turn green, and the element linked to the second drop-down would turn red, and so on so forth. It then needs to have a 'save' button, which saves the settings, and adds a cookie with the style details so that when they visit the page again it's still personalized. There also needs to be a cancel button which discards all changes. I know it's a large question but I'm ripping my hair out over this one! =P Your help is much appreciated. Hi all, I think I have posted in the right place, if not appologies. Anyhow, I am currently creating a website for my canvas printing business and run into a few javascripting issues. I am trying to create a small navigation form whereby a customer can select from a dropdown the required width of canvas, this selection will then populate a second dropdown with a choice of canvas heights. Ok, so trawling many sites I came across some javascript that I was able to chop about and have this part sorted. The problem now is that I would like to include a submit button that when clicked takes the customer to a webpage based on their two dropdown choices, and being a complete newby when it comes to javascript I am stuck trying to include the script to enable this. eg: if they select '20" (51cm)' from the first dropdown and '16" (41cm)' from the second dropdown, they will navigate to "http: / / 20x16.co.uk" canvas print page. I have not currently created the canvas print pages so am unable to give the URLs of the pages. However if somebody can lend a hand to get me started and indicate where the desitnation URLs need to be added, I can drop these in later. The way that the script is currently written, the linked url could be based soley on the choice made in the second dropdown. I have a draft page with the working dropdowns he http://merchant.auctivacommerce.com/...iewtheme=32189 And the code that I currently have is: Code: <script type="text/javascript"> var SELECT_WIDTH_FIRST = []; var WIDTH08 = []; var WIDTH10 = []; var WIDTH12 = []; var WIDTH14 = []; var WIDTH16 = []; var WIDTH18 = []; var WIDTH20 = []; var WIDTH24 = []; var WIDTH30 = []; var WIDTH36 = []; var WIDTH42 = []; var WIDTH48 = []; var WIDTH60 = []; var WIDTH72 = []; SELECT_WIDTH_FIRST[0] = new Option("Please Select Width First", "SelWidFir"); WIDTH08[0] = new Option("8'' (20cm)", "0808"); WIDTH08[1] = new Option("10'' (25cm)", "0810"); WIDTH08[2] = new Option("12'' (30cm)", "0812"); WIDTH08[3] = new Option("14'' (35cm)", "0814"); WIDTH08[4] = new Option("16'' (41cm)", "8016"); WIDTH08[5] = new Option("18'' (46cm)", "0818"); WIDTH08[6] = new Option("20'' (51cm)", "0820"); WIDTH08[7] = new Option("24'' (61cm)", "0824"); WIDTH10[0] = new Option("8'' (20cm)", "1008"); WIDTH10[1] = new Option("10'' (25cm)", "1010"); WIDTH10[2] = new Option("12'' (30cm)", "1012"); WIDTH10[3] = new Option("14'' (35cm)", "1014"); WIDTH10[4] = new Option("16'' (41cm)", "1016"); WIDTH10[5] = new Option("18'' (45cm)", "1018"); WIDTH10[6] = new Option("20'' (51cm)", "1020"); WIDTH10[7] = new Option("24'' (61cm)", "1024"); WIDTH10[8] = new Option("30'' (76cm)", "1030"); WIDTH12[0] = new Option("8'' (20cm)", "1208"); WIDTH12[1] = new Option("10'' (25cm)", "1210"); WIDTH12[2] = new Option("12'' (30cm)", "1212"); WIDTH12[3] = new Option("14'' (35cm)", "1214"); WIDTH12[4] = new Option("16'' (41cm)", "1216"); WIDTH12[5] = new Option("18'' (45cm)", "1218"); WIDTH12[6] = new Option("20'' (51cm)", "1220"); WIDTH12[7] = new Option("24'' (61cm)", "1224"); WIDTH12[8] = new Option("30'' (76cm)", "1230"); WIDTH12[9] = new Option("36'' (91cm)", "1236"); WIDTH14[0] = new Option("8'' (20cm)", "1408"); WIDTH14[1] = new Option("10'' (25cm)", "1410"); WIDTH14[2] = new Option("12'' (30cm)", "1412"); WIDTH14[3] = new Option("14'' (35cm)", "1414"); WIDTH14[4] = new Option("16'' (41cm)", "1416"); WIDTH14[5] = new Option("18'' (45cm)", "1418"); WIDTH14[6] = new Option("20'' (51cm)", "1420"); WIDTH14[7] = new Option("24'' (61cm)", "1424"); WIDTH14[8] = new Option("30'' (76cm)", "1430"); WIDTH14[9] = new Option("36'' (91cm)", "1436"); WIDTH14[10] = new Option("42'' (107cm)", "1442"); WIDTH16[0] = new Option("8'' (20cm)", "1608"); WIDTH16[1] = new Option("10'' (25cm)", "1610"); WIDTH16[2] = new Option("12'' (30cm)", "1612"); WIDTH16[3] = new Option("14'' (35cm)", "1614"); WIDTH16[4] = new Option("16'' (41cm)", "1616"); WIDTH16[5] = new Option("18'' (45cm)", "1618"); WIDTH16[6] = new Option("20'' (51cm)", "1620"); WIDTH16[7] = new Option("24'' (61cm)", "1624"); WIDTH16[8] = new Option("30'' (76cm)", "1630"); WIDTH16[9] = new Option("36'' (91cm)", "1636"); WIDTH16[10] = new Option("42'' (107cm)", "1642"); WIDTH16[11] = new Option("48'' (122cm)", "1648"); WIDTH18[0] = new Option("8'' (20cm)", "1808"); WIDTH18[1] = new Option("10'' (25cm)", "1810"); WIDTH18[2] = new Option("12'' (30cm)", "1812"); WIDTH18[3] = new Option("14'' (35cm)", "1814"); WIDTH18[4] = new Option("16'' (41cm)", "1816"); WIDTH18[5] = new Option("18'' (45cm)", "1818"); WIDTH18[6] = new Option("20'' (51cm)", "1820"); WIDTH18[7] = new Option("24'' (61cm)", "1824"); WIDTH18[8] = new Option("30'' (76cm)", "1830"); WIDTH18[9] = new Option("36'' (91cm)", "1836"); WIDTH18[10] = new Option("42'' (107cm)", "1842"); WIDTH18[11] = new Option("48'' (122cm)", "1848"); WIDTH18[12] = new Option("60'' (152cm)", "1860"); WIDTH18[13] = new Option("72'' (183cm)", "1872"); WIDTH20[0] = new Option("8'' (20cm)", "2008"); WIDTH20[1] = new Option("10'' (25cm)", "2010"); WIDTH20[2] = new Option("12'' (30cm)", "2012"); WIDTH20[3] = new Option("14'' (35cm)", "2014"); WIDTH20[4] = new Option("16'' (41cm)", "2016"); WIDTH20[5] = new Option("18'' (45cm)", "2018"); WIDTH20[6] = new Option("20'' (51cm)", "2020"); WIDTH20[7] = new Option("24'' (61cm)", "2024"); WIDTH20[8] = new Option("30'' (76cm)", "2030"); WIDTH20[9] = new Option("36'' (91cm)", "2036"); WIDTH20[10] = new Option("42'' (107cm)", "2042"); WIDTH20[11] = new Option("48'' (122cm)", "2048"); WIDTH20[12] = new Option("60'' (152cm)", "2060"); WIDTH20[13] = new Option("72'' (183cm)", "2072"); WIDTH24[0] = new Option("8'' (20cm)", "2408"); WIDTH24[1] = new Option("10'' (25cm)", "2410"); WIDTH24[2] = new Option("12'' (30cm)", "2412"); WIDTH24[3] = new Option("14'' (35cm)", "2414"); WIDTH24[4] = new Option("16'' (41cm)", "2416"); WIDTH24[5] = new Option("18'' (45cm)", "2418"); WIDTH24[6] = new Option("20'' (51cm)", "2420"); WIDTH30[0] = new Option("10'' (25cm)", "3010"); WIDTH30[1] = new Option("12'' (30cm)", "3012"); WIDTH30[2] = new Option("14'' (35cm)", "3014"); WIDTH30[3] = new Option("16'' (41cm)", "3016"); WIDTH30[4] = new Option("18'' (45cm)", "3018"); WIDTH30[5] = new Option("20'' (51cm)", "3020"); WIDTH36[0] = new Option("12'' (30cm)", "3612"); WIDTH36[1] = new Option("14'' (35cm)", "3614"); WIDTH36[2] = new Option("16'' (41cm)", "3616"); WIDTH36[3] = new Option("18'' (45cm)", "3618"); WIDTH36[4] = new Option("20'' (51cm)", "3620"); WIDTH42[0] = new Option("14'' (35cm)", "3614"); WIDTH42[1] = new Option("16'' (41cm)", "3616"); WIDTH42[2] = new Option("18'' (45cm)", "3618"); WIDTH42[3] = new Option("20'' (51cm)", "3620"); WIDTH48[0] = new Option("16'' (41cm)", "4816"); WIDTH48[1] = new Option("18'' (45cm)", "4818"); WIDTH48[2] = new Option("20'' (51cm)", "4820"); WIDTH60[0] = new Option("18'' (45cm)", "6018"); WIDTH60[1] = new Option("20'' (51cm)", "6020"); WIDTH72[0] = new Option("18'' (45cm)", "7218"); WIDTH72[1] = new Option("20'' (51cm)", "7220"); function populateSub(mainSel, subSel){ var mainMenu = mainSel; var subMenu = subSel; var subMenuItems; subMenu.options.length = 1; switch (mainMenu.selectedIndex) { case 0: subMenuItems = SELECT_WIDTH_FIRST; break; case 1: subMenuItems = WIDTH08; break; case 2: subMenuItems = WIDTH10; break; case 3: subMenuItems = WIDTH12; break; case 4: subMenuItems = WIDTH14; break; case 5: subMenuItems = WIDTH16; break; case 6: subMenuItems = WIDTH18; break; case 7: subMenuItems = WIDTH20; break; case 8: subMenuItems = WIDTH24; break; case 9: subMenuItems = WIDTH30; break; case 10: subMenuItems = WIDTH36; break; case 11: subMenuItems = WIDTH42; break; case 12: subMenuItems = WIDTH48; break; case 13: subMenuItems = WIDTH60; break; case 14: subMenuItems = WIDTH72; break; } for (var i = 0; i < subMenuItems.length; i++) { subMenu.options[i] = subMenuItems[i]; } } </script> <div style="width:320px; text-align:right;"> <form name="Menus"> <label style="font-size:14px; font-variant:small-caps;">Width</label> <select style="width:250px; margin-bottom:10px;" name="Width" onchange="populateSub(this, this.form.Height);"> <option>Please Select</option> <option value="W08">8'' (20cm)</option> <option value="W10">10'' (25cm)</option> <option value="W12">12'' (30cm)</option> <option value="W14">14'' (35cm)</option> <option value="W16">16'' (41cm)</option> <option value="W18">18'' (46cm)</option> <option value="W20">20'' (51cm)</option> <option value="W24">24'' (61cm)</option> <option value="W30">30'' (61cm)</option> <option value="W36">36'' (61cm)</option> <option value="W42">42'' (61cm)</option> <option value="W48">48'' (61cm)</option> <option value="W60">60'' (61cm)</option> <option value="W72">72'' (61cm)</option> </select> <label style="font-size:14px; font-variant:small-caps;">Height</label> <select style="width:250px; margin-bottom:10px;" name="Height"> <option>Please Select Width First</option> </select> <input type="button" value="View Canvas!"> </form> </div> As mentioned, Javascript is completely new to me but I am attempting to learn. Any help would be greatly appreciated. Wayne Thanks for all the help Old Pedant. You're nice enough to lend people a hand when you don't have to, and this makes the second or third time you've helped me solve a problem I've had with my website. Thanks so much. So I'm making a page where when someone clicks on the second drop list, then it carrys out a function first, and it calculates it based on what the first droplist is picked. Here's the code I have: Code: <html> <head> <title></title> <script type="text/javascript"> function first() { var gold = 4; var green = 6; var red = 30; var blue = 0; var total = 100; if (calculate.color.GetElementById('gold').select) { var depends = gold/total }; if (calculate.color.GetElementById('green').select) { var depends = green/total }; if (calculate.color.GetElementById('red').select) { var depends = red/total }; if (calculate.color.GetElementById('blue').select) { var depends = blue/total }; if (calculate.choice1.GetElementById('first').select) { calculate.results.value = 1 * calculate.howmany.value * depends; } } </script> </head> <body> <form name="calculate"> <table> <td> I need: <input type="text" name="howmany" /> <br /> My choice is: </td> <td> <select name="color"> <option selected id="gold">Gold</option> <option id="green">Green</option> <option id="red">Red</option> <option id="blue">Blue Charms</option> </select> <br /> <select name="choice1"> <option id="first" onClick="first()"> First </option> </select> </td> </tr> <tr> <td colspan="2" align="center" valign="top"> You will need <input type="text" name="results" /> </td> </tr> </table> </form> </body> </html> Any help is well appreciated. Thanks. Okay I Don't Know Much About Javascript, But I Need A Hand I Have A Drag And Drop Script Along With A Simple Script To Make Things Appear And Disappear Bt Using This Line: ShowHide('Table'); return false; I Want to Make It So That When I Drag Something over a Div, More Preferably a Table or an Image and Then Let Go of Your Mouse (onMouseUp) It Makes the Object Disappear Or Have An Action Happen Thanx ________________________________________________________________________________________ Alright, I wrote this a while ago and This Time I'll Be More Clear And Simple. I Want To Make It So That If A Div Hovers Over A Table By Drag And Drop And You Drop Your Div in The Table An Action happens hello, i am more a designer than a developer so i need your help. i want to create a form containing : 1. drop down list of countries (that i managed to create) 2. action on selection (redirect to a link on country selection) 3. post the selected option into a text box below and remeber (if possible) The remeber part is optional . I want a form where user will select country , based on the selection to be redirected to a link and message display , you selected : [textarea]Option[/textarea] can it be done? Hello, I am trying to use select options to get birthdate and calculate the age. I got the birthday with "birthDay = document.form1.selDate;" However i'm lost on the birthMonth and birthYear. I've looked at lots of examples. The birthMonth probably needs to be converted to integer, or use 1 thru 12 rather than Jan thru Dec. But birthYear i'd think would come back as a valid number. Is anyone familiar with this? Thanks. Code: <html> <head> <title>Main</title> <script language="javascript"> <!-- function Age() { var birthDay; var birthMonth; var birthYear; var userAge; var currentDay = new Date(); var dayNow = currentDay.getDate(); var monthNow = (currentDay.getMonth()); var yearNow = (currentDay.getFullYear()); birthDay = document.form1.selDate; // Don't know how to get birthmonth???? // birthMonth = (parseInt(document.form1.selMonth.value)-1); birthYear = document.form1.selYear; // alert("birthyear " + birthYear); ( gives "birthYear [object HTMLSelectElement]") if((monthNow > birthMonth)||(monthNow == birthMonth & dayNow >= birthDay)) { userAge = birthYear; } else { userAge=birthYear+1;} alert("As of today, " + currentDay +' \n'+", you a " + (yearNow - userAge) + " years old"); } //--> </script> </head> <body> <form name="form1" id="startOfForm"> <table><tbody> <tr> <td class="question"><label for="birthdate">Enter Birthdate</label></td> <td> <select name=selMonth> <option value=0 selected>Month</option> <option selected value="Jan">Jan</option> <option selected value="Feb">Feb</option> <option selected value="Mar">Mar</option> <option selected value="Apr">Apr</option> <option selected value="May">May</option> <option selected value="Jun">Jun</option> <option selected value="Jul">Jul</option> <option selected value="Aug">Aug</option> <option selected value="Sept">Sept</option> <option selected value="Oct">Oct</option> <option selected value="Nov">Nov</option> <option selected value="Dec">Dec</option> </select> <select name=selDate> <option value=0 selected>Date</option> <option selected value="1">1</option> <option selected value="2">2</option> <option selected value="3">3</option> <option selected value="4">4</option> <option selected value="5">5</option> <option selected value="6">6</option> <option selected value="7">7</option> <option selected value="8">8</option> <option selected value="9">9</option> </select> <select name=selYear> <option value=0 selected>Year</option> <option value="2001">2001</option> <option value="2000">2000</option> <option value="1999">1999</option> <option value="1998">1998</option> <option value="1997">1997</option> <option value="1996">1996</option> <option value="1995">1995</option> </select> </td> </tr> <tr> <td> <input name="cmd" type=button value="Age" onclick="Age()" style="width:150px; height:30px;"> </td> </tr> </tbody></table> </form> </body> </html> Would this code i made <html> <head> <title>Demo</title> </head> <html> <body> <h3>Just a Demo</h3> <script type="text/javascript"> var numbers = new Array ( "1", "1", "1", "1", "1", "1" ); for ( i=1; i < numbers.length; i++ ) { alert ( numbers[i] ); } </script> </body> </html> Would that be an exmaple of arrays with elements intilized to 1(true) if a mod views this can you correct the spelling mistake in que to queue in heading please ok so before you look at the code i am using the fightBoss() function to start run the main functions read the comment under fightWithSkillOrRefill......(1) http://pastebin.com/ZjbvevfP when you get to the function useInventoryItemMS(item) the if statment gets stuck not sure if its before or after then but when it gets stuck theres a reload function purposly to stop the script from getting stuck but for some reason its not getting to the if statment to clear the queue to stop the reload and then do the next queue set in the if statment. Hey Forum, I have this little script working great when all if's are seperated. what i need is to have the script read if one of these fields has a value then result=true. as you see the script now i have this seperated in many different if's for all three text fields. I need to put all text fields like they were one, thanks Code: function ValidateLink(Form) { var result = true; if (formMyLocations.cellAddress.value.length == 0) { alert('Cell address is empty on the locations page'); result = false; } if (formMyLocations.homeAddress.value.length == 0) { alert('Home address is empty on the locations page'); result = false; } if (formMyLocations.carAddress.value.length == 0) { alert('Car address is empty on the locations page'); result = false; } return result; } Got a timing issue with sending a URI string out to a server side script right before a client side form validation process returns true.. The problem is that the return true gets called to quickly for the submission of the URI string to be completed. So my question is, might there be a way to mix a return and a setTimeout? If so, could some one give a an example? Thanks! hi peeps, this one might be confusing, if so i apologise! below is a cut down version of the script calling a function: Code: function updateStockRequest(thestatus,theform,thedate) { if(thestatus == 'locked') { if(checkStockRequested()) { if(confirm('Are you sure you want to send for processing?\nYou will not be able to add any more stock!')) { document.getElementById('status').value = 'locked'; document.forms[0].submit(); } } else { alert('You must request some stock first!'); } } } the following is the function being called: Code: function checkStockRequested() { //check to see if stockrequest has items added!!! xmlHttp=GetXmlHttpObject() if (xmlHttp==null) { alert ("Browser does not support HTTP Request"); return; } var params = "?theuid=" + escape(document.getElementById('uid').value); var url="_check_stockrequest.php" url=url+params; ajaxedInner = ""; xmlHttp.open("GET",url,true); xmlHttp.setRequestHeader("If-Modified-Since", "Fri, 31 Dec 1999 23:59:59 GMT"); xmlHttp.onreadystatechange=stateChanged; xmlHttp.send(null); xmlHttp.onreadystatechange = function() { if (xmlHttp.readyState == 4){ if (xmlHttp.status == 200) { responsestring = xmlHttp.responseText.replace(/^\s+|\s+$/g, ''); alert(responsestring); if(responsestring == 'true') { return true; } else { return false; } } } } } in the testing the function is alerting 'true' but the calling function still fails and says you need to add stock. i must admit ive rarely used the return syntax so maybe im doing it wrong?!? ive tried many variants such as creating a variable and assigning it the string 'true' etc and then using if(checkStockRequested == 'true') but it still fails. help!!!!!!!!! hi guys, maybe im being stupid but any ideas why this doesnt seem to work: Code: function checkSCItems() { //check sccost not blank due to ajax need to do lookup xmlHttp=GetXmlHttpObject() if (xmlHttp==null) { alert ("Browser does not support HTTP Request"); return; } var params = "?scnumber=" + escape(document.getElementById('scnumber').value); var url="_check_scitems.php"; url=url+params; ajaxedInner = ""; xmlHttp.open("GET",url,true); xmlHttp.setRequestHeader("If-Modified-Since", "Fri, 31 Dec 1999 23:59:59 GMT"); xmlHttp.onreadystatechange=stateChanged; xmlHttp.send(null); xmlHttp.onreadystatechange = function() { if (xmlHttp.readyState == 4){ if (xmlHttp.status == 200) { var checkSCItemsResponse = xmlHttp.responseText; if(checkSCItemsResponse == 'found') { return true; } else { window.location.hash = 'scpricebuildup2'; alert('You must first create some cost items'); return false; } } else { alert('There was a problem, please try again, or contact the Administrator'); return false; } } } } im calling this and if it returns true another function is called but for some reason the 2nd function never seems to happen. (that function works fine so it cant be that - if i just set this function to return true everything works fine too) its being called like so: Code: <a href='javascript:;' onclick="if(checkSCItems() && validateText(document.subcontract_order,['scdate','scworks','scpayment','scfirstpayment','scpaymentinterim','scbalance','scretentionat','sccommence','sccompletion','sclabour','scplant','scmaterials']) && validateDate(document.subcontract_order, ['scdate','scfirstpayment','scbalance','sccommence','sccompletion']) && validateSelectNoBlank(document.subcontract_order, ['trading_name'])){window.open('subcontract_order_print.php?id=<?php echo writeIfSet($id) ?>')}"> is there some issue with ajax and return true? do i need to tell it to call another function that calls return true etc? Hello all, Can anyone help me with a script for changing font color of a number within a table when there is a match? Table A contains numbers and table B contains numbers. When table B numbers matches some of the numbers in table A, the numbers in table A need to change color. I hope you understand what I mean. I am trying to figure out that if the function "xmlhttp.onreadystatechange=function()" returns true the whole function "function checkUser(str)" should return true as well....so not sure how to do it. i have banged my head since long so please advise! Here is the code below: -------------------------------------------------------- function checkUser(str) { var sp = document.getElementById("msgs"); if (str=="") { document.getElementById("msgs").innerHTML="Username cannot be empty."; return false; } if (str.length <= 6) { document.getElementById("msgs").innerHTML="Username cannot be less than 6 characters and must not start with a number or a special value"; return false; } if (window.XMLHttpRequest) { //code for IE7+, firefox, chrome, opera, safari xmlhttp=new XMLHttpRequest(); } else { //code for old IE xmlhttp=new ActiveXObject("Microsoft.XMLHTTP"); } xmlhttp.onreadystatechange=function() { if (xmlhttp.readyState==4 && xmlhttp.status==200) { if (xmlhttp.responseText === 'FOUND') { sp.style.color = "red"; sp.innerHTML = "[ERROR]: The username \"" + str + "\" already exist. Please try a different name."; return false; } else if (xmlhttp.responseText === 'NOT FOUND') { sp.style.color = "blue"; sp.innerHTML = "Username: VALID"; return true; } } } xmlhttp.open("GET", "checkUser.php?q="+str,true); xmlhttp.send(); } Let me first say I am not a java programmer but I can follow the tutorials and get some things to work. Here I am trying to create a password protected page, realizing the level of security is not very high. This page of code, link1.html, will be blank and if the correct password is entered then I want to automatically link to another page, barcs.html. I simply cannot find a way to do it.....Thanks Code: <html> <head> <meta content="text/html; charset=ISO-8859-1" http-equiv="content-type"> <title>Psw test link 1</title> <script language="JavaScript"> <!--hide var password; var pass1="cool"; var pass2="awesome"; var pass3="geekazoid"; password=prompt('Please enter your password to view this page!',' '); if (password==pass1 || password==pass2 || password==pass3) alert('Password Correct! Click OK to enter!'); else { window.location="http://www.acma-rc.com/"; } //--> </script> </head> <body> This is link1.html<br> </body> </html> Is there a difference between right clicking an iframe and reloading post reponse vs. using javascript to reload the frame? So far, the javascript route hasn't worked for me. [some context] I am writing a little bookmarklet to help me with the online registrations at my school. Here is the setup. Load up a page on the domain. Remove all body elements. Insert an iframe. Set iframe to page for class roster search. (in iframe on school search page) Select class search options, POST the form data, and view results in frame. *This works perfectly, but I need to have it refresh results every minute or so. When I use frame.contentDocument.location.reload(true); the frame loses the post data or something and the page is broken. BUT when I just right click on the frame and select "reload frame" it works perfectly. Whats the deal here? What is the difference between rightclicking the frame and refreshing it like that vs. using javascript to reload the frame? PS: using chrome Hi All, This is in ASP.Net Im creating a task loggin system and this allows the user to raise tasks and update them, im using javascript for validation and if the fields are empty it then changes the fields back ground to Red which is fine but then it goes on to update the data in SQL which i dont want, any suggestions or how i can achieve no post back is the result from the function is False (for fields in error) Html Code where im calling the function Code: <asp:button runat="server" id="btnChangeCommentsAuth" CSSclass="RaiseButton" OnClientClick="CommentsCheck('MainDisplayContentChange_txtAuthCommentsArea');" PostBackUrl="~/RaiseTaskChange.aspx" Text="Auth" /> Javascript function Code: function CommentsCheck(comments) { var com; var result = new boolean(); com = document.getElementById(comments); if (document.getElementById(comments).value == '') { com.style.backgroundColor = "#B20635"; result = 0; } else { result = 1 } } Thanks in Advance look forward to your reply. |