JavaScript - Harvest Data -> Return -> Display
How would I use JavaScript to pull numbers (information such as Clan Members # Count) from this page (http://services.runescape.com/m=clan...me=Void+Nation), and then write them to a page on my site?
Similar TutorialsHi All, I have a button in my html form that will process some functions when user clicks on the button. The problem is after processing the functions, the result is not displayed in the form where I want it to be displayed. I want to ask whether we can create table in the function and display the result in the table row/column but in the same form. Is this possible to be done? And how to do this? In this form cpiM, the input button will call function showIndex. Code: <tr> <td><input type="button" value="Enter" onclick="showIndex(document.cpiM.currFrom.options.selectedIndex, document.cpiM.currTo.options.selectedIndex, document.cpiM.base.options.selectedIndex, document.cpiM.country.options.selectedIndex)"> </td> <td><input type="button" onclick="frmResetM()" value="Reset form" /> </td> </tr> In this function, I want to display the result of calcIndex right below the button Enter in the form cpiM. Code: function showIndex(frm, to, base, country) { for (i=frm; i<=to; i++) { document.write(calcIndex(i, base, country)); document.write("<br/>"); } } I don't understand the logic of Break, Return False, Return True. It was never really covered in our college class, and I see everyone using it. I got an A in the class, if that 'proves' that I really tried to apply myself. NOTE: I understand what the function is doing. I just don't understand WHEN to use break, return false or return true if the the translator can determine the conditional statements. PHP Code: function submitForm(){ var ageSelected = false; for (var i=0; i<5; ++1){ if (document.forms[0].ageGroup[i].checked == true) { ageSelected = true; break; } } if (ageSelected == false){ window.alert("You must select your age group"); return false; } else return false; } if the the translator can determine the conditional statements, why not write it like this: PHP Code: function submitForm(){ var ageSelected = false; for (var i=0; i<5; ++1){ if (document.forms[0].ageGroup[i].checked == true) { ageSelected = true; break; // what's the point for the 'break'? Won't the rest of the code be ignored since it passed the first condition? } } if (ageSelected == false){ window.alert("You must select your age group"); return false; } // why not leave the last else out? is it just a 'safety' catch, in case something other than true or false is inputted? else return false; // what's the point? } Questions: Why use return true, if the translator knows it's ture? Why use "return false" if the translator knows it's false and the alert window has already gone up? why not use "break" to stop the code? Why use the "return false" at the end "else" statement? Hi room, Hey, I opened up the source code for this page in google chrome and since i'm learning javascript, i wanted see if i could "read" it and figure out what was going on. I'm am having the hardest time understanding "return false" and "return true". Could someone step me through this via interpreting this code (in bold typeface): Code: var DefaultValue = 'Search'; function clearSearch() { if (document.searchForm.q.value == DefaultValue) { document.searchForm.q.value = ''; } } function validateSearchHeader() { if ( document.searchForm.q.value == '' || document.searchForm.q.value.toLocaleLowerCase() == DefaultValue.toLocaleLowerCase() ) { alert('Please enter at least one keyword in the Search box.'); document.searchForm.q.focus(); return false; } return true; } Thanks! I am working on my form. Once user put data in the form, I want to save it as cookie and display it in another page as form processor. In my html file therefore, I have Code: <form id="frmBuyer" method="get" action="FormProcessor_Cookies.html" enctype="application/x-www-form-urlencoded" onsubmit="return validate();" onreset="location.reload();"> which is basically validate all the data and once it meets the requirement, it goes to FormProcessor_Cookies.html. So, i put a function in my js file to get all the data as cookie as following. Code: function createCookie(){ document.cookie = first + "=" + encodeURIComponent(document.forms[0].FirstName.value); document.cookie = last + "=" + encodeURIComponent(document.forms[0].LastName.value); document.cookie = phone1 + "=" + encodeURIComponent(document.forms[0].PhoneA.value); document.cookie = phone2 + "=" + encodeURIComponent(document.forms[0].PhoneB.value); document.cookie = phone3 + "=" + encodeURIComponent(document.forms[0].PhoneC.value); document.cookie = email + "=" + encodeURIComponent(document.forms[0].Email.value); location.href = "cookie.html"; } and I called this function after it validates. Code: function validate(){ var blnError = false; var zip = document.getElementById("Zip").value; var textBoxthree = document.getElementById("third"); var textLengththree = textBoxthree.value.length; var textBoxtwo = document.getElementById("second"); var textLengthtwo = textBoxtwo.value.length; var textBoxone = document.getElementById("first"); var textLengthone = textBoxone.value.length; var patternZip = new RegExp("^([0-9]){5}(([ ]|[-])?([0-9]){4})?$"); if (document.forms[0].Zip.value == ""||!patternZip.test(document.forms[0].Zip.value)){ document.getElementById('E_Zip').style.display="inline"; document.forms[0].Zip.focus(); document.forms[0].Zip.style.backgroundColor="lemonchiffon" blnError = true; } else{ document.getElementById('E_Zip').style.display="none"; document.forms[0].Zip.style.backgroundColor="white" } var patternCity = new RegExp("^(?:[a-zA-Z]+(?:[.'\-,])?\s?)+$"); if (document.forms[0].City.value == ""||!patternCity.test(document.forms[0].City.value)){ document.getElementById('E_City').style.display="inline"; document.forms[0].City.focus(); document.forms[0].City.style.backgroundColor="lemonchiffon" blnError = true; } else{ document.getElementById('E_City').style.display="none"; document.forms[0].City.style.backgroundColor="white" } var patternAddress = new RegExp("^[a-zA-Z]+.*|.*[a-zA-Z]+|.*[a-zA-Z]+.*$"); if (document.forms[0].Address1.value == ""||!patternAddress.test(document.forms[0].Address1.value)){ document.getElementById('E_Address1').style.display="inline"; document.forms[0].Address1.focus(); document.forms[0].Address1.style.backgroundColor="lemonchiffon" blnError = true; } else{ document.getElementById('E_Address1').style.display="none"; document.forms[0].Address1.style.backgroundColor="white" } var patternConfirm = new RegExp("^[_a-zA-Z0-9\\-]+(\.[_a-zA-Z0-9\\-]+)*@[a-zA-Z0-9\\-]+(\.[a-aZ-Z0-9\\-]+)*(\.[a-z]{2,3})$"); if (document.forms[0].ConfirmEmail.value == "" ||!patternConfirm.test(document.forms[0].ConfirmEmail.value) ||document.forms[0].ConfirmEmail.value != document.forms[0].Email.value){ document.getElementById('E_ConfirmEmail').style.display="inline"; document.forms[0].ConfirmEmail.focus(); document.forms[0].ConfirmEmail.style.backgroundColor="lemonchiffon" blnError = true; } else{ document.getElementById('E_ConfirmEmail').style.display="none"; document.forms[0].ConfirmEmail.style.backgroundColor="white" } var patternEmail = new RegExp("^[_a-zA-Z0-9\\-]+(\.[_a-zA-Z0-9\\-]+)*@[a-zA-Z0-9\\-]+(\.[a-aZ-Z0-9\\-]+)*(\.[a-z]{2,3})$"); if (document.forms[0].Email.value == ""||!patternEmail.test(document.forms[0].Email.value)){ document.getElementById('E_Email').style.display="inline"; document.forms[0].Email.focus(); document.forms[0].Email.style.backgroundColor="lemonchiffon" blnError = true; } else{ document.getElementById('E_Email').style.display="none"; document.forms[0].Email.style.backgroundColor="white" } var patternPhoneA = new RegExp("^\\d{3}$"); var patternPhoneB = new RegExp("^\\d{3}$"); var patternPhoneC = new RegExp("^\\d{4}$"); if(patternPhoneC.test(document.forms[0].PhoneC.value) &&patternPhoneB.test(document.forms[0].PhoneB.value) &&patternPhoneA.test(document.forms[0].PhoneA.value)){ document.getElementById('E_Phone').style.display="none"; } if(patternPhoneC.test(document.forms[0].PhoneC.value)){ document.forms[0].PhoneC.style.backgroundColor="white"} if(patternPhoneB.test(document.forms[0].PhoneB.value)){ document.forms[0].PhoneB.style.backgroundColor="white"} if(patternPhoneA.test(document.forms[0].PhoneA.value)){ document.forms[0].PhoneA.style.backgroundColor="white"} if (!patternPhoneC.test(document.forms[0].PhoneC.value)){ document.getElementById('E_Phone').style.display="inline"; document.forms[0].PhoneC.focus(); document.forms[0].PhoneC.style.backgroundColor="lemonchiffon" } if (!patternPhoneB.test(document.forms[0].PhoneB.value)){ document.getElementById('E_Phone').style.display="inline"; document.forms[0].PhoneB.focus(); document.forms[0].PhoneB.style.backgroundColor="lemonchiffon" } if (!patternPhoneA.test(document.forms[0].PhoneA.value)){ document.getElementById('E_Phone').style.display="inline"; document.forms[0].PhoneA.focus(); document.forms[0].PhoneA.style.backgroundColor="lemonchiffon" } var patternLast = new RegExp("^[a-zA-Z]+.*|.*[a-zA-Z]+|.*[a-zA-Z]+.*$"); if (document.forms[0].LastName.value == ""||!patternLast.test(document.forms[0].LastName.value)){ document.getElementById('E_LastName').style.display="inline"; document.forms[0].LastName.style.backgroundColor="lemonchiffon" blnError = true; } else{ document.getElementById('E_LastName').style.display="none"; document.forms[0].LastName.style.backgroundColor="white" } var patternFirst = new RegExp("^[a-zA-Z]+.*|.*[a-zA-Z]+|.*[a-zA-Z]+.*$"); if (document.forms[0].FirstName.value == ""||!patternFirst.test(document.forms[0].FirstName.value)){ document.getElementById('E_FirstName').style.display="inline"; document.forms[0].FirstName.style.backgroundColor="lemonchiffon" blnError = true; } else{ document.getElementById('E_FirstName').style.display="none"; document.forms[0].FirstName.style.backgroundColor="white" } if (blnError == true){ document.getElementById('E_Alert').style.display="inline"; return false; } else { document.getElementById('E_Alert').style.display="none"; createCookie(); return true; } } Lastly, I tried to display all the cookies in my "FormProcessor_Cookies.html" page 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 name="author" content="" /> <meta name="description" content="Home" /> <meta name="keywords" content="Client Side Programming, JavaScript, CSS" /> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> <meta http-equiv="Content-Language" content="en-us" /> <link rel="stylesheet" href="javascript.css"/> <script type="text/javascript" src="shopping.js"></script> <title>Homepage::Seunghun Jun</title> </head> <body> <div id="container"> <!-- Begin web page --> <div id="header"><!-- Header and Navigation --> <!-- Page Heading --><!-- Navigation --> <script type="text/javascript"> displayHeader(); </script> <br/><br/><br/><br/> </div> <div id="content"> <!-- Main Content --><div id="submited"> <script type="text/javascript"> /* <![CDATA[ */ document.write(documetn.cookie;); /* ]]> */ </script></div> </div><br/><br/><br/><br/> <div id="footer"> <!-- Footer --> <!-- Begin Footer Div--> <script type="text/javascript">displayFooter();</script> <!-- End Footer Div --> </div> <!--End web page --> </div> </body> </html> And its not showing any messages...I know I am asking to much...but could any expert can help me what is wrong and how I can fix this? Hello i have done this so far, i dont really know how to assign the else statement in queris, and i am not sure for js as well. Those are the files and what i have done. any idea? thanks main page: Code: <%@LANGUAGE="VBSCRIPT" CODEPAGE="65001"%> <!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> <script type="text/javascript"> function showUser() { var t=document.getElementById("type"); var t_val = q.options[q.selectedIndex].value; var c=document.getElementById("checkin"); var c_val = c.options[q.selectedIndex].value; var r=document.getElementById("checkout"); var r_val = r.options[q.selectedIndex].value; if (window.XMLHttpRequest) {// code for IE7+, Firefox, Chrome, Opera, Safari xmlhttp=new XMLHttpRequest(); } else {// code for IE6, IE5 xmlhttp=new ActiveXObject("Microsoft.XMLHTTP"); } xmlhttp.onreadystatechange=function() { var q=document.getElementById("type"); var q_val = q.options[q.selectedIndex].value; var c=document.getElementById("checkin"); var c_val = c.options[c.selectedIndex].value; var r=document.getElementById("checkout"); var r_val = r.options[r.selectedIndex].value; if (xmlhttp.readyState==4 && xmlhttp.status==200) { document.getElementById("txtHint").innerHTML=xmlhttp.responseText; } } xmlhttp.open("GET","check10.asp?q=" + q_val + "&c=" + c_val+"&r=" +r_val, true); xmlhttp.send(); } </script> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Untitled Document</title> </head> <body> <form> <select id="type" name="type" onchange="showuser()"> <option value="">types</option> <option value="single">single</option> <option value="double ">double</option> <option value="suite">suits</option> </select> <input id="checkin" onchange="showCustomer(this.value)" size="22"/> <input id="checkout" onchange="showCustomer(this.value)" size="22"/> </form> <br /> <div id="txtHint">Customer info will be listed here...</div> </body> </html> The page with data: Code: <%@LANGUAGE="VBSCRIPT" CODEPAGE="65001"%> <!--#include file="Connections/sqlconn.asp" --> <% Dim sql Dim sql_cmd Dim sql_numRows ------if(t and c and r){ sql_cmd.CommandText = "SELECT dbo.rooms.id, type, image, price, details FROM dbo.rooms,dbo.transactions WHERE dbo.rooms.id=dbo.transactions.roomid and type='" & request.querystring("t") & "' and checkin>'" & request.querystring("c") & "' and checkout>'" & request.querystring("r") & "' and status='active'" } else if (c and r) { sql_cmd.CommandText = "SELECT dbo.rooms.id, type, image, price, details FROM dbo.rooms,dbo.transactions WHERE dbo.rooms.id=dbo.transactions.roomid and checkin>'" & request.querystring("c") & "' and checkout>'" & request.querystring("r") & "' and status='active'" else if (t) { sql_cmd.CommandText = "SELECT dbo.rooms.id, type, image, price, details FROM dbo.rooms,dbo.transactions WHERE dbo.rooms.id=dbo.transactions.roomid and type='" & request.querystring("t") & "' and status='active'" } else if ("") { "SELECT dbo.rooms.id, type, image, price, details FROM dbo.rooms,dbo.transactions WHERE dbo.rooms.id=dbo.transactions.roomid and status='active'" } sql_cmd.Prepared = true Set sql = sql_cmd.Execute sql_numRows = 0 %> <% Dim Repeat1__numRows Dim Repeat1__index Repeat1__numRows = -1 Repeat1__index = 0 sql_numRows = sql_numRows + Repeat1__numRows %> <!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>Untitled Document</title> </head> <body> <table border="1" cellpadding="1" cellspacing="1"> <tr> <td>id</td> <td>type</td> <td>image</td> <td>price</td> <td>details</td> </tr> <% While ((Repeat1__numRows <> 0) AND (NOT sql.EOF)) %> <tr> <td><%=(sql.Fields.Item("id").Value)%></td> <td><%=(sql.Fields.Item("type").Value)%></td> <td><%=(sql.Fields.Item("image").Value)%></td> <td><%=(sql.Fields.Item("price").Value)%></td> <td><%=(sql.Fields.Item("details").Value)%></td> </tr> <% Repeat1__index=Repeat1__index+1 Repeat1__numRows=Repeat1__numRows-1 sql.MoveNext() Wend %> </table> </body> </html> <% sql.Close() Set sql = Nothing %> I am trying to have the user input data into a box on a form and when they press an "Add" button, what they typed in the input field should appear in a box below. I can get it to to work....slightly. What they typed pops up where it should be, but then it disappears. Any idea as to stop that? Here is the javascript code and the form code: Code: <script type="text/javascript"> var array = new Array(); function insert(val){ array[array.length]=val; } function show() { var string=""; for(i = 0; i < array.length; i++) { string =string+array[i]+"<br>"; } if(array.length > 0) document.getElementById('quickSearchIngList').innerHTML = string; } </script> Code: <form> <table> <th>Recipe Quick Search</th> <tr> <td class="quickSearchHeader">Ingredient:</td> </tr> <tr> <td><input type="text" name="quicksearch" size="18" id="quickSearchInput"/></td> </tr> <tr> <td class="quickSearchAddButton" id="quickSearchAddButton"><input type='image' src='images/quickAddButton.png' name='quicksearchadd' alt='Add' onclick='insert(this.form.quicksearch.value),show();'/></td> </tr> </table> </form> <div class="quickSearchIngList" id="quickSearchIngList"> </div> Hello Everybody, I have a scenario where in i have 2 divisions, TOP and BOTTOM. In the BOTTOM Division i have a list box and Submit button in a form. User can select an item from the list box and click on the submit button. After user clicks the submit button i want to display some data/graph in the bottom division. However with my current code i see that on clicking the submit button , the data is displayed on a fresh page. Please guide me if this is possible or should i use a different logic. The code goes here. Code: <html> <head> <TITLE> Display Graph </TITLE> <script type="text/javascript"> function processData(form) { var BoardNumber = document.forms[0].elements[0].value; var BoardIndex = document.forms[0].elements[0].selectedIndex; alert("Selected board is :" + BoardNumber + ":Selected Index is :" + BoardIndex); document.write("Trying to print some data : "); document.write("<br>"); document.write("The board number is " + BoardNumber); } </script> <style type="text/css"> body { background-color : #fefefe; font-family:arial , verdana, sans-serif; text-align : center; } .page { margin-bottom : 10px ; text-align : left; font-size: 12px; background-color : 00ff00; background-repeat:repeat-y; border:1px solid #666666; height : auto; } .Down { margin-top : 10px ; text-align : left; font-size: 12px; background-color : ff0000; background-repeat:repeat-y; border:1px solid #666666; height : auto; } .header{ padding : 3px; background-color:#f3f3f3; } .content {padding : 10px; margin-left : 100px; } </style> </haed> <body> <div class = "page"> <div class = "header"><h1> My Company Name </h1> </div> <div class = "content"> <!-- The main Page Goes here --> <h2> Top DIVISION </h2> <p> This is test page. This is test page. This is test page. This is test page. This is test page. This is test page. This is test page. This is test page. This is test page. This is test page. This is test page. This is test page. This is test page. This is test page. </p> </div> </div> <div class = "Down" name="Down"> <h2> BOTTOM DIVISION </h2> <p> Down : I NEED TO DISPLAY DATA/GRAPH in the same division. Not in a fresh page???? <BR> <B> SELECT THE BOARD NUMBER and PRESS THE BUTTON "Process Request" </B> <form name = "SelectColor"> <select name = "boardnum"> <option selected = "selected " value = " " > select board </option> <option value = "Board_7125">7125</option> <option value = "Board_7325">7325</option> <option value = "Board_7335">7335</option> <option value = "Board_7340">7340</option> <option value = "Board_7342">7342</option> <option value = "Board_7400">7400</option> <option value = "Board_7401">7401</option> <option value = "Board_7405">7405</option> <option value = "Board_7420">7420</option> <option value = "Board_7550">7550</option> </select> <input type="button" name="process" id="process" value="Process Request..." onclick="processData(this.form)" /></p> </form> </p> </div> </body> </html> Hi and thanks in advance! Someone on this site made a form for me that hides and displays fields, depending on which variable is chosen from a given array. They did a very good job with it with one exception. It seems the code that is used to hide certain fields also hides the form data rather than posting it when the form is submitted. Here is the code for both the java (listed first) and the form itself. Code: // Funtion // Description: show or hide element in the form according to selected element // function show_hide(){ if (!document.getElementById) return false; fila = document.getElementById('tr_firstname'); fila.style.display = "none"; //hide fila = document.getElementById('tr_firstname_data'); fila.style.display = "none"; //hide fila = document.getElementById('tr_email'); fila.style.display = "none"; //hide fila = document.getElementById('tr_email_data'); fila.style.display = "none"; //hide fila = document.getElementById('tr_email'); fila.style.display = "none"; //hide fila = document.getElementById('tr_email_data'); fila.style.display = "none"; //hide fila = document.getElementById('tr_receipt_invoice'); fila.style.display = "none"; //hide fila = document.getElementById('tr_receipt_invoice_data'); fila.style.display = "none"; //hide fila = document.getElementById('tr_url'); fila.style.display = "none"; //hide fila = document.getElementById('tr_url_data'); fila.style.display = "none"; //hide fila = document.getElementById('tr_description_comments'); fila.style.display = "none"; //hide fila = document.getElementById('tr_description_comments_data'); fila.style.display = "none"; //hide var strtext ; var nuoption= document.frmbodydata.csreason.length; var nuindice = document.frmbodydata.csreason.selectedIndex; var nuvalueSelect = document.frmbodydata.csreason.options[nuindice].value; var strtextSelect = document.frmbodydata.csreason.options[nuindice].text; if (nuvalueSelect==0 ) { return; } fila = document.getElementById('tr_description_comments'); fila.style.display = ""; //show fila = document.getElementById('tr_description_comments_data'); fila.style.display = ""; //show if (nuvalueSelect==1 || nuvalueSelect==3 || nuvalueSelect==4 || nuvalueSelect==5 ) { fila = document.getElementById('tr_firstname'); fila.style.display = ""; //show fila = document.getElementById('tr_firstname_data'); fila.style.display = ""; //show fila = document.getElementById('tr_email'); fila.style.display = ""; //show fila = document.getElementById('tr_email_data'); fila.style.display = ""; //show } if (nuvalueSelect==2 || nuvalueSelect==3 || nuvalueSelect==4 || nuvalueSelect==5 ) { fila = document.getElementById('tr_url'); fila.style.display = ""; //show fila = document.getElementById('tr_url_data'); fila.style.display = ""; //show } if (nuvalueSelect==4 ) { fila = document.getElementById('tr_receipt_invoice'); fila.style.display = ""; //show fila = document.getElementById('tr_receipt_invoice_data'); fila.style.display = ""; //show } } // // Function // Description: Validate the form for submit // function ValidateForm( form ) { var nuindice = form.csreason.selectedIndex; var nuvalueSelect = form.csreason.options[nuindice].value; if (nuvalueSelect==0 ) { return false; } valor = form.receipt_invoice.value; if (!freturn(valor)) return false; valor = form.description_comments.value; if (!freturn(valor)) return false; if (nuvalueSelect==1 || nuvalueSelect==3 || nuvalueSelect==4 || nuvalueSelect==5 ) { valor = form.firstname.value; if (!freturn(valor)) return false; } valor = form.lastname.value; if (!freturn(valor)) return false; valor = form.email.value; if (!freturn(valor)) return false; if (nuvalueSelect==2 || nuvalueSelect==3 || nuvalueSelect==4 || nuvalueSelect==4 ) { valor = form.url.value; if (!freturn(valor)) return false; } alert ("Thank you for your comment.") return true } // // Function // Description: Function to return TRUE or FALSE for inclomplete data // /*function freturn(pbolvalue) { if( pbolvalue == null || pbolvalue.length == 0 || /^\s+$/.test(pbolvalue) ) { alert ("Incomplete Data, check please."); return false; }else{ return true; } } */ function ReloadCaptchaImage(captchaImageId) { var obj = document.getElementById(captchaImageId); var src = obj.src; var date = new Date(); var pos = src.indexOf('&rad='); if (pos >= 0) { src = src.substr(0, pos); } obj.src = src + '&rad=' + date.getTime(); return false; } Code: <center> <form id="frmbodydata" name="frmbodydata" onsubmit="return ValidateForm(this);" action="http://www.SnapHost.com/captcha/WebFormSubmit.aspx" method="post"> <input id="SnapHostID" name="SnapHostID" value="2FMYX5LLTQZQ" type="hidden" /> <table align="center" border="0" cellpadding="0" cellspacing="0"> <tbody> <tr> <td>Reason for contact</td> </tr> <tr> <td><select id="csreason" name="csreason" onchange="show_hide();" align="left"> <option value="0">Please Select One</option> <option value="1">Contact</option> <option value="2">Report Bad Link</option> <option value="3">Gallery Submission</option> <option value="4">Preferred Partner Submission</option> <option value="5">Link Exchange</option> </select></td> </tr> <tr id="tr_firstname" style="display:none;"> <td>First name/Last name</td> </tr> <tr id="tr_firstname_data" style="display:none;"> <td><input id="firstname" /><input id="lastname" align="left" type="text" /></td> </tr> <tr id="tr_email" style="display:none;"> <td>Email</td> </tr> <tr id="tr_email_data" style="display:none;"> <td><input id="email" size="30" maxlength="30" align="left" type="text" /></td> </tr> <tr id="tr_receipt_invoice" style="display:none;"> <td>Receipt/Invoice</td> </tr> <tr id="tr_receipt_invoice_data" style="display:none;"> <td><input id="receipt_invoice" name="receipt_invoice" size="15" maxlength="15" align="left" type="text" /></td> </tr> <tr id="tr_url" style="display:none;"> <td>URL</td> </tr> <tr id="tr_url_data" style="display:none;"> <td><input id="url" size="80" maxlength="80" align="left" type="text" /></td> </tr> <tr id="tr_description_comments" style="display:none;"> <td>Description/Comments</td> </tr> <tr id="tr_description_comments_data" style="display:none;"> <td><textarea id="description_comments" rows="10" cols="50" align="left"> </textarea></td> </tr> <tr> <td><i>Enter security code</i></td> <td>SECURITY CODE</td> </tr> <tr> <td><input name="CaptchaCode" class="txtFields" maxlength="6" style="width:130px; height:28px; font-size:24px; text-align:center;" type="text" /></td> <td><a href="http://www.SnapHost.com/captcha/ProCaptchaOverview.aspx"><img id="CaptchaImage" alt="Web Form Code" style="margin-left:20px; border:1px solid #999999;" src="http://www.SnapHost.com/captcha/WebForm.aspx?id=2FMYX5LLTQZQ&ImgType=2" /></a> <br /> <a href="#" onclick="return ReloadCaptchaImage('CaptchaImage');"><span style="font-size:12px;">reload image</span></a></td> </tr> <tr> <td align="center"><input src="http://www.theopenpussy.com/1/images/submit.gif" alt="Submit button" type="image" /></td> </tr> <tr> <td></td> </tr> </tbody> </table> </form> </center> Sorry for all the code! Is there anything I can do to maintain the hide and seek nature of the forms and show the data that is submitted, or am I stuck displaying all fields all the time? Hey guys, I'm hoping this is possible or that there is an easier way to do this. I'm having an issue with displaying data from one array that contains information about users in a table that is controlled by a different array. Is it possible to do this or is this use of arrays to display the data the wrong approach? The table is located on one webpage, I simply want to extract one piece of information that I have placed in the initial array as part of the login script that contains user information (for validation for login etc) and display it in a table on the new webpage that is opened as a result of successful validation of the user details. I'm completely stumped and after many attempts I just can't seem to get it to work. i have this in my javascript code but have no idea on how a returned value works/where does it return to???? what do i do/or can i do with a value that gets returned??? i am asking this so i can learn on how to use it cos i am new to all this and dont know how it works...please show/explain to me please? thanks here my full code: PHP Code: <?php use_stylesheets_for_form($form) ?> <?php use_javascripts_for_form($form) ?> <html> <head> <script type="text/JavaScript"> function refreshPage(s) { window.location.reload(); if((s.options[s.selectedIndex].value) = "zed-catcher") { var $index = s.selectedIndex; var $value = s.options[$index].value; alert (s.selectedIndex); alert ($value); window.location.reload(); [COLOR="Red"]return &value; //where does it return to ???? how/what to do with a return value???[/COLOR] } } </script> </head> </html> <body> <form action="<?php echo url_for('adminservice/'.($form->getObject()->isNew() ? 'create' : 'update').(!$form->getObject()->isNew() ? '?id='.$form->getObject()->getId() : '')) ?>" method="post" <?php $form->isMultipart() and print 'enctype="multipart/form-data" '?>> <?php if (!$form->getObject()->isNew()): ?> <input type="hidden" name="sf_method" value="put" /> <?php endif; ?> <table > <tfoot> <tr> <td colspan="2"> <?php echo $form->renderHiddenFields(false) ?> <a href="<?php echo url_for('adminservice/index') ?>">Back to list</a> <?php if (!$form->getObject()->isNew()): ?> <?php echo link_to('Delete', 'adminservice/delete?id='.$form->getObject()->getId(), array('method' => 'delete', 'confirm' => 'Are you sure?')) ?> <?php endif; ?> <input type="submit" value="Save" /> </td> </tr> </tfoot> <tbody> <?php echo $form->renderGlobalErrors() ?> <tr> <th><?php echo $form['name']->renderLabel() ?></th> <td> <?php echo $form['name']->renderError() ?> <?php echo $form['name']?> </td> </tr> <tr> <th><?php echo $form['logo_url']->renderLabel() ?></th> <td> <?php echo $form['logo_url']->renderError() ?> <?php echo $form['logo_url'] ?> </td> </tr> <tr> <th><?php echo $form['call_center_number']->renderLabel() ?></th> <td> <?php echo $form['call_center_number']->renderError() ?> <?php echo $form['call_center_number'] ?> </td> </tr> <tr> <th><?php echo $form['catcher_id']->renderLabel(); $catcher_id = $form->getObject()->getCatcherId(); $catcher = LpmCatcherPeer::getByCatcherId($catcher_id); $catcher_name = $catcher->getName(); ?></th> <td> <?php echo $form['catcher_id']->renderError() ?> [COLOR="Red"]<select name="services" onchange="refreshPage(this.form.services)">[/COLOR] <?php $catcher_names = LpmCatcherPeer::getByAllNames(); foreach($catcher_names as $row) { ?> <option value="<?php echo $row->getName()."/".$row->getId();?>" <?php if($row->getName() == $catcher_name) echo ' selected="selected"'; ?> ><?php echo $row->getName();?></option> <?php } [COLOR="Red"]if ($row->getName() == "zed-catcher") //just thought with the return in my java script i can pass the newley selected value back to here and if it meets the if i echo these lines?? { echo $form['service_code']->renderLabel(); echo $form['service_code']->renderError(); echo $form['service_code']; } [/COLOR] ?> </select> </td> </tr> <tr> <th><?php echo $form['price_description']->renderLabel() ?></th> <td> <?php echo $form['price_description']->renderError() ?> <?php echo $form['price_description'] ?> </td> </tr> </tbody> </table> </form> </body> thanks! i'm trying to get some information with this code from my database: Code: function getTableSize(tableName){ db.transaction ( function(tx) { tx.executeSql ('SELECT * FROM '+ tableName,[] , function(tx, r) { return r.rows.length; } ); } ); } but it doesnt work and i cant figure why what i want is that this function return the table size to one variable in another function...something like: Code: var groupTableSize = getTableSize('groups'); Have a jsp page with 10 editable fields and in last Add Button.Now when user edit a field from value 10 to 20(example)and click on Add .Value will be changed and focus will return to the same field.similarly for other fields.how to to .any code sample?
I want the output to be this way Student: Doe, John eMail: jd@email.com Course ID: COIN-O70A.01 ----------------------- Can any one pls help me with the display. If I use alert instead of return then I works. But I need to display it in the document. Code: <html> <head> <title>Variable - Examples 1</title> <script type="text/javascript"> function Student(firstName, lastName, email,courseID){ this.firstName = firstName; this.lastName = lastName; this.email = email; this.courseID = courseID; } Student.prototype = { constructor : Student, toString : studentInfo }; function studentInfo(){ return this.firstName + "," + this.lastName + '\n'+ this.email + '\n' + this.courseID; } var student = new Student("Doe", "John", "Doeohn@gmail.com","COIN 70A.01"); </script> </head> <body> <script type="text/javascript"> document.writeln(student.toString()); </script> </body> </html> i achieved to make a chain: Code: function getId(id) { id_elem = document.getElementById(id); return { color:function(e){ id_elem.style.color = e; } }; } so this can be getId("test").color("red"); but what happens if i want to do that? Code: function getId(id) { id_elem = document.getElementById(id); return id_elem; return { ????...... how can i chain if i use return in the first place? Hello, How can this be made to return confirmation? <form id="score_form" method="post" action="addscore.php"><input id="score" name="score" value="" type="hidden"><img id="collect" style="cursorointer;height: 37px; width: 100px; margin-top: 13px;" src="./collectlive.gif" onclick="collect_points();"></form> Letsay the confirmation window would say"ARE YOU SURE" hi, i wanna get the value from javascript to php variable. here is my code, <html> <body> <select name="drop" size="10" onchange="drp_selectd_value(this)"> <option>One</option> <option>Two</option> <option>Three</option> <option>Four</option> <option>Five</option> </select> <?php echo "The PHP value".'<script>value_return();</script>'; $p='<script>y;</script>'; ?> </body> </html? <script> var x; var y=100; function drp_selectd_value(sdf) { x=sdf.value; alert("Value is : " +x); value_return(x); } function value_return(val) { alert("Second Function calling : "+val ); return val; } </script> This code does not working!!! How can i fix tis problem???I m expecting for the reply.. Thanks in advance I have a javascript that takes information from a form and recompiles that information into a readable shift report. The problem I am having is with returns in the textareas. I tried: Code: theReport = theReport.replace(" ","<br>" but that space puts the rest of the var on a different line and screws with the results. How can I replace a return with <br>? hi,i don't understand about the jquery basic example the code is below PHP Code: <html> <head> <script type="text/javascript" src="jquery.js"></script> <script type="text/javascript"> $(document).ready(function(){ $("button").click(function(){ $('p').addClass(function(n){ return 'par_' + n; }); }); }); </script> <style type="text/css"> .par_0 { color:blue; } .par_1 { color:red; } </style> </head> <body> <h1>This is a heading</h1> <p>This is a paragraph.</p> <p>This is another paragraph.</p> <button>Add classes to p elements</button> </body> </html> i want to understand about the how is work function(n){ in the function a and how work return function return 'par_' + n; thanks mate Im working on a function where i need to return the active elements ID. the element will have class="main" id="1" onmouseover="showSub()"> Would someone be able to write me a simple function which simply puts the elements ID number in an alert box? I can figure out the rest i need from that . Thanks, Tom |