JavaScript - Table And Fill Text In
Hello now i found better way how to show it to you people.
I finished one teail of this workd . Now the most important thing i need to do is > 1. Check this http://zr-gaming.ucoz.com/index/ban_lista/0-5 2. In place "Nick Igraca" __________ . When i type there something , that text shoudl go automaticly in table oben Example When i write "OMG" it should fill "OMG" Under "Nick Igraca" There you see Pred@t0R is allredy filled in , but i do it alone in codes . So i want when i fill the text and press submit it should go to real place automaticly , so it should be filled in . How can i do it ? I hear i need some script or something . I will give you Reward and Reputation points for help , its inportant for me , i need to finish it for 24 hours . Thank you very much guys . If you dont understand something just tell me . And very thanks to you who will try to help me . Similar TutorialsHi, I have a form with 9 text fields and a text area. What I want to do is replace the text in the text area depending on how many fields contain text. For example my text boxes are named 1 to 9, if the user enters text in the first five boxes I want the text area to auto fill with 'you have selected boxes 1 to 5' if the user selects all nine it will say 'you have selected 1 to 9', therefore, the user must complete the text boxes in order. I have it working with an onchange event but i have a button on the form to also auto fill the text boxes and it does not work if this is clicked. Any help would be appreciated! Hey I got two text boxes one for start date and second for end date in that i want to fill text boxes according to Quarter of a year, as like if i put 1-4-2012 in first text box then in second text box values should be automatically 30-6-2012. So now tell me please how to do this ??????? Regards rajboy13 Contact me @ = rajboy13@gmail.com Hello, I am trying to search for a string within a table and I am using "createTextRange" but all of the examples I can find use the path "document.body.createtextrange", which uses all of the page data to create the text range. I have tried using the element id but that doesn't seem to work. Any help would be appreciated. Thank you I am building an e-learning lesson in Lectora that will be deployed to a SCROM compatible learning management system. The lesson is converted into HTML before that happens. My table of contents is around 100 pixels wide but some of the page names are longer than that and do not display fully when viewed in a browser. What I am trying to do is this: The page name for this page is very, very long and I can't see it all. Blah blah Would become The page name for this page is very, very long and I can't see it all. Blah blah I've been led to believe there is javascript that will do that. I currently have a table where the current cell (cursor hover) is highlighted along with the top cell in that column and first cell in row. I want to assign the values in these cells to input text fields. The first column cell is identified by Col1Cell[0] where Cell is the top table data cell of the current column. I can access the value of the cell by Col1Cell[0].innerHTML But when I try to assign this value to a text field nothing happens. I have Code: document.getElementById("tableID").fieldID.value = Col1Cell[0].innerHTML Any ideas? Hello All, I'm working on a project which requires a small portion from a large table of information to be displayed on a webpage (sort of like a magnifying glass). The display will be a table of fixed size (m by n cells). Some of the cells will be merged. When the table updates, different sets of cells may be merged. It needs to be coded in HTML5, which I assume includes the use of JavaScript and CSS (The specs of this is rather unclear at the moment, so I'm going to cover all bases). Anyhow, looking through the HTML5 and JavaScript tutorials, I found two ways to solve this problem. One way would be to have a script to parse out the relevant information, and have it output into a table (dynamically generating the HTML required). The second way would be to have the script draw the table on its own in a canvas. User events (such as arrow keys on the keyboard) will change the position of the focus (move the magnifying glass in a cardinal direction). I hit a small snag with the first solution - Is it possible to update the table on the page (including changing the structure of it) without having to refresh? If you could point me to a relevant tutorial or example on the web, I'd greatly appreciate it. Hi, I want to create a javascript: url that will automatically enter a few pieces of information into a registration form provided by a 3rd party. Basically I just want to help users navigate the form a little quicker, and the form doesn't accept query strings. I am running into the fact that when the page is loaded, the cache is flushed. So, I have 2 working javascript: URLs, and I want to combine them into a bookmarklet (and then make it a tinyurl). Can I do that? Thanks, Chris javascript: top.location.href='http://www.google.com/'; javascript: document.f.q.value='This works too'; Does anyone know how I can modify the code below to show a question that has more then one fill in the blank? For example: _____ is an attitude or behavior which leads another to do ________. Thank you. Code: <html> <head> <title>Untitled Document</title> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> <script language="JavaScript"> var question_type=new Array(4) question_type[0]="mult"; question_type[1]="mult"; question_type[2]="blank"; question_type[3]="blank"; var questions=new Array(4) questions[0]="The words used to <u>describe</u> the manifestation of Jesus as Messiah of Israel, Son of God and Savior of the world are ..."; questions[1]="Which of these is not a symbol of the Holy Spirit?"; questions[2]="Human life must be respected and protected absolutely from the moment of ______."; questions[3]="_____ is an attitude or behavior which leads another to do evil."; var answers = new Array(4) answers[0]= "B"; //The Epiphany answers[1]= "C"; //Sunshine [water, fire, anointing] answers[2]="conception"; answers[3]="scandal"; var each_question = new Array(3) each_question[0]="<table width='98%' border='0'>" + "<tr>" + "<td colspan='2'>" + "<font face='Arial, Helvetica, sans-serif'>" + questions[0] + "</font>" + "</td>" + "</tr>" + "<tr>" + "<td width='28%'>" + " " + "</td>" + "<td>" + " " + "</td>" + "</tr>" + "<tr>" + "<td width='28%' align='right'>" + "<input type='radio' name='choice' value='A'>" + "</td>" + "<td>" + "<font face='Arial, Helvetica, sans-serif'>" + "The creed" + "</font>" + "</td>" + "</tr>" + "<tr>" + "<td width='28%' align='right'>" + "<input type='radio' name='choice' value='B'>" + "</td>" + "<td>" + "<font face='Arial, Helvetica, sans-serif'>" + "The Epiphany" + "</font>" + "</td>" + "</tr>" + "<tr>" + "<td width='28%' align='right'>" + "<input type='radio' name='choice' value='C'>" + "</td>" + "<td>" + "<font face='Arial, Helvetica, sans-serif'>" + "The magisterium" + "</font>" + "</tr>" + "<tr>" + "<td width='28%' align='right'>" + "<input type='radio' name='choice' value='D'>" + "</td>" + "<td>" + "<font face='Arial, Helvetica, sans-serif'>" + "The Annunciation" + "</font>" + "</tr>" + "<tr>" + "<td width='28%' align='right'>" + " " + "</td>" + "<td>" + "<img src='line_animation.gif' width='160' height='14' align='right'>" + "</td>" + "</tr>" + "</table>" + "</font>"; each_question[1]="<table width='98%' border='0'>" + "<tr>" + "<td colspan='2'>" + "<font face='Arial, Helvetica, sans-serif'>" + questions[1] + "</font>" + "</td>" + "</tr>" + "<tr>" + "<td width='28%'>" + " " + "</td>" + "<td>" + " " + "</td>" + "</tr>" + "<tr>" + "<td width='28%' align='right'>" + "<input type='radio' name='choice' value='A'>" + "</td>" + "<td>" + "<font face='Arial, Helvetica, sans-serif'>" + "Water" + "</font>" + "</td>" + "</tr>" + "<tr>" + "<td width='28%' align='right'>" + "<input type='radio' name='choice' value='B'>" + "</td>" + "<td>" + "<font face='Arial, Helvetica, sans-serif'>" + "Fire" + "</font>" + "</td>" + "</tr>" + "<tr>" + "<td width='28%' align='right'>" + "<input type='radio' name='choice' value='C'>" + "</td>" + "<td>" + "<font face='Arial, Helvetica, sans-serif'>" + "Sunshine" + "</font>" + "</tr>" + "<tr>" + "<td width='28%' align='right'>" + "<input type='radio' name='choice' value='D'>" + "</td>" + "<td>" + "<font face='Arial, Helvetica, sans-serif'>" + "Anointing" + "</font>" + "</tr>" + "<tr>" + "<td width='28%' align='right'>" + " " + "</td>" + "<td>" + "<img src='line_animation.gif' width='160' height='14' align='right'>" + "</td>" + "</tr>" + "</table>" + "</font>"; each_question[2] = "<table width='98%' border='0'>" + "<tr>" + "<td colspan='2'>" + "<font face='Arial, Helvetica, sans-serif'>" + questions[2] + "</font>" + "</td>" + "</tr>" + "<tr>" + "<td width='28%'>" + " " + "</td>" + "<td>" + " " + "</td>" + "</tr>" + "<tr>" + "<td width='28%' align='right'>" + "<input type='text' name='text_field'>" + "</td>" + "<td>" + "<font face='Arial, Helvetica, sans-serif'>" + "</font>" + "</td>" + "</tr>" + "<tr>" + "<td width='28%' align='right'>" + " " + "</td>" + "<td>" + "<img src='line_animation.gif' width='160' height='14' align='right'>" + "</td>" + "</tr>" + "</table>" + "</font>"; each_question[3] = "<table width='98%' border='0'>" + "<tr>" + "<td colspan='2'>" + "<font face='Arial, Helvetica, sans-serif'>" + questions[3] + "</font>" + "</td>" + "</tr>" + "<tr>" + "<td width='28%'>" + " " + "</td>" + "<td>" + " " + "</td>" + "</tr>" + "<tr>" + "<td width='28%' align='right'>" + "<input type='text' name='text_field'>" + "</td>" + "<td>" + "<font face='Arial, Helvetica, sans-serif'>" + "</font>" + "</td>" + "</tr>" + "<tr>" + "<td width='28%' align='right'>" + " " + "</td>" + "<td>" + "<img src='line_animation.gif' width='160' height='14' align='right'>" + "</td>" + "</tr>" + "</table>" + "</font>"; var currentQuestion=0; var score=0; function writeEachQuestion() { if(currentQuestion==0){ top.bottom_right.document.open(); top.bottom_right.document.write("<center>" + "<h3>" + "<font face='arial, helvetica, verdana'>" + "Go get 'em," + " " + userName + "!" + "<br>" + "</h3>" + "Let's see how well" + "<br>" + "you know your faith!" + "</center>" + "</font>"); top.bottom_left.document.write(each_question[currentQuestion]); } else { top.bottom_left.document.write(each_question[currentQuestion]); top.bottom_right.document.open(); } } function swapper() { top.bottom_left.document.fish_first.src="next2.gif"; } function unswapper() { top.bottom_left.document.fish_first.src="next.gif"; } function checkQuestionType() { if (question_type[currentQuestion-1]=="mult"){ multChecker(); } else if (question_type[currentQuestion-1]=="blank") { textChecker(); } } function multChecker() { var answerValue=answers[currentQuestion-1]; var checkedIndex = -1; for(i=0; i < top.bottom_left.document.quiz_questions.choice.length; i++) { //if a radio button is checked, the variable checkedIndex is set to the value of that index number. if(top.bottom_left.document.quiz_questions.choice[i].checked){ checkedIndex = i; selected_answer = top.bottom_left.document.quiz_questions[checkedIndex].value; } } if (selected_answer==answerValue) { score++; //The angelTableCorrect() function runs(see below). angelTableCorrect(); //An alert pops up if nothing's checked, with a string telling the user to guess next time. } else if (checkedIndex==-1){ alert("Next time," + " " + userName + "," + " " + "take a guess!"); //Because I'm heartless, the user isn't given a second chance. If not guess was made, angelTableWrong() executes (see below). angelTableWrong(); } else { angelTableWrong(); } } function textChecker() { var answerValue=answers[currentQuestion-1]; //theWord represents the user's input. var theWord = top.bottom_left.document.quiz_questions.text_field.value; theWordLower=theWord.toLowerCase(); if(theWordLower==answerValue) { score++; angelTableCorrect(); } else if (theWord!=answerValue) { angelTableWrong(); } } function angelTableCorrect () { top.top_right.document.open(); top.top_right.document.write("<table align='left'>" + "<tr>" + "<td align='center'>" + "<font face='Arial'>" + "Right," + " " + userName + "!" + "<br>" + "You're" + " " + score + " " + "out of" + " " + currentQuestion + "</td>" + "<td>" + "<img src='angel_correct.gif'>" + "</td>" + "</tr>" + "</table>"); } function angelTableWrong () { top.top_right.document.open(); top.top_right.document.write("<table align='left'>" + "<tr>" + "<td align='center'>" + "<font face='Arial'>" + "Wrong," + " " + userName + "." + "<br>" + "You're" + " " + score + " " + "out of" + " " + currentQuestion + "</td>" + "<td>" + "<img src='angel_wrong.gif'>" + "</td>" + "</tr>" + "</table>"); } function writeBeginning() { top.bottom_left.document.clear(); top.bottom_left.document.open(); top.bottom_left.document.write("<html>" + "<head>" + "</head>" + "<body>" + "<form name='quiz_questions'>"); } //This function writes the concluding part of each quiz question table in the bottom_left frame, except for the last one. //The last one's Next button has to call a different function, so I wrote the next function to do that. function writeEnding(){ top.bottom_left.document.write("<img name='fish_first' src='next.gif' align='right' onMouseOver='top.top_left.swapper();' onMouseOut='top.top_left.unswapper();' onMouseUp='top.top_left.onNext();'>" + "</form>" + "</body>" + "</html>") } //This function writes the concluding part of the last question, which has a next button that calls a //different function. function writeEndingLast(){ top.bottom_left.document.write("<img name='fish_first' src='next.gif' align='right' onMouseOver='top.top_left.swapper();' onMouseOut='top.top_left.unswapper();' onMouseUp='top.top_left.writeMailTable();'>" + "</form>" + "</body>" + "</html>") } function writeMailTable(){ top.top_right.document.open(); top.top_right.document.write("<font face='arial, verdana, helvetica'>" + "<center>" + "Thank you for" + "<br>" + "taking the quiz," + " " + userName + "!" + "<br><br>" + "</center>"); top.bottom_right.document.open(); top.bottom_right.document.write("<font face='arial, verdana, helvetica'>" + "<center>" + "If you don't have questions" + "<br>" + "you'd like to have answered," + " " + "<a href='http://www.archden.org' target='_blank')>" + "return to the" + "<br>" + "Archdiocese of Denver home page." + "</a>" + "</center>"); top.bottom_left.document.open(); top.bottom_left.document.write("<font face='arial, verdana, helvetica'>" + "Do you have questions about this quiz," + " " + userName + "?" + " " + "<img src='angel_final.gif' align='right'>" + "Post them in" + " " + "<a href='http://www.archden.org/ubb' target='_blank')>" + "The Upper Room," + "</a>" + " " + "the online community of the Archdiocese of Denver, in the 'What Does the Church Teach About ...?' forum!"); } function onNext() { //Write a table to the_questions.htm that includes a variable for the new question. if(currentQuestion==3) { currentQuestion++; textChecker(); doTheMath(); top.bottom_left.document.open(); top.bottom_left.document.write("<font face='arial, verdana, helvetica'>" + "<center>" + "You got" + " " + "<b>" + finalPercent + "%" + "</b>" + " " + "of the questions right," + " " + userName + "!" + "<br>" + "Click on the 'Next' fish" + "<br>" + "one more time to find out" + "<br>" + "how to get answers for those questions you missed." + "</center>" + "</font>"); writeEndingLast(); } else { currentQuestion++; checkQuestionType(); writeBeginning(); writeEachQuestion(); writeEnding(); } } //The doTheMath function divides the score by 20, and that multiplies that value by 100 to come up //with a final percentage value. That is used in the string written at the end (in the above onNext function). function doTheMath(){ thePercent=score/4; finalPercent=thePercent*100; } </script> </head> <body bgcolor="#FFFFFF" onLoad="writeBeginning(); writeEachQuestion(); writeEnding();"> <img src="title.gif" width="371" height="109"> <script language="JavaScript"> </script> </body> </html> Ok. I'm going to start by saying I'm a complete novice. I am having a hell of time finding specific codes for the things I need. I'm pretty impressive I've gotten this far. So I am trying to make a portfolio website, for myself, which has thumbnails on the left(which I'll crop in photoshop because it is easier for me than having to do any coding) which will make the main image on the right change. At the same time, I want it to change the text below to correspond to the current image. Now I have the images swapping alright, except that the thumbnails that have the onClick function in them won't sit inside the table I have inside the table. I don't understand why that happens. I can work around this, and just get rid of that table. Another problem is that even though I defined the collumns as each being 20%, they are not all the same size. I am using percentages so that the site will function regardless of screen resolution. Anyway, here is my current code. Ignore the image names, I'm just using what random images I have at hand while I test things out. Code: <html> <head> <script type="text/javascript"> function swap(image) { document.getElementById("main").src = image.href; } </script> </head> <body> <table width="80%" align="center"> <tr><td colspan="5">I'll put a header image here.</td> </tr> <tr> <td width="20%"><center>Print</center></td> <td width="20%"><center>Motion</center></td> <td width="20%"><center>Photo</center></td> <td width="20%"><center>Misc</center></td> <td width="20%"><center>Resume</center></td> </tr> <tr> <td colspan="2"><table align="left"> <td colspan="100%">Catagory 1 </td> <tr> <a href="mario.jpg" onClick="swap(this); return false;"><img src="../Jpg/sluticon.jpg"></a> <a href="../Jpg/cattits.jpg" onClick="swap(this); return false;"><img src="../Jpg/sluticon.jpg"></a> <a href="bowie.jpg" onClick="swap(this); return false;"><img src="../Jpg/sluticon.jpg"></a> </tr> <td colspan="100%">Catagory 2 </td> <tr> <td><img src="../Jpg/sluticon.jpg" /></td> <td><img src="../Jpg/sluticon.jpg" /></td> </tr> </table></td> <td colspan="3"> <img id="main" src="bowie.jpg" width="400"> </td> </tr><td colspan="5"> <p>Description goes here</p></td> <tr> </tr> </table> </body> </html> Hi, I have a php script that displays database data in a web table. I also have a javascript code which is supposed to compare the value entered in a web form to that hard coded in the script and change the color to green if its below, amber if its equal and red if its greater than. Below is my javascript code: Code: <script type="text/javascript"> function hallo(){ var value1=200 var inputVal = window.document.getElementById("one").value; //alert(negNum); if(inputVal > value1){ window.document.getElementById("color").style.color="red"; } else if(inputVal < value1) { window.document.getElementById("color").style.color="green"; } else if(inputVal == value1) { window.document.getElementById("color").style.color="#FF7E00"; } } </script> And below is my php script that displays the data in a web table. Code: <body> <form> Value1: <input type="text" name="one" id="one" ><br/> Value2: <input type="text" name="two" id="two" value="" onClick="hallo();"> <br/> Value3: <input type="text" name="three" id="$cell" value="test data"> </form> <?php require_once("database.php"); $CustID=$_POST['CustomerID']; $query="SELECT c.*,r.Meter_No,r.January,r.February,r.March,r.April,r.May,r.June FROM customer AS c,readings AS r WHERE c.CustomerID=r.CustomerID AND c.CustomerID='".$CustID."'"; $result=mysql_query($query); $num=mysql_numrows($result); mysql_close(); ?> <table border="0" cellspacing="2" cellpadding="2"> <tr> <th><font face="Arial, Helvetica, sans-serif">CustomerID</font></th> <th><font face="Arial, Helvetica, sans-serif">Title</font></th> <th><font face="Arial, Helvetica, sans-serif">First_Name</font></th> <th><font face="Arial, Helvetica, sans-serif">Last_Name</font></th> <th><font face="Arial, Helvetica, sans-serif">Meter_No</font></th> <th><font face="Arial, Helvetica, sans-serif">January</font></th> <th><font face="Arial, Helvetica, sans-serif">February</font></th> <th><font face="Arial, Helvetica, sans-serif">March</font></th> <th><font face="Arial, Helvetica, sans-serif">April</font></th> <th><font face="Arial, Helvetica, sans-serif">May</font></th> <th><font face="Arial, Helvetica, sans-serif">June</font></th> </tr> <?php $i=0; while ($i < $num) { $f1=mysql_result($result,$i,"CustomerID"); $f2=mysql_result($result,$i,"Title"); $f3=mysql_result($result,$i,"First_Name"); $f4=mysql_result($result,$i,"Last_Name"); $f5=mysql_result($result,$i,"Meter_No"); $f6=mysql_result($result,$i,"January"); $f7=mysql_result($result,$i,"February"); $f8=mysql_result($result,$i,"March"); $f9=mysql_result($result,$i,"April"); $f10=mysql_result($result,$i,"May"); $f11=mysql_result($result,$i,"June"); ?> <tr> <td><font face="Arial, Helvetica, sans-serif"><?php echo $f1; ?></font></td> <td><font face="Arial, Helvetica, sans-serif"><?php echo $f2; ?></font></td> <td><font face="Arial, Helvetica, sans-serif"><?php echo $f3; ?></font></td> <td><font face="Arial, Helvetica, sans-serif"><?php echo $f4; ?></font></td> <td><font face="Arial, Helvetica, sans-serif"><?php echo $f5; ?></font></td> <td id="color"><font face="Arial, Helvetica, sans-serif"><?php echo $f6; ?></font></td> <td id="color"><font face="Arial, Helvetica, sans-serif"><?php echo $f7; ?></font></td> <td id="color"><font face="Arial, Helvetica, sans-serif"><?php echo $f8; ?></font></td> <td id="color"><font face="Arial, Helvetica, sans-serif"><?php echo $f9; ?></font></td> <td id="color"><font face="Arial, Helvetica, sans-serif"><?php echo $f10; ?></font></td> <td id="color"><font face="Arial, Helvetica, sans-serif"><?php echo $f11; ?></font></td> </tr> <?php $i++; } ?> </body> As you can see from my javascript, i am getting the elements by id (getElementById("color")). Currently, only the first <td> with id='color' is changing when the value is entered. How do I make the text in other table cells with id='color' change color when the comparison value is entered? Hi All, Firstly - apologies to anyone who has read this in the PHP forum - I was not sure if I needed to post it there or here! I have a PHP form which has an select field (i.e. drop-options) where the different options are populated from a MySQL database as follows: Code: <select size="1" id="category" name="category"> <option value="">Select from drop-list:</option> <?php $sql = "SELECT * FROM `DB1` ORDER BY list_category ASC"; $sql_result = mysql_query ($sql, $connection ) or die ('request "Could not execute SQL query" '.$sql); while ($row = mysql_fetch_assoc($sql_result)) { if ($row["list_category"]<>'') { echo '<option value="'; echo nl2br(stripslashes(utf8_decode($row["list_category"]))).'">'; echo nl2br(stripslashes(utf8_decode($row["list_category"]))).'</option>'; }; }; ?> </select> Now, the issue I have is that I also have another input field (possibly hidden) in this form which is called 'category_id', and what I want it to do is to automatically populate when the user selects the relevant 'category' from the select field above. EDIT: Sorry - should also have told you that the 'category_id' is associated with the 'category' field above in the same database, DB1. Can anyone recommend any way of doing this? Thanks, Neil Hello, I would like to program a custom link for my visitors, which will fill a payment form on an external page automatically. As an ultimate goal, I would like to press a link, which will send necessary information to this external page, fill it in the right forms, and press "submit" button there. If there is no way to do all these tasks in only one link, then just filling the forms would be great. I've tried something like: Code: <a href="https://load.payoneer.com/LoadToPage.aspx" style="cursor:pointer;" onclick="document.getElementById('emailAddress').value='somemail@mail.com';"> Pay to "somemail@mail.com" </a> Unfortunately this approach didn't work for me. The other problem is that I need to fill more fields on this external page (https://load.payoneer.com/LoadToPage.aspx), like payment amount, email address, reason for payment, etc. I've found out that I can send Email as a parameter in an URL: https://load.payoneer.com/LoadToPage...email@mail.com (will work only with a valid email, as it goes through a validation on their page). Is there any way to get the names of other parameters (like "email", "payment", etc.)? Please let me know if there are any possible ways to program such a task. I believe that JavaScript should be used here, but if not, please advise me on different ways of programming such a solution. Thank you in advance, Anatoliy. Hi everyone, I have a very simple fill-in-the-blank quiz that I would like to add a randomizer to. Right now, the quiz has 3 questions that are asked one at a time, in order. I want to increase this to 100 possible questions (that part I can do), but I want the script to randomly choose 10 of them to ask. Then once the person has taken the quiz, they would be able to try again with 10 new questions. The script is live he http://www.elearnfrenchlanguage.com/...verb-quiz.html I have a quiz with a randomizing script, but it's for multiple choice questions, and I don't know how to adapt it so that it works with my script. Here is the working quiz: http://french.about.com/library/week...frenchquiz.htm And here is the randomizing script: http://french.about.com/library/weekly/longquiz.js I'd be so grateful for any help. hey guys so I need a way to auto select certain radio buttons and then submit the page. here is the form: https://spreadsheets.google.com/view...I0NGNiMDQ&ifq0 for questions 1 and 2 i would like the answer submitted to be "no" and for all others "no" ive been trying to do this with the little coding knowledge i have for 2 hours with no success. thanks in advance guys/gals! I am trying to create a sample form using javascript. The form has a series of option and a submit button followed by a textarea. When the user clicks the submit button the textarea should be filled with the selected information from the form. I cannot get the textarea to fill with text. I believe the problem lies in the fact that when I submit the form the page refreshes, but I am not sure if that's the case. With this version of the code I actually can't get passed the Room Type. It always says No Room Type selected. Here is my code: Code: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Form Sample</title> <link href="default.css" rel="stylesheet" type="text/css" /> <script language="javascript" type="text/javascript"> <!-- function checkForm(myForm) { regexp = /^\d\d\/\d\d\/\d{4}$/; numReg = /^\d*$/; str = ""; for (i = 0; i < 5; i++) { if (!myForm.roomType[i].checked) { alert("No Room Type Selected!\nPlease Select Room Type!"); return; } str += "Room Type: "; str += myForm.roomType[i].value + "\n" } str += "Activities: \n"; for (i = 0; i < 4; i++) { if (!myForm.activity[i].checked) { alert("No Activities Selected!\n Please Select Activities!"); return; } str += "\t" + myForm.activity[i].value + "\n"; } if (myForm.hotels.selectedIndex+1 < 1) { alert("No Hotel Selected!\n Please Select a Hotel!"); return; } else { str += "Hotel: "; for (var i = 0; i < myForm.hotels.length; i++) { if (myForm.hotels[i].selected) { str += myForm.hotels[i].value + "\n"; } } } if ( myForm.confname.value == "" || myForm.confname.value == null) { alert("No Conference Name Entered! Please Enter a Conference Name!"); return; } else { str += "Conference Name: " + myForm.confname.value + "\n"; } if (!regexp.test(myForm.date.value)) { alert("Invalid Date"); return; } else { str += "Date: " + myForm.date.value + "\n"; } if (!numReg.test(myForm.zip.value)) { alert("Invalid Zip Code"); return; } else { str += "Zip Code: " + myForm.zip,value + "\n"; } myForm.info.value = str; } </script> </head> <body> <h1>Host your Conference!</h1> <form name="conference" method="post" onsubmit="checkForm(this); return false;" action="#"> <div style="font-size:20px; font-weight:bold; color:#FF0000;"> Select Room Type Type:<br /> </div> <div style="color:#FFCC00; font-weight:bold;"> <input type="radio" name="roomType" value="Large Meeting Room" />Large Meeting Room<br /> <input type="radio" name="roomType" value="Small Meeting Room" />Small Meeting Room<br /> <input type="radio" name="roomType" value="Video Conference Room" />Video Conference Room<br /> <input type="radio" name="roomType" value="Theater Lecture Hall" />Theatre Lecture Hall<br /> <input type="radio" name="roomType" value="Convention Center" />Convention Center<br /> </div> <br /> <div style="font-size:20px; font-weight:bold; color:#FF0000;"> Select Activities:<br /> </div> <div style="color:#FFCC00; font-weight:bold;"> <input type="checkbox" name="activity" value="Swimming" />Swimming<br /> <input type="checkbox" name="activity" value="lecture" />Lecture<br /> <input type="checkbox" name="activity" value="Golf" />Golf (Gentlemen Only Ladies Forbidden)<br /> <input type="checkbox" name="activity" value="Tour of the Facilities" />Tour of the Facilities<br /> </div> <br /> <div style="font-size:20px; font-weight:bold; color:#FF0000;"> Select Hotel:<br /> </div> <div style="color:#FFCC00; font-weight:bold;"> <select name="hotels" size="4"> <option name="marriott" value="Marriot">Marriott</option> <option name="doubleTree" value="Double Tree">Double Tree</option> <option name="comfortSuites" value="Comfort Suites">Comfort Suites</option> <option name="sheraton" value="Sheraton">Sheraton</option> </select> </div> <br /> <div style="font-size:20px; font-weight:bold; color:#FF0000;"> Confence Name: <input type="text" name="confname" size="60" /> </div> <br /> <div style="font-size:20px; font-weight:bold; color:#FF0000;"> Zip Code: <input type="text" name="zip" size="12" value="Enter Zip Code"/> </div> <br /> <div style="font-size:20px; font-weight:bold; color:#FF0000;"> Date: <input type="text" name="date" size="10" value="mm/dd/yyyy" /> </div> <br /> <div> <input name="confSubmit" type="submit" style="background:#CCCCCC !important; color:#333333 !important;" value="It's Conference Time!" /> <input name="confReset" type="reset" style="background:#CCCCCC !important; color:#333333 !important;" value="Reset Form" onclick="javascript:return checkForm(this.form);" /> </div> <br /> <div style="font-size:20px; font-weight:bold; color:#FF0000;"> Print This: <textarea type="text" name="info" size="1200" style="vertical-align:text-top; height:175px; width:325px;"> </textarea> </div> </form> </body> </html> And here is a link to the page: Form Sample Hello everyone! I have a select (combo box) element that gets filled with items when selected item changed in another one (master combo box). It works in Chrome, FireFox but not in IE (all latest browser versions). How do I populate the items in the child combo box: - ajax call of a PHP script - that returns items for the combo box: echo '<option value="' . $id . '">' . $name . '</option>'; - setting innerHTML attribute of the child combo box to a value that gets returned by the ajax call: document.forms['parametersForm'].elements['stationId'].innerHTML = html; Do I need to return JSON object (or XML) by the PHP script and programically add items (in JavaScript) in the ajax callback or is there an alternative? Obviously building DOM with echoing PHP result doesn't work well in IE. Thanks for your future help! Regards What I am looking to do is auto-populate a number of forms based on what a user chooses as a starting date. For example: If a user enters 12/12/2009 I want the other fields to automatically populate with the next 2 weeks (12/13/2009, 12/14/2009, 12/15/2009 etc.) Anyone have a useful script that I can use given that these fields are formatted as dates? The idea is to save time by only having to fill in the first date in the timesheet. hi all, i have the following form: Code: <form id="form1" name="form1" method="post" action="results.php"> <table width="680" border="0" align="center" cellpadding="5" cellspacing="5"> <tr> <td colspan="5"><strong>How much would you pay for X? </strong></td> </tr> <tr> <td width="100"><div align="center">$1</div></td> <td width="125"><div align="center"><span class="style13"> <input name="p1" type="radio" value="yes" /> </span></div></td> <td width="125"><div align="center">Yes</div></td> <td width="125"><div align="center"><span class="style13"> <input name="p1" type="radio" value="no" /> </span></div></td> <td width="125"><div align="center">No</div></td> </tr> <tr> <td><div align="center">$2</div></td> <td><div align="center"><span class="style13"> <input name="p2" type="radio" value="yes" /> </span></div></td> <td><div align="center">Yes</div></td> <td><div align="center"><span class="style13"> <input name="p2" type="radio" value="no" /> </span></div></td> <td><div align="center">No</div></td> </tr> <tr> <td><div align="center">$3</div></td> <td><div align="center"><span class="style13"> <input name="p3" type="radio" value="yes" /> </span></div></td> <td><div align="center">Yes</div></td> <td><div align="center"><span class="style13"> <input name="p3" type="radio" value="no" /> </span></div></td> <td><div align="center">No</div></td> </tr> <tr> <td><div align="center">$4</div></td> <td><div align="center"><span class="style13"> <input name="p4" type="radio" value="yes" /> </span></div></td> <td><div align="center">Yes</div></td> <td><div align="center"><span class="style13"> <input name="p4" type="radio" value="no" /> </span></div></td> <td><div align="center">No</div></td> </tr> <tr> <td><div align="center">$5</div></td> <td><div align="center"><span class="style13"> <input name="p5" type="radio" value="yes" /> </span></div></td> <td><div align="center">Yes</div></td> <td><div align="center"><span class="style13"> <input name="p5" type="radio" value="no" /> </span></div></td> <td><div align="center">No</div></td> </tr> </table> </form> sorry for the lengthy code because of the table. what i want to do is, if the user clicks No for for any input (p1 through p5), then I want all the other inputs below to automatically fill in with No as well. Similarly, if the user clicks Yes for any answer, I want all the inputs above that answer to fill in with Yes. i think those are the only two rules i would have to program to ensure that the user provides consistent answers. i'd also like to know how, if input 1 is a set of radio buttons, and one of them is selected, you can use that result to fill in input 2 in a certain way. thanks I was wondering if someone could help me? In my code below what if answers in question 2 were allowed to be in any order? Like: hips,body,knees or knees,hips,body and so on. How should I modify my code? Anyone please???? 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" xml:lang="en" lang="en"> <head> <title>Quiz</title> <meta http-equiv="Content-Type" content="text/html;charset=utf-8" /> <script type="text/javascript"> var answer_list = [ ['False'], ['body,hips,knees'] // Note: No comma after final entry ]; var response = []; function getCheckedValue(radioObj) { if(!radioObj) return ""; var radioLength = radioObj.length; if(radioLength == undefined) if(radioObj.checked) return radioObj.value; else return ""; for(var i = 0; i < radioLength; i++) { if(radioObj[i].checked) { return radioObj[i].value; } } return ""; } function setAnswer(question, answer) { response[question] = answer; } function CheckAnswers() { var correct = 0; var resp, answ; for (var i = 0; i < answer_list.length; i++) { resp = response[i].toString(); resp = resp.toLowerCase(); answ = answer_list[i].toString(); answ = answ.toLowerCase(); //################################################################################################# if (resp == answ) { correct++; if(i==0){ document.forms[0].a1c.style.backgroundImage="url('correct.gif')"; document.forms[0].a1c.value = ""; } else{ document.forms[0].a1d.style.backgroundImage="url('correct.gif')"; document.forms[0].a1d.value = ""; } } else{ if(i==0){ document.forms[0].a1c.style.backgroundImage = "url('incorrect.gif')"; document.forms[0].a1c.value = " ANS: False. Position the head snugly against the top bar of the frame and then bring the foot board to the infant's feet."; } else{ document.forms[0].a1d.style.backgroundImage = "url('incorrect.gif')"; document.forms[0].a1d.value = " ANS: " + answ; } //################################################################################################### } } document.writeln("You got " + correct + " of " + answer_list.length + " questions correct!"); } </script> </head> <body> <form action="" method="post"> <div> <b>1. When measuring height/length of a child who cannot securely stand, place the infant such that his or her feet are flat against the foot board.</b><br /> <label><input type="radio" name="question0" value="True" />True</label> <label><input type="radio" name="question0" value="False" />False</label> <br /> <textarea rows="2" cols="85" name="a1c" style="background-repeat:no-repeat"></textarea> <br /> <b>2. When taking a supine length measurement, straighten the infant's <input type="text" name="question1_a" size="10" />, <input type="text" name="question1_b" size="10" />, and <input type="text" name="question1_c" size="10" />.</b> <br /> <textarea rows="2" cols="85" name="a1d" style="background-repeat:no-repeat"></textarea> <br /> <input type="button" name="check" value="Check Answers" onclick="setAnswer(0,getCheckedValue(document.forms[0].question0));setAnswer(1,[document.forms[0].question1_a.value,document.forms[0].question1_b.value,document.forms[0].question1_c.value]);CheckAnswers();" /> </div> </form> </body> </html> I have an html page "PageA" which contains a "link" to another html page "PageB". The link is handled as a form submit because PageA sends some variables which it wants "processed". However, PageB is NOT a CGI script but simply another html page which happens to contain a form. This form handles the desired processing. I would appreciate some help getting some javascript in place, in PageA, in order to automatically fill in a form field in PageB with a variable supplied by PageA. The complications here a 1) PageB is not a CGI script and so sending variables via a query string does not work. (The variables never get read by PageB.) 2) PageB is maintained by another organisation so I cannot modify it. (Actually I could, as I have a local copy, but I would have to redo after every new release and so this is not acceptable.) It therefore needs to be treated as an independent page. 3) The variable is quite a lengthy one, it is extracted from a database and changes depending on how PageA was called, so I want to do this for repeated instances and cutting and pasting to a new page on each occasion is not attractive. 4) I would like to open PageB in a separate window or tab as I want to be able to reference both pages at once. (This is not essential to the key problem but may influence the solution. A solution which depended on the window being the same I would not regard as satisfactory.) The relationship between the documents is probably most accurately described as "PageB is a section of PageA". It is providing some additional information on aspects of what is in PageA. The output from submission of PageB can be quite lengthy. The actual form field in PageB I want to fill in is a textarea element and I know its name (call it name1) and also the name of the form (call it form1). But I don't think the field type should be important. I simply want to update its value (presumably after a page load?). Is this possible without editing PageB? I would appreciate some guidance if not a proven solution. Perhaps I have overlooked something but I can't find a working solution to this particular problem and my experiments to date don't work. Thanks |