JavaScript - For Loop Wont Finish
hi
I created a forloop and that runs fine, but it wont run any code after the loop finishes. I've tryed playing around with it but nothing I do will make it display the alert. Heres the problem code: Code: function price() { var price=0; for(var i=1; i<=15; i++) { if(document.form.partPrice[i].value == "price" == false) { price+=Number(document.form.partPrice[i].value); alert("test"); } } //wont run any code after here alert(price); } I'm not sure whats wrong, its probably something small that im overlooking but I just cant find whats wrong thanks in advance! Similar Tutorialsit wont loop, as long as you enter something in the name field it will submit. also how do i stop from submitting if all fields are not filled out? any help will be appreciated) ====== function checkForm(form) { var len = form.elements.length; var h=0; for (h=0; h<=len; h++){ if ((form.elements[h].value==null) || (form.elements[h].value=="")){ alert("Please enter "+document.myForm.elements[h].name); document.myForm.elements[h].focus(); return false; } return true; } } ===body-== <FORM NAME="myForm" METHOD="post" ACTION="http://ss1.prosofttraining.com/cgi-bin/process.pl"> Name:<BR> <INPUT TYPE="text" size="30" NAME="name"><br> Email address:<BR> <INPUT TYPE="text" size="30" NAME="email address" onBlur="emailTest(this);"><br> Phone number:<BR> <INPUT TYPE="text" size="30" NAME="phone number"><br> Fax number:<BR> <INPUT TYPE="text" size="30" NAME="fax number"><p> <INPUT TYPE="submit" VALUE="Submit Data" onClick="return checkForm(this.form);"> <INPUT TYPE="reset" VALUE="Reset Form"> </FORM> Hello, can make recommendations that it is necessary to finish in this site, I see that that that doesn't suffice but I will not understand that, to you I will be very grateful for your answers Here a site http://iceroos.ru Hi all, I've been trying to figure out for the past 4 hours why this JS pop up window function I wrote won't finish loading in Firefox. When you click the thumbnail image, it pops up a new window with the image enlarged. But for some reason, the Firefox page loading bar on the bottom right-hand side stops at about 25%, even after the image finishes loading. What is wrong with my code that I need to fix so the page shows that it loaded 100%? Here is a link to the page: http://www.unitedautoandtruck.com/cu...ilt_truck.html Code: <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <script language="javascript" type="text/javascript"> <!-- function pop_up_window (image, title, width, height, text, close_button, scroll_bars, bg) { var l = (screen.width-width) / 2 - 6; var t = (screen.height-height) / 2 - 28; var pop_up = window.open('', '_blank', 'toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars='+scroll_bars+',resizable=no,copyhistory=no,top='+t+',left='+l+',width='+width+',height='+height); pop_up.document.write ('<html>'); pop_up.document.write ('<title>'+title+'</title>'); window.name='main'; if (bg == 'default') bg = '#FFFFFF'; if (bg.charAt(0) == '#') pop_up.document.write ('<body bgcolor='+bg+' text=black link=blue vlink=purple alink=red>'); else pop_up.document.write ('<body background="'+bg+'" text=black link=blue vlink=purple alink=red>'); pop_up.document.write ('<style> A:link {text-decoration: none} A:visited {text-decoration: none} A:active {text-decoration: none} </style>'); if (image != ' ') { pop_up.document.write ('<center><img src="'+image+'"></center>'); } if (text != ' ') { pop_up.document.write ('<center><table BORDER=0 CELLSPACING=0 CELLPADDING=0 WIDTH="94%"><tr><td>'); pop_up.document.write (''+text+''); pop_up.document.write ('</td></tr></table></center>'); } if (close_button == 1) { pop_up.document.write ('<form name="closeit">'); pop_up.document.write ('<center><input type="button" value="Close" onClick="window.close();"></center>'); pop_up.document.write ('</form>'); } pop_up.document.write ('</body>'); pop_up.document.write ('</html>'); } // --> </script> <title>Transformers Peterbilt Truck</title> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> </head> <body> <a href="javascript:pop_up_window ('../images/customgallery/transformers_peterbilt_truck/DSC02061.jpg', 'Transformers', 623, 534, ' ', 1, 'no', 'default')" onMouseOver="window.status='Press to Enlarge'; return true"> <img src="../images/customgallery/transformers_peterbilt_truck/DSC02061.jpg" width="150" height="113"></a> </body> </html> Hey there guys, I'm working with an AJAX request that returns some stuff to print in 2 boxes. All working great, so I decided to make something fluffy, when I click a result in the AJAX request, he filters the clicked result, so you only see that clicked row. When clicked again, the old results will return. All working great. Now, my problem, I wanted a checkbox after every row in the search results and when the user clicks twice on a result to filter it and than goes back to the old results to check the checkboxes again that were checked before filtering that component. I made the functions and it didn't work till I put some alerts in, when the return function got some time to finish printing (like with the user had to click on OK in the alert) it worked. When I deleted the alerts, it didn't work again... I searched on the internet, found a function to wait for an image to load or smth similar and I found some guys that used a function to wait for a specific time (1 sec for example) and that's not what I want. If I use a specific waittime it can still fail if the PC is slow, or whatever, it's just not nice coding. So, is there something I can do so it waits till my AJAX request has been printed? Thanks! 'x. I try to get data from database and display them onto a div, after all messages are shown on the div, then only it will know the scrollheight of the div, it will auto scroll to the bottom of div as default by function asd(). My problem is when there are too many messages on database, it took very long time to display them all onto the div, so asd() executed before all messages are displayed. Meaning the scrollheight of the div is incorrect at this point, thus auto scroll to bottom is fail. Code: $(function() { showMsg(); asd(); }); How to wait until showMsg() finish render the contents before execute asd()? I havejQuery.get(); .append(); .replace(); .innerHTML inside showMsg(). The problem is fixed when I use timeout to execute asd() after 3 seconds : Code: $(function() { showMsg(); setTimeout(asd();, 3000); }); That's why I sure asd() is executed when showMsg() is not yet finish loaded the contents. I guess I know where is the problem. If showMsg() is executed BEFORE the DOM is ready, and if asd() is executed AFTER DOM is ready (at this point all messages are rendered already), so the problem is fix. But now my situation is AFTER the DOM is ready, all messages still not yet finish rendered, because showMsg() and asd() are executed only AFTER the DOM is ready. "executed" doesn't mean "finish rendered". My question is how to make sure showMsg() finish rendered the contents into a div before execute asd() ? Hi Guys, im using chrome and ff and it worked fine till i tested on ie7 and the form just wont send on ie7. it gives me a validation error msg "SOME VALUES ARE NOT ACCEPTABLE" when i try to submit. ive tried so many things and i cant figure out why ie7 wont send upon submit like ff does, code seems to be fine, pls see validation coding line 7 - 32 , any jsGURU advice will be much appreciated! Code: <?php defined('_JEXEC') or die('Restricted access'); ?> <?php JHTML::_('behavior.formvalidation'); ?> <script language="javascript" type="text/javascript"> function submitbutton(pressbutton) { var form = document.adminForm; if (pressbutton == 'cancel') { submitform( pressbutton ); return; } // do field validation if (document.getElementById('jformfirstname').value == ""){ alert( "<?php echo JText::_( 'Firstname is missing.', true ); ?>" ); } else if (document.getElementById('jformsurname').value == ""){ alert( "<?php echo JText::_( 'Surname is missing.', true ); ?>" ); } else if (document.getElementById('jformemail').value == ""){ alert( "<?php echo JText::_( 'Email is missing.', true ); ?>" ); } else if (document.getElementById('jformphone1').value == ""){ alert( "<?php echo JText::_( 'Phone1 is missing.', true ); ?>" ); } else { if (document.formvalidator.isValid(form)) { submitform( pressbutton ); } else { alert("<?php echo JText::_( 'SOME VALUES ARE NOT ACCEPTABLE.', true ); ?>"); } } } </script> <?php if ($this->courseid){ ?> <?php if ( $this->params->def( 'show_page_title', 1 ) ) : ?> <div class="componentheading<?php echo $this->params->get( 'pageclass_sfx' ); ?>"> <?php echo $this->courseDetails->title; ?> </div> <?php endif; ?> <h3>Course Details</h3> <table cellSpacing=0 cellPadding=5 width="90%" border=0> <tr> <td width="20%"><?php echo JText::_( 'Course Title' ); ?>:</td> <td width="30%"><?php echo $this->courseDetails->title;?></td> <td width="20%"><?php echo JText::_( 'Code' ); ?>:</td> <td width="30%"><?php echo $this->courseDetails->code;?></td> </tr> <tr> <td><?php echo JText::_( 'Price' ); ?>:</td> <td><?php echo (number_format($this->courseDetails->price,2));?></td> <td><?php echo JText::_( 'No. of Days' ); ?>:</td> <td><?php echo $this->courseDetails->capacity;?></td> </tr> <tr> <?php if ($_GET['hide'] != 1 ) { ?> <td><?php echo JText::_( 'Location' ); ?>:</td> <td><?php echo $this->courseDetails->course_location;?></td> <?php } else { echo "<td> </td>"; echo "<td> </td>"; } ?> </tr> <tr> <?php if ($_GET['hide'] != 1 ) { ?> <td><?php echo JText::_( 'Start Date' ); ?>:</td> <td><?php echo Date('d-M-y', strtotime($this->courseDetails->start_date));?></td> <?php } else { echo "<td> </td>"; echo "<td> </td>"; } ?> </tr> </table> <?php } ?> <?php if ( $this->params->def( 'show_course_sessions', 1 ) && ($this->courseid) ) : ?> <h3>Sessions</h3> <table cellSpacing=0 cellPadding=5 width="90%" border=0> <tr> <td width="20%" align="center" height="20" class="sectiontableheader<?php echo $this->params->get( 'pageclass_sfx' ); ?>"> <?php echo JText::_('Day'); ?> </td> <td width="20%" align="center" height="20" class="sectiontableheader<?php echo $this->params->get( 'pageclass_sfx' ); ?>"> <?php echo JText::_('Start Time'); ?> </td> <td width="20%" align="center" height="20" class="sectiontableheader<?php echo $this->params->get( 'pageclass_sfx' ); ?>"> <?php echo JText::_('Finish Time'); ?> </td> <td width="10%" align="center" height="20" class="sectiontableheader<?php echo $this->params->get( 'pageclass_sfx' ); ?>"> <?php echo JText::_('Duration'); ?> </td> <td width="30%" align="center" height="20" class="sectiontableheader<?php echo $this->params->get( 'pageclass_sfx' ); ?>"> <?php echo JText::_('Location'); ?> </td> </tr> <?php $k = 0; $n=count( $this->course_sessions ); if ($n > 0){ for ($i=0, $n; $i < $n; $i++) { $row = &$this->course_sessions[$i]; ?> <tr> <td align="center"> <?php echo $row->session_day;?> </td> <td align="center"> <?php echo date('H:i', strtotime($row->start_time));?> </td> <td align="center"> <?php echo date('H:i', strtotime($row->finish_time));?> </td> <td align="center"> <?php echo $row->duration;?> </td> <td align="center"> <?php echo $row->session_location;?> </td> </tr> <?php $k = 1 - $k; } } else { ?> <tr> <td colspan="5"><? echo JText::_( 'There are no sessions for this course' );?></td></tr><?php } ?> </table> <?php endif; ?> <form action="<?php echo $this->action ?>" method="post" name="adminForm" id="adminForm" class="form-validate"> <?php if ( $this->params->def( 'show_page_title', 1 ) ) : ?> <div class="componentheading<?php echo $this->params->get( 'pageclass_sfx' ); ?>"> <?php echo $this->escape($this->params->get('page_title')); ?> </div> <?php endif; ?> <table cellpadding="4" cellspacing="1" border="0" width="100%"> <tr> <td width="15%"> <label for="jformcourseid"> <?php echo JText::_( 'Course' ); ?>: </label> </td> <td> <?php echo $this->lists['courseid'];?>* </td> </tr> <?php if ($_GET['hide'] == 1 ) { ?> <tr> <td valign="top"> <label for="jformcity"> <?php echo JText::_( 'I want to attend this course here' ); ?>: </label> </td> <td width="80%"> <select class="required" type="text" id="jformcountry" name="jform[country]" value="<?php echo $this->escape($this->booking->country);?>" />* <option>Choose your Location</option> <option>Melbourne</option> <option>Sydney</option> <option>Auckland</option> </select> </td> </tr> <?php } ?> <tr> <td valign="top"> <label for="jformfirstname"> <?php echo JText::_( 'Firstname' ); ?>: </label> </td> <td width="80%"> <input class="required" type="text" id="jformfirstname" name="jform[firstname]" size="50" maxlength="250" value="<?php echo $this->escape($this->booking->firstname);?>" />* </td> </tr> <tr> <td valign="top"> <label for="jformsurname"> <?php echo JText::_( 'Surname' ); ?>: </label> </td> <td valign="top"> <input class="required" type="text" id="jformsurname" name="jform[surname]" size="50" maxlength="250" value="<?php echo $this->escape($this->booking->surname);?>" />* </td> </tr> <?php if($this->userid > 0) { ?> <tr> <td valign="top"> <label for="jformusername"> <?php echo JText::_( 'Username' ); ?>: </label> </td> <td width="80%"> <input class="required" type="text" id="jformusername" name="jform[username]" size="50" maxlength="100" value="<?php echo $this->escape($this->username);?>" READONLY/>* </td> </tr> <?php } ?> <tr> <td valign="top"> <label for="jformdepartment"> <?php echo JText::_( 'Company' ); ?>: </label> </td> <td width="80%"> <input class="inputbox" type="text" id="jformdepartment" name="jform[department]" size="50" maxlength="30" value="<?php echo $this->escape($this->booking->department);?>" /> </td> </tr> <tr> <td valign="top"> <label for="jformemail"> <?php echo JText::_( 'Email' ); ?>: </label> </td> <td width="80%"> <input class="validate-email" type="text" id="jformemail" name="jform[email]" size="50" maxlength="100" value="<?php echo $this->escape($this->email);?>"/>* </td> </tr> <tr> <td valign="top"> <label for="jformphone1"> <?php echo JText::_( 'Phone Number' ); ?>: </label> </td> <td width="80%"> <input class="required" type="text" id="jformphone1" name="jform[phone1]" size="50" maxlength="20" value="<?php echo $this->escape($this->booking->phone1);?>" />* </td> </tr> <tr> <td valign="top"> <label for="jformcity"> <?php echo JText::_( 'Locations' ); ?>: </label> </td> <td width="80%"> <select type="text" id="jformcity" name="jform[city]" value="<?php echo $this->escape($this->booking->city);?>" /> <option>Choose your Location</option> <option>Melbourne</option> <option>Sydney</option> <option>Auckland</option> </select> </td> </tr> <tr> <td valign="top"> <label for="jforminstitution"> <?php echo JText::_( 'Referral Source' ); ?>: </label> </td> <td width="80%"> <select type="text" id="jforminstitution" name="jform[institution]" value="<?php echo $this->escape($this->booking->institution);?>" /> <option>How did you find out about us?</option> <option>Search Engine</option> <option>Friends</option> <option>Others</option> </select> </td> </tr> <tr> <td valign="top"> <label for="jformdescription"> <?php echo JText::_( 'Comments' ); ?>: </label> </td> <td> <textarea class="inputbox" cols="47" rows="6" id="jformdescription" name="jform[description]"><?php echo $this->escape( $this->booking->description);?></textarea> </td> </tr> </table> <div> <button type="button" class="button validate" onclick="submitbutton('save')"> <?php echo JText::_('Save') ?> </button> <button type="button" onclick="submitbutton('cancel')"> <?php echo JText::_('Cancel') ?> </button> </div> <input type="hidden" name="jform[id]" value="<?php echo $this->booking->id; ?>" /> <input type="hidden" name="jform[ordering]" value="<?php echo $this->booking->ordering; ?>" /> <input type="hidden" name="jform[approved]" value="<?php echo $this->booking->approved; ?>" /> <input type="hidden" name="jform[userid]" value="<?php echo $this->userid; ?>" /> <input type="hidden" name="option" value="com_courseman" /> <input type="hidden" name="controller" value="booking" /> <input type="hidden" name="task" value="" /> <?php echo JHTML::_( 'form.token' ); ?> </form> </br> Fields marked with an asterisk (*) are required. </br> </br> Hi all, Edit: Got it. I saved that source page and investigated closely and I realized that there's "Cookie plugin" script, which is not mentioned to add(?), in that tutorial I've been trying to implement the method given at http://dev.akabillposters.com/dom-js...-links-jquery/, but can't make it work. Nothing happens when I click the check box. I'm not a jquery expert, though tried some alerts statements to trace the issue, with no luck. Can anyone see what I'm missing? [link removed] Any help would be appreciated. Thanks. Ok, I'm nearly pulling my hair out with this one. I have been looking at this code for two evenings now, and rewrote it 4 times already. It started out as jQuery code and now it's just concatenating strings together. What I'm trying to do: Build a menu/outline using unordered lists from a multidimensional array. What is happening: Inside the buildMenuHTML function, if I call buildMenuHTML, the for loop only happens once (i.e. only for 'i' having a value of '0'.) If I comment out the call to itself, it goes through the for loop all 3 times, but obviously the submenus are not created. Here is the test object: Code: test = [ { "name" : "Menu 1", "url" : "menu1.html", "submenu" : [ { "name" : "menu 1 subitem 1", "url" : "menu1subitem1.html" }, { "name" : "menu 1 subitem 2", "url" : "menu1subitem2.html" } ] }, { "name" : "Menu 2", "url" : "menu2.html", "submenu" : [ { "name" : "menu 2subitem 1", "url" : "menu2subitem1.html" }, { "name" : "menu 2subitem 1", "url" : "menu2subitem1.html" } ] }, { "name" : "Menu 3", "url" : "menu3.html", "submenu" : [ { "name" : "menu 3 subitem 1", "url" : "menu3subitem1.html" }, { "name" : "menu 3 subitem 1", "url" : "menu3subitem1.html" } ] } ]; Here is the recursive function: Code: function buildMenuHTML(menuData,level) { var ul; if (level == 1) { ul = "<ul id='menu'>"; } else { ul = "<ul class='level" + level + "'>"; } for (i = 0; i < menuData.length; i++) { menuItemData = menuData[i]; ul += "<li>"; ul += "<a href='" + menuItemData.url + "'>" + menuItemData.name + "</a>"; if (typeof menuItemData.submenu != 'undefined') { ul += buildMenuHTML(menuItemData.submenu,level + 1); } ul += "</li>"; } ul += "</ul>"; return ul; } Here is how the function is called initially: Code: buildMenuHTML(test,1); This is it's return value (with indentation added for readability): Code: <ul id='menu'> <li><a href='menu1.html'>Menu 1</a> <ul class='level2'> <li><a href='menu1subitem1.html'>menu 1 subitem 1</a></li> <li><a href='menu1subitem2.html'>menu 1 subitem 2</a></li> </ul> </li> </ul> 'Menu 2' and 'Menu 3' don't show up! I'm sure it's something small that I'm overlooking, but any help would be appreciated. Hi all I'm well aware that I can't post assignments here and expect an answer, however, I have been staring at this code for so long. I feel I am close to the solution (to get the correct output to the browser) but I just cannot get it to count how many moves it takes. I don't want an answer, but a nudge in the right direction would be very grateful. As you can see from the code and the output, it will attempt to write to the browser how many moves, but only '0'. Code: function rollDie() { return Math.floor(Math.random() * 6) + 1; } /* *searches for a number in a number array. * *function takes two arguments * the number to search for * the number array to search *function returns the array index at which the number was found, or -1 if not found. */ function findIndexOf(number, numberArray) { var indexWhereFound = -1; for (var position = 0; position < numberArray.length; position = position + 1) { if (numberArray[position] == number) { indexWhereFound = position; } } return indexWhereFound; } //ARRAYS that represent the board -- you do not need to change these //array of special squares var specialSquaresArray = [1,7,25,32,39,46,65,68,71,77]; //array of corresponding squares the player ascends or descends to var connectedSquaresArray = [20,9,29,13,51,41,79,73,35,58]; //VARIABLES used -- you do not need to change these //the square the player is currently on var playersPosition; //play is initially at START playersPosition = 0; //what they score when they roll the die var playersScore; //the index of the player's position in the special squares array or -1 var indexOfNumber; //MAIN PROGRAM //TODO add code here for parts (iii), (iv)(b), (v), and (vi) // start of question(iii) playersScore = rollDie(); document.write(' Sco ' + playersScore); playersPosition = playersScore + playersPosition; document.write(', Squa ' + playersPosition); indexOfNumber = findIndexOf(playersPosition, specialSquaresArray); if (indexOfNumber != -1) { document.write(', Ladder to Squa ' + connectedSquaresArray[indexOfNumber]); playersPosition = connectedSquaresArray[indexOfNumber]; indexOfNumber = -1; } document.write('<BR>') // end of question(iii) // start of question(iv)(b) while(playersPosition<=80) { playersScore = rollDie() document.write(' Sco ' + playersScore) playersPosition = playersPosition + playersScore document.write(', Squa ' + playersPosition) indexOfNumber = findIndexOf(playersPosition, specialSquaresArray) if(indexOfNumber != -1) { document.write(', Ladder to Squa ' + connectedSquaresArray[indexOfNumber]); playersPosition = connectedSquaresArray[indexOfNumber]; } document.write('<BR>'); } var countMoves = 0; while(countMoves <= 0) { document.write('You took ' + countMoves + ' moves to get out'); countMoves = countMoves + 1 } /*for (var countMoves = 0; countMoves < playersPosition; countMoves = countMoves + 1) { countMoves = countMoves + playersPosition; document.write('You took ' + countMoves + ' moves to get out'); }*/ // end of question(iv)(b) // start of question (v) /*if (playersPosition >=80) { document.write('The player is out'); }*/ // end of question (v) </SCRIPT> </HEAD> <BODY> </BODY> </HTML> Many thanks. Hello... Thanks for reading... I am getting an undefined error when i try to get a value from this array in the interior loop... Code: // This is the array I am trying to access AuditTable [0] = ["Visio Modifed date","Word Modified Date","User Status","User Comment","Last Audit","Audit Status","Audit Comment"] AuditTable [1] = ["11/23/2009 8:52:18 AM","missing","OK","user comment number 1","1/1/2009","ok","audit comment number 1"] AuditTable [2] = ["11/24/2009 12:21:19 AM","missing","Out of Date","Changes from 2008 not implemented","1/2/2009","Out of Date","needs update"] AuditTable [3] = ["11/22/2009 9:24:42 PM","missing","Incomplete","Document doesnt cover all possibilities","1/3/2009","Inadequate","needs update"] I have hard coded values and had success such as: Code: data = AuditTable[1][0] But when I put the vars associated with the loop in I get an undefined error - AuditTable[i] is undefined: Code: // produces error data = AuditTable[i][j] //Works but retrieves wrong data data = AuditTable[j][i] //Works but retrieves wrong data data = AuditTable[1][i] //Works but retrieves wrong data data = AuditTable[j][2] I must be trying to access the array incorrectly or something... I have defined all the vars, and tried many combinations, alerted the values of both vars so I can prove it is not a scope issue... Am I missing something obvious? Thanks much... Code: var reportArray=new Array(); var reportData, title, subTitle, data; for(i in parmarray)// loop thru AuditTable array and get values { title = '<div style="font-family:verdana; font-size:14px; font-weight:bold; margin:25px 0px 5px 30px">'; title += namearray[i][0]; title += '</div>'; reportArray.push(title);//Take compiled variable value and put it into array for(j=0; j < AuditTable[0].length; j++)// loop thru AuditTable array and get values { subTitle = AuditTable[0][j];//points to first row of AuditTable where the labels are data = AuditTable[1][0];//points to the current row where actual data is html = i + j +'<div style="font-family:verdana; font-size:12px; color:#696969; font-weight:bold; margin-left:30px;">'; html += subTitle; html += '</div><div style="font-family:verdana; font-size:12px; color:#a9a9a9; margin-left:30px; margin-bottom:10px">'; html += data; html += "</div>"; reportArray.push(html);// put results into array } } Any idea why my code will not add a row? Code: function addRow() { var tbl = document.getElementById('thetable'); var lastRow = tbl.rows.length; var row = tbl.insertRow(lastRow); var cell1 = row.insertCell(0); cell1.setAttribute('align','center') var input = document.createElement('input'); input.name = 'date' + lastRow; input.id = 'date' + lastRow; cell1.appendChild(input); var cell2 = row.insertCell(1); cell2.setAttribute('align','center') input = document.createElement('input'); input.name = 'goals' + lastRow; input.id = 'goals' + lastRow; cell2.appendChild(input); var cell3 = row.insertCell(1); cell3.setAttribute('align','center') input = document.createElement('input'); input.name = 'venue' + lastRow; input.id = 'venue' + lastRow; cell3.appendChild(input); var cell4 = row.insertCell(1); cell4.setAttribute('align','center'); input = document.createElement('select'); input.name = 'terrain' + lastRow; input.id = 'terrain' + lastRow; var s = "Road/Track/Multi Terrain/Cross Country".split("/"); for(var i=0;i<s.length;i++) { var o = document.createElement("option"); o.value = s[i]; o.text = s[i]; input.add(o); } cell4.appendChild(input); } window.onload = function() { var cell5 = document.getElementById("cell5"); cell5.setAttribute('align','center'); input.name = 'distance' + lastRow; input.id = 'distance' + lastRow; var input = document.createElement("select"); var s = "3000m/5000m/10,000m/5 Miles/10 Miles/20 Miles/Half Marathon/Marathon /Other".split("/"); for(var i=0;i<s.length;i++) { var o = document.createElement("option"); input.options[i] = new Option(s[i], s[i]); } cell5.appendChild(input); } } function delRow() { var tbl = document.getElementById('thetable'); var lastRow = tbl.rows.length; if (lastRow > 2) tbl.deleteRow(lastRow - 1); } </script> Hi I have a CMS system using Tinymce and after making some alterations noticed the updates weren't showing up. After much messing (sql, set up etc) I started to delete the content bits at a time and came to the conclusion that is was the character ' as in what's any ideas why this is and how to solve it i'm thinking its due to php code! Cheers This will work in firefox but not IE. Any alternative I am new to coding and not sure how to do this. Code: <div id="leftnav"> <ul> <li><a href="home.html"><img src="home1.gif" onmouseover="document.homeb.src='home2.gif';" onmouseout="document.homeb.src='home1.gif';" id= "homeb" alt="home1"></a></li> <li><a href="striping.html"><img src="striping.gif" alt="striping" id="striping" onmouseover= "document.striping.src='striping2.gif';" onmouseout="document.striping.src='striping.gif';"> </a></li> <li><a href="design.html"><img src="design.gif" alt="design" id="design" onmouseover= "document.design.src='design2.gif';" onmouseout= "document.design.src='design.gif';"></a></li> <li><a href="lettering.html"><img src= "lettering.gif" alt="lettering" id="lettering" onmouseover= "document.lettering.src='lettering2.gif';" onmouseout= "document.lettering.src='lettering.gif';"></a></li> <li><a href="contact.html"><img src="contact.gif" alt="contact" id="contact" onmouseover= "document.contact.src='contact2.gif';" onmouseout= "document.contact.src='contact.gif';"></a></li> </ul> </div> Problem solved, thanks for looking.
hey all, what it says in the title, this block of code wont work and i dont know why. the first prompt box appears but not the "can vote, but can't drink" reply. can anyone offer any ideas? <!DOCTYPE html> <html> <head> <title>legal age</title> <script type="text/javascript"> var your_age = prompt("how old are you?"); if ((age > 18) && (age < 21)) { document.writeln("can vote, but can't drink."); } </script> </body> </html> kind regards, Redd . Hey I have a JS value but it won't put the value in the brackets when i try to get the element by ID instead it is looking for the id named the same as the variable name. Here is what i got to explain better: Code: function fill_div(v) { document.getElementById(v).innerHTML="<img src='untitle.png' style='width:100%;height:100%;'/>"; } var x = 0; var y = 3; var area = 1; window.onload = fill_div(area+':'+x+':'+y); It ends up looking for id v instead of id 1:0:3. Any idea how i correct this ? My function the_magnitude() takes in values from 4 different asp:textboxes. The textboxes "easting" and "northing" contain numbers that don't change, but the textboxes "east" and "north" contain numbers inputed by the user, and the function returns "error" as a value to be put into another textbox that we'll call "error box". So what it's suppose to do is when I update the information in either "east" or"north" it will update, on change, the number in the "error box". It kinda works. My problem is that if the number is a value that changes the style to red, #ff0000, in the function it wont update the "error box" and it just leaves a red zero that is a default number in the box. The only way I can get the number to change is if I end up with a number less than 200, which would make the text green. I'm pretty sure it's a problem with my javascript. here is my function Code: <script type="text/javascript"> function the_magnitude(easting, east, northing, north, error) { var a = easting.value; var b = east.value; var c = northing.value; var d = north.value; var total = Math.sqrt(((a - b) * (a - b)) + ((c - d) * (c - d))); if (total > 200) { document.getElementById('TextBox155').style.color = "#ff0000"; document.getElementById('TextBox155').style.fontWeight = "bold"; } else { document.getElementById('TextBox155').style.color = "#008000"; document.getElementById('TextBox155').style.fontWeight = "bold"; error.value = roundNumber(total); } } </script> and here are the two buttons that I input numbers into for east and north Code: <html> <body> <asp:TextBox ID="TextBox153" runat="server" Height="0.25in" Style="font-family: Arial, Helvetica, sans-serif; font-size: small; text-align: center" Width="0.75in" onchange="the_magnitude(document.getElementById('TextBox153'), document.getElementById('TextBox212'), document.getElementById('TextBox154'), document.getElementById('TextBox213'), document.getElementById('TextBox155'))" ></asp:TextBox> </body> </html> Code: <html> <body> <asp:TextBox ID="TextBox153" runat="server" Height="0.25in" Style="font-family: Arial, Helvetica, sans-serif; font-size: small; text-align: center" Width="0.75in" onchange="the_magnitude(document.getElementById('TextBox153'), document.getElementById('TextBox212'), document.getElementById('TextBox154'), document.getElementById('TextBox213'), document.getElementById('TextBox155'))" ></asp:TextBox> </body> </html> and here is the textbox that I want the return of the function to go into. Code: <html> <body> <asp:TextBox ID="TextBox155" runat="server" Height="0.25in" Style="font-family: Arial, Helvetica, sans-serif; font-size: small; text-align: center" Width="0.5in">0</asp:TextBox> </body> </html> Hi guys.. I cant figure out why the validation wont work on the form.. PHP Code: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Cork Discos Mailing List</title> <link href="css/stylesheet.css" rel="stylesheet" type="text/css" /> <script type="text/javascript" src="js/form_validation.js"></script> </head> <body> <div id="wrapper"> <div id="star1"> <div id="star2"> <div id="star3"> <div id="star4"> <div id="header"> <h1>Cork Discos Texting Service</h1> </div> <div id="content"> <form name="frm" action="index.html" 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> </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">Date of Birth</td> <td> <select name="date1" style="width:43px"> <option value=1>1</option><option value=2>2</option><option value=3>3</option><option value=4>4</option><option value=5>5</option><option value=6>6</option><option value=7>7</option><option value=8>8</option><option value=9>9</option><option value=10>10</option><option value=11>11</option><option value=12>12</option><option value=13>13</option><option value=14>14</option><option value=15>15</option><option value=16>16</option><option value=17>17</option><option value=18>18</option><option value=19>19</option><option value=20>20</option><option value=21>21</option><option value=22>22</option><option value=23>23</option><option value=24>24</option><option value=25>25</option><option value=26>26</option><option value=27>27</option><option value=28>28</option><option value=29>29</option><option value=30>30</option><option value=31>31</option> </select> <select name="date2" style="width:43px"> <option value=1>1</option><option value=2>2</option><option value=3>3</option><option value=4>4</option><option value=5>5</option><option value=6>6</option><option value=7>7</option><option value=8>8</option><option value=9>9</option><option value=10>10</option><option value=11>11</option><option value=12>12</option> </select> <select name="date3" style="width:102px"> <option value=1955>1955</option><option value=1956>1956</option><option value=1957>1957</option><option value=1958>1958</option><option value=1959>1959</option><option value=1960>1960</option><option value=1961>1961</option><option value=1962>1962</option><option value=1963>1963</option><option value=1964>1964</option><option value=1965>1965</option><option value=1966>1966</option><option value=1967>1967</option><option value=1968>1968</option><option value=1969>1969</option><option value=1970>1970</option><option value=1971>1971</option><option value=1972>1972</option><option value=1973>1973</option><option value=1974>1974</option><option value=1975>1975</option><option value=1976>1976</option><option value=1977>1977</option><option value=1978>1978</option><option value=1979>1979</option><option value=1980>1980</option><option value=1981>1981</option><option value=1982>1982</option><option value=1983>1983</option><option value=1984>1984</option><option value=1985>1985</option><option value=1986>1986</option><option value=1987>1987</option><option value=1988>1988</option><option value=1989>1989</option><option value=1990>1990</option><option value=1991>1991</option><option value=1992>1992</option><option value=1993>1993</option><option value=1994>1994</option><option value=1995>1995</option><option value=1996>1996</option><option value=1997>1997</option><option value=1998>1998</option><option value=1999>1999</option><option value=2000>2000</option><option value=2001>2001</option><option value=2002>2002</option><option value=2003>2003</option><option value=2004>2004</option><option value=2005>2005</option><option value=2006>2006</option><option value=2007>2007</option><option value=2008>2008</option><option value=2009>2009</option><option value=2010>2010</option> </select> </td> </tr> <tr> <td class="normalText">Gender</td> <td valign="middle" valign="middle"> <input type="radio" name="gender" id="genderM" value="Male" /> Male <input type="radio" name="gender" id="genderFM" value="Female" checked/> Female </td> </tr> --> <tr> <td class="normalText">Comments</td> <td> <textarea name="comments" id="comments" 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> </div> </div> </div> </div> </div> </div> </body> </html> 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('#comments').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 figure it out.. im trying it all morning Hi I can get both to work separately. If Iput the slideshow below the menu bar in the body it does not play if I put the slideshow first the menu bar does not appear Can anybody help please file uploaded. |