JavaScript - Passing Values Through Pages
I have the following snippet of HTML code:
Quote: <table id="identificativo"> .......... .......... .......... <tr id="id_riga"> <td width="40%"> Cella 1 </td> <td> <input type="hidden" name="params" value="valore1 valore2" /> <input type="button" value="Add/Change" onclick="return del()" /> </td> <td> Cella3 </td> </tr> ............ ............ ............ and the following javascript code that replace the second row of table with new form: Quote: function del() { if (document.getElementById) { var tabella = document.getElementById("identificativo"); tabella.deleteRow(1); x = tabella.insertRow(1); x.innerHTML = "<td colspan='3'> \ <form action='/cgi-bin/save.cgi' method='POST'> \ <input type='text' name='name' size='30' /> \ <input type='submit' value='Save' /> \ </form> \ </td>"; } } How can to pass hidden values valore1 and valore2 from old cell of row to new form with javascript? Thank you in advance to answers, savio Similar TutorialsHello, i'm working on a 3 page survey. When hitting next, previous, or submit it passes the values of all the questions to the next page. I've got the whole thing working correcting except for one thing: When the box is "not" checked it passes no value. I'm needing it to have a value of "1" when checked and a value of "0" when not checked, and currently when its not checked and i pass the info it leaves it blank. I'd post the whole code to one of the pages but it's long , so i'll post the snipits of the code. Code: <script type="text/javascript"> /* <![CDATA[ */ function processQueryString() { var formData = location.search; formData = formData.substring(1, formData.length); while (formData.indexOf("+") != -1) { formData = formData.replace("+", " "); } formData = unescape(formData); var formArray = formData.split("&"); for (var i=0; i < formArray.length; ++i) { //document.writeln(formArray[i] + "<br />"); var sDataName = formArray[i].split("=") switch (sDataName[0]) { case ".lib_use": for (var j=0; j < document.getElementsByName(".lib_use").length; ++j) { if (document.getElementsByName(".lib_use").item(j).value == sDataName[1]) { document.getElementsByName(".lib_use").item(j).checked = true; //alert("lib_use set"); } } break; case ".lib_comp": if (sDataName[1] == 1) { document.getElementsByName(".lib_comp").checked = true; document.getElementsByName(".lib_comp").value= 1; } else { document.getElementsByName(".lib_comp").checked = false; document.getElementsByName(".lib_comp").value= 0; } break; default: alert("not caught = " + sDataName[0]); continue; } } } /* ]]> */ </script> <input type="checkbox" name=".lib_comp" id="lib_comp" value="1" /> The first case that i showed in my code is a radio button, and it passes correctly, i just wanted to show the "format" i was using in a working sense. The 2nd case is an example of the check boxes. Thanks for looking at this, and giving any suggestions you might have! Hi, I was wondering if i can pass my php variables through javascript function. Actually i have a simple table of pictures, when clicked in the picture a new popup page comes up, it working fine uptill this stage but now i want to pass a value through it, for instance if user clicks on picture1 then my popup url should be "item_large.php?id=pic1 My Javascript junction for the popup window: Code: function popup() { window.open("item_large.php","Register","menubar=no,width=500,height=400,toolbar=no"); } My Html code where i have my pictures: Code: <td height="19" align="center" valign="top" onmouseover="this.bgColor='#CC3300' ; this.style.cursor='pointer'" onmouseout="this.bgColor='#FFFFFF'" <A HREF="javascript:popup()">Picture01</A> </td> Thanks Hi, I am trying to pass a video id value from one javascript page to another, extract the video id, append it to a utube url and then pass it to a html page for immediate display. I have managed to extract the video id value and append it to the url but cannot get it into the html section of the code. My code is posted below <html> <head> <script type="text/javascript"> function getParams() { var idx = document.URL.indexOf('?'); var urlId; var params = new Array(); if (idx != -1) { var url = document.URL.substring(idx+1, document.URL.length).split('&'); for (var i=0; i<url.length; i++) { videoVal = url[i].split('='); urlId = "http://www.youtube.com/v/" + videoVal[1]; } } document.getrElementById('UrlId').value=urlId; } params = getParams(); </script> </head> <body> <object width="425" height="344"> <param name="UrlId" value=urlId; </param><embed src=urlId type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="425" height="344"> </embed> </object> </p> </body> </html> I need to get it to appear as a complete url in the following lines in the html code <param name="UrlId" value=urlId; <embed src=urlId type="application/x-shockwave-flash"></embed> Can someone please help with this. Thanks i have this frameset: http://www.mediafire.com/?75dvswgvelw19a9 this is somehow the like my other posts but im dealing with the radio buttons. what i want is when i click on the "create" button in form1 http://www.mediafire.com/?eld7a1rb21h799e it will pass the value to form 2 http://www.mediafire.com/?f0o060cdpyf06ya. so when i select "yes" in form1 and click on "create" it will autoselect "On" in form2. if i select "no" in form1 and click on "create" it will autoselect "off" in form2. I want to pass dynamic array values to java script function.how its possible. explain with some code.........
I tried implementing a cleaner approach to a web form I had created, but it doesn't seem to be passing the values to the server properly. What gives? This form on the left and right work perfectly, but they have two ridiculously long drop down lists, which would be the "ProgramOfInterest" fields (please use the following values preselected in this form) http://www.nationalcollegesearch.org..._pingpost.html On this form, I tried creating a triple drop down list setup to clean up the older, long lists in this example, but it doesn't pass the values properly. It also seems to not duplicate the new drop down triple drop lists properly as in the original form. You can change the values in the drop downs in the forms to see what I mean. Also just pick Bachelor's > B_Business > Business Administration in the triple drop downs for an example since I don't know how to preselect those values. http://nationalcollegesearch.org/Integrate/PleaseHelpMeWithMyCode/integrate_pingpost_experiment.html Please let me know if there is anything I can do to pass the correct values to the server. Thanks! P.S. Please note that I have disabled the form on the right and intentionally left the action empty. This is the triple drop down script I am using: Code: <script type="text/javascript"> /* Triple Combo Script Credit By Philip M: http://www.codingforums.com/member.php?u=186 Visit http://javascriptkit.com for this and over 400+ other scripts Modified by: jmrker */ var categories = []; categories["startList"] = ["Diploma/Certificate:CE","Associate's:AA","Bachelor's:BA","Master's:MA"]; categories["Diploma/Certificate"] = ["C_Arts & Humanities:CE1","C_Automotive:CE2","C_Computers & IT:CE3","C_Education & Teaching:CE4","C_Health & Medical:CE5","C_Trades & Careers:CE6"]; categories["C_Arts & Humanities"] = ["Desktop Publishing:CEDP","Floral Design:CEFD","General Arts:CEGA","Interior Decorating:CEID","Jewelry:CEJ"]; categories["C_Automotive"] = ["Automotive Technician Training:CAUTO","Collision and Auto Body Repair:CCOLL","Motorcycle Mechanic Training:CMM"]; categories["C_Computers & IT"] = ["Cisco:CECS", "Information Technology:CEIT", "Microsoft:CEMS", "Network Systems:CENSYS", "Oracle:CEOR", "PC Repair:CEPC"]; categories["C_Education & Teaching"] = ["Child Day Ca CEDC", "General Education:CEGE"]; categories["C_Health & Medical"] = ["Dental Assisting:CEDENT", "Fitness:CEFIT", "Healthca CEHC", "Massage Therapy:CMT", "Medical Assisting:CEMEA", "Medical Billing and Insurance Coding:CEMBIC", "Medical Office Administration:CEMOA", "Occupation Therapy:CEOT", "Phlebotomy:CEPHL", "Social Work:CESW"]; categories["C_Trades & Careers"] = ["Administrative Assistant:CEAA", "Animal Ca CEAC", "Appliance Repair:CEAR", "Bookkeeping and Payroll Accounting:CEBOO", "Bridal Consulting:CEBC", "Carpentry and Construction:CECC", "Culinary:CECU", "Drafting:CEDR", "Electronics:CEEL", "Forestry and Wildlife:CEFW", "Gunsmithing:CEGUN", "HVAC:CEHV", "Landscaping:CELS", "Law Enforcement:CELE", " Locksmithing:CELOCK", "Plumbing and Electrical:CEPE", "Private Investigator:CEPI", "Wedding Planner:CEWP"]; categories["Associate's"] = ["A_Arts & Humanities:AA1","A_Business:AA2","A_Criminal Justice:AA3","A_Computers & IT:AA4","A_Education & Teaching:AA5","A_Health & Medical:AA6","A_Science & Technology:AA7","A_Social Sciences:AA8","A_Trades & Careers:AA9"]; categories["A_Arts & Humanities"] = ["Communication:AACOM","Fashion:AAFASH","Game Design:AAGD","General Arts:AAGA","Graphic Design:AAGR","Religion:AAREL","Web Design:AAWD","Writing:AAWR"]; categories["A_Business"] = ["Accounting:AAAC","Administrative Assistant:AAAS","Business Administration:AABA","eBusiness and eCommerece:AAEB","Finance:AAFIN","Human Resources Management:AAHR","International Business:AAIB","Marketing:AAMAR","Organizational Leadership:AAOR","Project Management:AAPM"]; categories["A_Criminal Justice"] = ["Criminal Justice:AACJ","Homeland Security:AAHS","Law:AALAW","Legal Assisting Paralegal:AAPAR","Political Science:AAPS"]; categories["A_Computers & IT"] = ["Computer Networking and Security:AACNS","Computer Science:AACS","Databases:AADB","Information Systems:AAIS","Information Technology:AAIT","Technology Management:AATEM","Web Development:AADEV"]; categories["A_Education & Teaching"] = ["Adult and Higher Education:AAHE","Curriculum and Instruction:AACI","Early Childhood Education:AAEVE","General Education:AAGE","Special Education (K-12):AASE"]; categories["A_Health & Medical"] = ["Gerontology (Study of people as they age):AAGER","Healthca AAHLTH","Healthcare Management:AAHCM","Medical Assisting:AAMA","Medical Billing and Insurance Coding:AAMBIC","Medical Office Administration:AAMOA","Nursing:AANUR","Radiology & Sonography:AARAD"]; categories["A_Science & Technology"] = ["Aviation:AAAV","Engineering Management:AAEN","Environmental Sciences:AAENV","Science:AASCI"]; categories["A_Social Sciences"] = ["Counseling:AACOUN","History:AAHIST","Psychology:AAPSY","Public Administration:AAPA","Public Safety:AAPUBS","Social Science:AASS"]; categories["A_Trades & Careers"] = ["Animal Ca AAAC","Carpentry & Construction:AACAR","Fire and Law Enforcement:AALE","Travel and Tourism:AATR"]; categories["Bachelor's"] = ["B_Arts & Humanities:BA1","B_Business:BA2","B_Computers & IT:BA3","B_Criminal Justice:BA4","B_Education & Teaching:BA5","B_Health & Medical:BA6","B_Science & Technology:BA7","B_Social Sciences:BA9","B_Trades & Careers:BA0"]; categories["B_Arts & Humanities"] = ["Communication:BACOM","Fashion:BAFASH","Game Design:BAGD","General Arts:BAGA","Graphic Design:BAGR","Music:BAMUS","Religion:BAREL","Web Design:BAWD","Writing:BAWR"]; categories["B_Business"] = ["Accounting:BAAC","Business Administration:BABA","eBusiness and eCommerece:BAEB","Entrepreneurial Studies:BAES","Finance:BAFIN","Human Resources Management:BAHR","International Business:BAIB","Marketing:BAMAR","Organizational Leadership:BAOR","Project Management:BAPM"]; categories["B_Computers & IT"] = ["Computer Networking and Security:BACNS","Computer Science:BACS","Databases:BADB","Information Systems:BAIS","Information Technology:BAIT","Technology Management:BATM","Web Development:BADEV"]; categories["B_Criminal Justice"] = ["Criminal Justice:BACJ","Homeland Security:BAHS","Law:BALAW","Legal Assisting Paralegal:BAPAR","Political Science:BAPS"]; categories["B_Education & Teaching"] = ["Adult and Higher Education:BAHE","Curriculum and Instruction:BACI","Early Childhood Education:BAECE","General Education:BAGE","Special Education (K-12):BASE"]; categories["B_Health & Medical"] = ["Gerontology (Study of people as they age):BAGR","Healthca BAHLTH","Healthcare Management:BAHCM","Medical Assisting:BAMA","Nursing:BANUR","Radiology & Sonography:BARAD"]; categories["B_Science & Technology"] = ["Aviation:BAAV","Electronics Engineering:BAEE","Engineering Management:BAEN","Environmental Sciences:BAENV","Mathematics:BAMS","Science:BASCI"]; categories["B_Social Sciences"] = ["Counseling:BACOUN","History:BAHIST","Psychology:BAPSY","Public Administration:BAPA","Public Safety:BAPUBS","Social Science:BASS","Sociology:BASOC"]; categories["B_Trades & Careers"] = ["Fire and Law Enforcement:BALE"] categories["Master's"] = ["M_Arts & Humanities:MA1","M_Business:MA2","M_Computers & IT:MA3","M_Criminal Justice:MA4","M_Education & Teaching:MA5","M_Health & Medical:MA6","M_Science & Technology:MA7","M_Social Sciences:MA9"]; categories["M_Arts & Humanities"] = ["Communication:MACOM","Game Design:MAGD","General Arts:MAGA","Graphic Design:MAGR","Music:MAMUS","Religion:MAREL","Web Design:MAWD","Writing:MAWR"]; categories["M_Business"] = ["Accounting:MAAC","Business Administration:MBA","eBusiness and eCommerece:MAED","Entrepreneurial Studies:MAES","Finance:MAFA","Finacial Planning:MAFPL","Human Resources Management:MAHR","International Business:MAIB","Marketing:MAMAR","Organizational Leadership:MAOR","Project Management:MAPM"]; categories["M_Computers & IT"] = ["Computer Networking and Security:MACNS","Computer Science:MACS","Databases:MADB","Information Systems:MAIS","Information Technology:MAIT","Technology Management:MATM","Web Development:MADEV"]; categories["M_Criminal Justice"] = ["Criminal Justice:MACJ","Homeland Security:MAHS","Law:MALAW","Legal Assisting Paralegal:MAPAR","Political Science:MAPS"]; categories["M_Education & Teaching"] = ["Adult and Higher Education:MAHE","Curriculum and Instruction:MACI","Early Childhood Education:MAECE","General Education:MAGE","Special Education (K-12):MASE"]; categories["M_Health & Medical"] = ["Gerontology (Study of people as they age):MAGR","Healthca MAHLTH","Healthcare Management:MAHCM","Medical Assisting:MAMA","Nursing:MANUR","Radiology & Sonography:MARAD"]; categories["M_Science & Technology"] = ["Aviation:MAAV","Electronics Engineering:MAEE","Engineering Management:MAEN","Environmental Sciences:MAENV","Mathematics:MAMS","Science:MASCI"]; categories["M_Social Sciences"] = ["Counseling:MACOUN","History:MAHIST","Psychology:MAPSY","Public Administration:MAPA","Public Safety:MAPUBS","Social Science:MASS","Sociology:MASOC"]; var nLists = 3; // number of select lists in the set function fillSelect(currCat,currList){ var step = Number(currList.id.replace(/\D/g,"")); for (i=step; i<nLists+1; i++) { document.forms['form1']['List'+i].length = 1; document.forms['form1']['List'+i].selectedIndex = 0; } var tmp = currCat.split(':'); var nCat = categories[tmp[0]]; for (each in nCat) { tmp = nCat[each].split(':'); var nOption = document.createElement('option'); var nData = document.createTextNode(tmp[0]); nOption.setAttribute('value',nCat[each]); nOption.appendChild(nData); currList.appendChild(nOption); } } function getValue(L3, L2, L1) { var l3 = L3.split(':'); var l2 = L2.split(':'); var l1 = L1.split(':'); // alert("Your selection was:- \n" + L1 + "\n" + L2 + "\n" + L3); // alert("Your selection was:- \n" + l1[1] + "\n" + l2[1] + "\n" + l3[1]); } function init() { fillSelect('startList',document.forms['form1']['List1']) } navigator.appName == "Microsoft Internet Explorer" ? attachEvent('onload', init, false) : addEventListener('load', init, false); </script> </head> <body> <form name="form1" action=""> <table> <tr> <td class="frmText" style="color: #000000; font-weight: normal;">Degree:</td> <td><select id='List1' onchange="fillSelect(this.value,this.form['List2'])"> <option selected>Select degree</option> </select> </td> </tr> <tr> <td class="frmText" style="color: #000000; font-weight: normal;">Area of Study:</td> <td><select id='List2' onchange="fillSelect(this.value,this.form['List3'])"> <option selected>Select area of study</option> </select> </td> </tr> <tr> <td class="frmText" style="color: #000000; font-weight: normal;">Program of Interest:</td> <td><select class="frmInput" id="List3" name="ProgramOfInterest" onchange="getValue(this.value,this.form['List2'].value, this.form['List1'].value)"> <option selected >Select program</option> </select> </td> </tr> </table> </form> Hello guys. I've been struggling on how to make this work. I have a problem in Javascript when it comes to passing of value in a input type field. page1.html Code: <html> <head><title></title></head> <form action="" method="post> <input type="text" name="weight" value=""><a href="hw_calculator.html" target="name" onclick="window.open('hw_calculator.html','name','height=270,width=370,toolbar=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=yes'); return false;"> calculate </a> </form> </html> hw_calculator.html Code: <html> <head> <title> Height Converter (Metric/Standard) </title> </head> <body> <FORM> <INPUT type=hidden value="(Math.round((P.value * 0.45359)*100))/100" name=K_expr> <INPUT type=hidden value="(Math.round((K.value / 0.45359)*100))/100" name=P_expr> <INPUT type=hidden value="(Math.round((F.value * 30.48 + I.value * 2.54)*100))/100" name=C_expr> <INPUT type=hidden value="(Math.floor(C.value / 30.48))" name=F_expr> <INPUT type=hidden value="(Math.round(((C.value - (Math.floor(C.value / 30.48) * 30.48)) / 2.54)*100))/100" name=I_expr> <INPUT type=hidden value="(Math.round(P.value * 0.45359))" name=K_exprrnd> <INPUT type=hidden value="(Math.round(K.value / 0.45359))" name=P_exprrnd> <INPUT type=hidden value="(Math.round(F.value * 30.48 + I.value * 2.54))" name=C_exprrnd> <INPUT type=hidden value="(Math.floor(C.value / 30.48))" name=F_exprrnd> <INPUT type=hidden value="(Math.round((C.value - (Math.floor(C.value / 30.48) * 30.48)) / 2.54))" name=I_exprrnd> <h2>Height Converter</h2> <table border="0" bgcolor="#FFFF99" cellspacing="6" cellpadding="6"> <tr> <td colspan> <p class="conv" style="margin-top: 10px; margin-bottom: 10px"><b>STANDARD</b></p> </td> <td></td> <td colspan> <p class="conv" style="margin-top: 10px; margin-bottom: 10px"><b>METRIC</b></p> </td> </tr> <tr> <td> <p class="conv" style="margin-top: 10px; margin-bottom: 10px">Feet : <input maxLength=1 size=1 value=0 name=F> Inches : <input maxLength=2 size=1 value=0 name=I> </td> <td> <p class="conv" style="margin-top: 10px; margin-bottom: 10px"> = </p> </td> <td> <p class="conv" style="margin-top: 10px; margin-bottom: 10px"><input maxLength=3 size=1 value=0 name=C disabled> cm.</p> </td> </tr> <tr> <td class="conv" colspan="2"> <input type="button" name="Taste" value="Calculate" onclick="if (rounded.checked == true) { eval('C.value = ' + this.form.C_exprrnd.value); eval('K.value = ' + this.form.K_exprrnd.value) } else { eval('C.value = ' + this.form.C_expr.value); eval('K.value = ' + this.form.K_expr.value) }"> <INPUT type=checkbox name="rounded" value="rounded" checked disabled><font size="1" face="Verdana">Rounded Result</font> </td> </tr> </table> <p class="conv" style="margin-top: 10px; margin-bottom: 10px"> </body> </html> I want the value of Code: <input maxLength=3 size=1 value=0 name=C disabled> , this is from hw_calculator.html, to be passed on the Code: <input type="text" name="weight" value=""> on page1.html. How can I do this? Huge thanks. Hi, I coded the following JavaScript: Code: var el = document.createElement("iframe"); el.setAttribute('id', 'ifrm'); document.body.appendChild(el); el.setAttribute('height', 250); el.setAttribute('width', 300); el.setAttribute('frameborder', 0); el.setAttribute('marginheight', 0); el.setAttribute('marginwidth', 0) el.setAttribute('src', 'http://example.com/?pub=1&format=image&size=300x250&url='+window.location); And am putting it between <script type="text/javascript"> and </script> tags in the <body> section of my site. But, it only works in certain areas of the page. Can you guys think of any reason for this? Let me know... Thanks, ~Christian Hi, I have what I assume started as a simple error and then trying to fix it I think I have made things so complicated I've become confused. I have two fields, a drop down list and a text field, when someone clicks on a value in a drop down list (I will show the results eventually but at the moment) I just want the result to echo in my getCategory.php and the same for the text field. Both php pages are currently being called. And at the moment contain $_REQUEST['category'] and $_REQUEST['ProductName'] respectively. Nothing is being echoed. I know the below code is wrong, but the more I try to correct it the worse it gets so I thought I would just leave it as is before I made it worse. Code: <script type="text/javascript"> function loadXMLDoc1(File,ID,Msg){ if (window.XMLHttpRequest) { xmlhttp=new XMLHttpRequest(); } else { try{ xmlhttp=new ActiveXObject("Msxml2.XMLHTTP"); } catch (e) { xmlhttp=new ActiveXObject("Microsoft.XMLHTTP"); } } xmlhttp.onreadystatechange=function(){ if (xmlhttp.readyState==4 && xmlhttp.status==200){ document.getElementById(ID).innerHTML=xmlhttp.responseText; } } var params=Msg; xmlhttp.open("POST",File,true); xmlhttp.setRequestHeader("Pragma", "Cache-Control:no-cache"); xmlhttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded"); xmlhttp.setRequestHeader("Content-length", params.length); xmlhttp.setRequestHeader("Connection", "close"); xmlhttp.send(params); } </script> </head> <body> <label>Search by Category: </label> <select name="category" id="category" onchange='loadXMLDoc1("getCategory.php","txtHint","category")' class="input"> <option value="please select" selected"selected">Please Select</option> <option value="Clothes" name="Clothes" id="Clothes">Clothes</option> <option value="Bags" name="Bags" id="Bags">Bags</option> <option value="Hats" name="Hats" id="Hats">Hats</option> </select> <br /> <br /> <label>Search by name: </label> <input type="text" class="input" name="ProductName" id="ProductName" value="Search" size="30"/> <input type="button" value="Search" onclick="loadXMLDoc1('getProductName.php','txtHint', ProductName='(this.value)')" /> <br /> <br /> <div id="txtHint"></div> Dear all, I'm passing the variables myTitle and myLink to form.php using javascript. This is the way I'm doing it: Code: <a href='form.php?title=" + myTitle +"&link="+myLink+">Click me</a> It's working great but sometimes myTitle and myLink contain the plus character (+). When this happens it's not passed. In the case of the title, it's just a problem of looks but in the case of the link, well, the link won't work without the character. As an example if the title is: Laptop + Accessories What is passed is: Laptop Accessories What can I do to pass also the plus character?? Thanks a lot!! Hi gud mng, I have one problem... How to process textbox values/ call textbox values in JS through a Java program. My text box values are dates. I have to process these dates. Like in online banking we select day to know our transactions. After submitting we get results. remember my files are in my directory only. No need of database. My files are look like 20100929, 20100930, 20101001 For epoch_classes.js, epoch_styles.css u can download coding from this link : http://www.javascriptkit.com/script/...ch/index.shtml Code: Code: <html> <table width="900" border="0" cellpadding="10" cellspacing="10" style="padding:0"> <tr><td id="leftcolumn" width="170" align="left" valign="top"> <div style="margin-left:0px;margin-top:0px"><h3 class="left"><span class="left_h2">Select Option</span></h3> <a rel="nofollow" target="_top" href="day_wise.htm" >Day-wise</a><br /> <br /> <a rel="nofollow" target="_top" href="between.htm" >Between Days</a> <link rel="stylesheet" type="text/css" href="epoch_styles.css" /> <script type="text/javascript" src="epoch_classes.js"></script> <script type="text/javascript"> var cal1, cal2; window.onload = function () { cal1= new Epoch('epoch_popup','popup',document.getElementById('popup_container1')); cal2= new Epoch('epoch_popup','popup',document.getElementById('popup_container2')); }; /*............*/ function confirmation(f) { var startdate = f.fromdate.value var enddate = f.todate.value var myday=new Date() var yr=myday.getFullYear() var mn=myday.getMonth()+1 var dt=myday.getDate() var today="" var present, ys, ms, ds, ye,me,de, start, end if(mn < 10) { mn = "0" + mn } if(dt <10) { dt = "0" + dt } today= yr + "/" + mn + "/" + dt present=yr + "/" + mn + "/" +dt if (today < startdate ) { alert (" Start date should not be exceed to-day's date " + present ) startdate.focus() return false } if (today < enddate ) { alert (" End date should not be exceed to-day's date " + present ) enddate.focus() return false } if (today == startdate ) { alert(" You are selected to-days date as Starting day" ); } var answer = confirm("Do you want to continue ?") if (answer) { if( startdate < enddate) alert("Dates between " + startdate + " to " + enddate + " are confirmed" ) else alert("Dates between " + enddate + " to " + startdate + " are confirmed" ) } else { alert("Date not confirmed") window.location="to_date.htm"; } ys= startdate.substring(0,4); ms= startdate.substring(5,7); ds= startdate.substring(8,10); start=ys + "" + ms + "" +ds ye= enddate.substring(0,4); me= enddate.substring(5,7); de= enddate.substring(8,10); end=ye + "" + me + "" +de } /*.......................................................*/ </script> <div style="margin-left:100px;"> <body> <style type="text/css"> #conf { margin-left:115px; } </style> <td align="left" valign="top"> <table width="100" border="0" cellpadding="0" cellspacing="0"> <td style="padding-top:0px"> </table> <h4>From Date</h4> <form name= "formbet" id="placeholder" method="post" action="#" > <input id="popup_container1" type="text" name= "fromdate" maxlength="10" size="20"/> <td align="left" valign="top"> <table width="300" border="0" cellpadding="0" cellspacing="0"> <td style="padding-top:20px"> <h4>To Date</h4> <input id="popup_container2" type="text" name= "todate" maxlength="10" size="20"/> <br /> <br /> <input id="conf" type="button" onclick="confirmation(this.form)" value="Submit"> </form> </body> </html> In my coding, ys, ms, ds represents year starting, month starting, starting day... ye, me, de represents end... start,end gives file names in the format of yyyymmdd now i want to process files from 20100101 to 20100930 means from date is 2010/01/01 and to date is 2010/09/30 if i press submit button the files from 20100101 to 20100930 are processes here ys=2010 ms=01 ds =01 and ye=2010 me=09 de= 30 For this how do i call these textbox values (from date text box and todate) to another program (java) Thanks in advance. Hi, I've had problems in the past understanding this, however, after reading this tutorial, I understand. In some languages, like VB6, I notice the "byVal" and the "byRef" is specifically used. In javascript, I don't notice those specifics typed in functions. Is the "default" by value when using in a function to change a parameter? If it is, what is the syntax for using by reference, or is that ever used? My question arises from this notation taken from here: Quote: Note that it is the value that a has at the time that it is passed into the function that gets substituted into the argument and not the value that the original variable has at that point in the processing. It is the values in the parameters that the function uses and not the variables. This is called pass by value . In those languages where you can pass the actual variable into the function instead of just passing its value the method used to do so is called pass by reference . Had we been able to pass the variables into the function by reference rather than by value then the final value in b would have been -16 instead of -14. Here is the example (passing by value): Code: function myfunction(y, z) { a += y; b -= z; } var a = 0; var b = 10; var c = 3; var d = 4; var e = 2; myfunction(c, d); myfunction(d, e); myfunction(9, 2); myfunction(b, a); Results: myFunction(c, d); output: 0 + 3 = 3(y), 10 - 4 = 6(z) myFunction(d, e); output: 3 + 4 = 7(y), 6 - 2 = 4(z) myFunction(9, 2); output: 7 + 9 = 16(y), 4 - 2 = 2(z) myFunction(b, a); output: 2 + 16 = 18(y), 2 -16 = -14(z) Thanks! I have a bunch of checkboxes like below that the user can check some or all and click the button and see the values of all the selected checkboxes. How can I do that? Code: <script> function alertValues(){ } </script> <input type="checkbox" class ="normal2" value="131971" name="list[]" > <input type="checkbox" class ="normal2" value="131973" name="list[]" > <input type="checkbox" class ="normal2" value="131975" name="list[]" > <input type="checkbox" class ="normal2" value="131977" name="list[]" > <input type="button" onClick="alertValues()" Hi, What's a good way/ideal data structure to achieve this? The objective of the code/function is to map user-inputted strings into a pair of specific, hard-coded strings. For example, say the user types "firefox" or "ff", or "fx". The output would be the pair ["browser", "mozilla"], for example. I'm currently using a multidimensional array, but it feels inefficient and I'm having trouble mapping an arbitrary number of inputs into 2 outputs. Code: var strings = [ ["input1", "output1a"], ["input2", "output1a"], ["input3", "output1a"], ["input1", "output1b"], ["input2", "output1b"], ["input3", "output1b"] ]; How should I map the elements ["input1", "input2", "input3"] => ["output1a", "output1b"] ? Another method I used previously was a massive switch statement. This fulfills my needs, but I'm not sure about the efficiency (though if I remember correctly, switch statements become more efficient as size grows, since it uses a hash table?). Code: switch (input) { case "ff": case "firefox": case "fx" : case "ffox": return ["browser", "mozilla"]; case "ie": case "internet explorer": return ["browser", "microsoft"]; ... } I've had some help figuring out how to pass a variable through a pop-up window: Code: <script type="text/javascript"> function expo(o) { var et = document.getElementById(o); if(et) { window.open( "exp.php?exportthis="+et.value, "myWindow", "status = 1, height = 300, width = 300, resizable = 0"); } } </script> <form action="" method="post"><input type=hidden value="$file" name="exportthis" ><input type=submit value=Export name= "Exp"onclick="expo('exportthis');" /> </form> However, my issue is that I have multiple forms. The forms are the same - the variables are different. The code above only works with the first variable returned. Here's an example of the problem. Code: <?PHP //for example purposes the filename will be labeled as numbers $i = 1; while ($i < 5) { echo "<form action=\"\" method=\"post\"><input type=hidden value=\"$i\" name=\"exportthis\" ><input type=submit value=\"Export\" name= \"Exp\"onclick=\"expo('exportthis');\" /></form>"; } ?> The above simple PHP script produces 5 simple forms. All of them are identical with the exception of the 'exportthis' or variable that I'm trying to pass through. They are numbered '1' to '5'. If I press the submit button for any of them only the first variable (in this case '1') is passed through. Can someone help me modify the javascript so that the right variable is passed through and not just the first one? |