JavaScript - Need Help Passing Value To Populate Sub-records
<!-- *** NEED HELP PASSING VALUE id TO POPULATE SUBRECORDS *** -->
<!-- *** See line #51 to #55 *** --> <?php session_start(); ob_start(); if($_SESSION[userdetails]->role != "Admin") { die("Access Denied!"); } require_once("includes/connect.php"); // Check if he has the right info. $sql = sprintf("SELECT * FROM members ORDER BY username ASC", $_SESSION[userdetails]->id); $query = mysql_query($sql); // You are now connected ?> <head> <html> <head> <title>Split ListBox Text To Text Boxes</title> <script type="text/javascript"> <!-- archaic format: language="javascript" --> function SplitText (info) { if (info == '') { return; } var tarr = info.split(","); document.getElementById('tBox1').value = tarr[0]; document.getElementById('tBox2').value = tarr[1]; document.getElementById('tBox3').value = tarr[2]; document.getElementById('tBox4').value = tarr[3]; } </script> </head> <body> <form name="convert"> <p style="margin: 2px"> <p><select name="Groups" style="width: 176; height: 19; border: 1px solid #C0C0C0 ; font-size: 11px; font-family:Arial" size="1" onChange="SplitText(this.value)"> <option>===Select Group===</option> <?php $sql1 = mysql_query("SELECT * FROM qw_groups"); while($r1=mysql_fetch_assoc($sql1)){ $f1 = $r1[id]; $f2 = $r1[GroupName]; echo "<option value='$f1,$f2,,'>$f2</option>"; } echo "</select>"; ?> <p><select name="GroupItems" style="width: 176; height: 19; border: 1px solid #C0C0C0 ; font-size: 11px; font-family:Arial" size="1" onChange="SplitText(this.value)"> <option>===Select Group Item===</option> <?php // **** IS IT POSSIBLE TO PASS THE VALUE "$f1" FROM GROUPS TO GROUPITEMS **** // **** I WANT TO POPULATE THE SECOND DROPDOWN LIST WITH SUB-RECORDS WITHOUT SUBMIT /POST /REFRESH /OR RELOAD **** // WHERE id = $f1 ?? maybe some java code id = $val onChange ?? $sql2 = mysql_query("SELECT * FROM qw_groupitems WHERE id = $f1"); while($r2=mysql_fetch_assoc($sql2)){ $f3 = $r2[Subid]; $f4 = $r2[GroupItem]; echo "<option value='$f1,$f2,$f3,$f4'>$f4</option>"; } echo "</select>"; ?> </p> <!-- Input selected data from listBox --> <p style="margin: 2px"> <input type="text" name="textbox1" id="tBox1" value=""><br> <input type="text" name="textbox2" id="tBox2" value=""><br> <input type="text" name="textbox3" id="tBox3" value=""><br> <input type="text" name="textbox4" id="tBox4" value=""><br> </p> </form> </body> </html> Similar TutorialsHi, I have written this program: Code: var scores=[]; function sortScores(scoreRecs){ for(i=0;i<scoreRecs.length;i++) scores.push(scoreRecs[i]); for(var i=0;i<scores.length;i++) { for(var j=i+1;j<scores.length;j++) { if(Number(scores[i])>Number(scores[j])) { tempValue=scores[j]; scores[j]=scores[i]; scores[i]=tempValue; } } } alert(scores); } sortScores(["5","6","5","7","7"]); to take an array of variables in calling the function (ie sortScores), place these variables into an empty array("scores"), apply the bubble sort to scores, and then alert scores in sorted form. When I use test values like I have above, where they are all just numbers, this program works perfectly and alerts the "scores" array, correctly sorted. However, what I would like to do is to call the function with an array of records, each containing two fields, and apply the same sort to the array of records, based on the value in the first field of each record.To illustrate, i'd like to be able to call the function thus: Code: sortScores([{sco 0,index:0},{sco 2, index:1},{sco 1,index:2}]); and for it to sort the records in descending order of the value of the "score" field. So the above call would alert: Code: [{sco 2,index:1},{sco 1,index:2},{sco 0,index:0}] however, i'm not sure how i'd reference the numeric part of the f1 of each record in the sort? Hopefully you can see what I'm trying to achieve...any ideas would be greatly appreciated. Hello, 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 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!! Resolution if interested: Code: <head> <title>Lab8</title> <script src="arrays.js" type="text/javascript"></script> <link href="css.css" rel="stylesheet" type="text/css" /> <script type="text/javascript"> function amountTotal() { var totalDonations = 0; for (var i = 0; i < amount.length; i++) { totalDonations += amount[i]; } return totalDonations; } </script> </head> <body> <table id="donations" rules="rows"> <tr> <th> Date </th> <th> Name </th> <th> Amount </th> <th> Address </th> </tr> <script type="text/javascript"> for (var i = 0; i < amount.length; i++) { if (i % 2 == 0) document.write("<tr>") else document.write("<tr class='yellowrow'>"); document.write("<td>" + date[i] + "</td>"); document.write("<td>" + firstName[i] + lastName[i] + "</td>"); document.write("<td>" + amount[i] + "</td>"); document.write("<td>" + street[i] + "<br />" + city[i] + "," + " " + state[i] + " " + zip[i] + "</td>"); } document.write("</tr>") </script> </table> <table id="totalsTable"> <tr> <th colspan="2"> Summary </th> </tr> <tr> <td> Contributions </td> <td class="amt"> <script type="text/javascript"> document.write(amount.length); </script> </td> </tr> <tr> <td> Amount </td> <td class="amt">$ <script type="text/javascript"> var totalTotal = amountTotal(); document.write(totalTotal); </script> </td> </tr> </table> </body> </html> I have a seperate .js sheet with some arrays on them (firstName, lastName, date, amount, city, state, zip) and I am trying to populate a table with these indexes. The 'yellowrow' highlights everyother row which is called out in my css sheet. My header rows fill in but not the rest. Here is the link for the site actually posted on the web. Code: <body> <table id="donations" rules="rows"> <tr> <th>Date</th> <th>Name</th> <th>Amount</th> <th>Address</th> </tr> <script type="text/javascript"> for (var i = 0; i < amount.length; i++) { if (i % 2 == 0) document.write("<tr>") else document.write("<tr class='yellowrow'>"); document.write("<td>" + date(i) + "</td>"); document.write("<td>" + firstName(i) + lastName(i) + "</td>"); document.write("<td>" + amount(i) + "</td>"); document.write("<td>" + "<br />" + city(i) + "," + state(i) + zip(i) + "</td>"); } document.write("</tr>") </script> </table> </body> I am trying to populate a listbox using Javascript. The listbox is populated using the xml response from ajax request. Below is the code used for the same Code: var xmlDoc = xmlhttp.responseXML; for (var i = 0; i < xmlDoc.getElementsByTagName("id").length; i++) { traderlists.add(new Option(xmlDoc.getElementsByTagName("name")[i].childNodes[0].nodeValue, xmlDoc.getElementsByTagName("id")[i].childNodes[0].nodeValue)); } This works fine for me. But i am facing performance issue here. some ajax requests retrieves xmls with around 11,000 nodes and this takes too much of time to populate the listbox. Can anyone please advice me with an better solution? I have a div what will contain a various number on images and i need to put all their src's into an array. Is this doable? Heres the code Code: <div id="imageHolder"> <!-- ONLY CHANGE THE SRC, NOTHING ELSE --> <div style="width:770px;height:400px;overflow-y:auto;margin-bottom:5px;"> <img src="http://wholesalepadlocks.co.uk/ebayImages/AU080.JPG" alt="" width="750" id="mainImage"/><br /><br /> </div> <img src="http://wholesalepadlocks.co.uk/ebayImages/au080a.jpg" alt="" width="240" height="120" onmouseover="Images = this.src;alert(Images)" /> <img src="http://wholesalepadlocks.co.uk/ebayImages/au080b.jpg" alt="" width="240" height="120" onmouseover="Images = this.src;alert(Images)"/> <img src="http://wholesalepadlocks.co.uk/ebayImages/AU080.JPG" alt="" width="240" height="120" onmouseover="Images = this.src;alert(Images)"/> </div>Ignore the onmouseover code i was attempting to do this but so far no luck :P hello i am trying to fire a form which after the call to retrieve the data, populate the form with the data. i can see from firebug that the json data is being captured, but cannot seem to be able to populate the form with it. i am using a jquery plugin facybox, that opens the form, but the fields are blank. i have attached my code and would be grateful if someone could tell me where i am going wrong? many thanks js code Code: <script type="text/javascript"> function edit(com, grid) { if (com == 'Edit') { if($('.trSelected').length>0){ if($('.trSelected').length>1){ alert('Please select just one row'); return; } var items = $('.trSelected'); var itemlist =''; for(i=0;i<items.length;i++){ itemlist+= items[i].id.substr(3); } $.ajax({ type: "POST", dataType: "json", url: "tempcontact.php", data: "items="+itemlist, success: function(data){ document.getElementById('id').value = data.id; document.getElementById('email').value = data.email; $("#flex1").flexReload(); } }); /*and so on then you can call facybox*/ jQuery.facybox({ div: "#editform"}); } else{ alert('Please select a row to edit.'); } } } </script> form Code: <div id="editform" style="display:none;"> <form action="conedit.php" method="post" class="webform"> <fieldset> <legend><span>Update Contact</span></legend> <br /> <div id="dataText">Please delete the fields if there is no data 'No data to display'.</div> <label for="id">ID:</label> <input id="id" name="id" class="text" type="text" value="" /> <label for="name">Full Name:</label> <input id="name" name="name" class="text" type="text" value="" /> <label for="email">Email address:</label> <input id="email" name="email" class="text" type="text" value="" /> <label for="phone">Telephone:</label> <input id="phone" name="phone" class="text" type="text" value="" /> <label for="mobile">Mobile:</label> <input id="mobile" name="mobile" class="text" type="text" value="" /> <label for="fax">Fax:</label> <input id="fax" name="fax" class="text" type="text" value="" /> <label for="notes">Notes:</label> <textarea name="notes" cols="25" rows="3"></textarea> </fieldset> <input class="submit" type="submit" name="submit" value="Update" /> </form> </div> I really need help with this. I really don't know how to make this work. I need to populate a drop down menu with a value passed through the browser if it's passed. so the browser URL will look like: domain.com/?referer=YellowPagesOnline I need to capture the referer value from the browser store it into a cookie. If the cookie is set and then populate the drop down on the page with the cookie. If it's not set then a list of sources should appear. So I already have the code to grab the string and store it in a cookie but I'm not sure how to do the initialization of the drop down with the cookie value. This is what I have... Code: <script> //Get the referer string out of the URL function getQuerystring(key, default_) { if (default_==null) default_=""; key = key.replace(/[\[]/,"\\\[").replace(/[\]]/,"\\\]"); var regex = new RegExp("[\\?&]"+key+"=([^&#]*)"); var qs = regex.exec(window.location.href); if(qs == null) return default_; else return qs[1]; } //Set the cookie for 30 days function SetCookie(cookieName,cookieValue,nDays) { var today = new Date(); var expire = new Date(); if (nDays==null || nDays==0) nDays=1; /* expire.setTime(today.getTime() + 3600000*24*nDays);*/ expire.setTime(today.getTime() + (1000 * 60 * 60 * 24 * 30)); document.cookie = cookieName+"="+escape(cookieValue) + ";expires="+expire.toGMTString(); } //Put the cookie on the user's computer function putcookie() { var val = getQuerystring('referer'); if(val !=""){ if (document.cookie.length == 0) { SetCookie('referer', val, 1); alert(val); } } alert(document.cookie); } putcookie(); getCookie(name); //If there is a cookie then get the cookie function getCookie(c_name) { if (document.cookie.length>0) { c_start=document.cookie.indexOf(c_name + "="); if (c_start!=-1) { c_start=c_start + c_name.length+1; c_end=document.cookie.indexOf(";",c_start); if (c_end==-1) c_end=document.cookie.length; if(document.SECatJax.referer.length > 0) { document.SECatJax.referer.value = unescape(document.cookie.substring(c_start,c_end)); return false; } alert(document.cookie); } } document.SECatJax.referer.value = 'Website'; } The dropdown to appear if there isn't a cookie is Code: <select name="source_code" size="1" id="source_code" class="select_2" style="display:none"> <option value="" selected="selected">--</option> <option value="Direct Mail">Direct Mail</option> <option value="High School Presentation">High School Presentation</option> <option value="Search Engine">Internet Search</option> <option value="Newspaper">Newspaper</option> <option value="Poster">Poster</option> <option value="Radio">Radio</option> <option value="Referral">Referral</option> <option value="TV">TV</option> <option value="Yellow Pages">Yellow Pages</option> </select> The drop down to appear if there is a cookie is[CODE]<select name="source_code2" size="1" id="source_code2" class="select_2" style="display:none"> <option value="YellowPagesOnline" selected="selected">YellowPagesOnline</option> </select>[CODE] Can someone help me with this please? Thanks. I have a check box right now that calls an onClick event. Here is the Input: Code: <input name="usePad" type="checkbox" value="usePad" id="usePad" onclick="showBind('padShow','padOk')" /> Here is the Script: Code: var xmlhttpshowBind; var showBindDiv; function showBind(BindPage,BindDiv) { xmlhttpshowBind=GetXmlHttpObject(); if (xmlhttpshowBind==null) { alert ("Browser does not support HTTP Request"); return; } var url="/scripts/"+BindPage+".php"; showBindDiv=BindDiv; xmlhttpshowBind.onreadystatechange=showBindGet; xmlhttpshowBind.open("GET",url,true); xmlhttpshowBind.send(null); } function showBindGet() { if (xmlhttpshowBind.readyState==4) { document.getElementById(showBindDiv).innerHTML=xmlhttpshowBind.responseText; } } It works great to fill the div called for, but I would like it to remove the div contents if it's unchecked, I'm not sure how to do this?? Any help would be appreciated! Thank you in advance! Hello guys, How to populate array from dropdownlist? I've tried like this var array = new array(); var d = document.getElementById("DropDownListl"); for (var i = 0; i < d.options.length; i++) { array[i] = d.options[i].value; } Thank you Need help with a loop to populate links menu from external page. I am trying to auto populate a links menu from an external page without manually changing them. My menu has 12 categorys and I would like to retreive 4 links in each category from an external page, selecting a category brings up a page with 4 to 10 links in the selected category. In the code below category number1 has been selected. please help me with a loop to auto populate the links in 12 categorys with 4 links each...even if only one category is populated after manual category selection would still be a big help. Thanks Code: /* ---------------------------------------external articles------------------------------ */ /* -------------item/category selection 1 thru 12 --------------------*/ <td class="num">1.</td><td class="selected">num1</td></tr> <tr><td class="num">2.</td><td><a href="">selected page link</a></td></tr> <tr><td class="num">3.</td><td><a href="">selected page link</a></td></tr> <tr><td class="num">4.</td><td><a href="">selected page link</a></td></tr> <tr><td class="num">5.</td><td><a href="">selected page link</a></td></tr> <tr><td class="num">6.</td><td><a href="">selected page link</a></td></tr> <tr><td class="num">7.</td><td><a href="">selected page link</a></td></tr> <tr><td class="num">8.</td><td><a href="">selected page link</a></td></tr> <tr><td class="num">9.</td><td><a href="">selected page link</a></td></tr> <tr><td class="num">10.</td><td><a href="">selected page link</a></td></tr> <tr><td class="num">11.</td><td><a href="">selected page link</a></td></tr> <tr><td class="num">12.</td><td><a href="">selected page link</a> /* -------------end item/category selection 1 thru 12 --------------------*/ /* ---------------------------external page with news atricles--------------- */ <b>News Articles</b> <div class="msc-result"> <div class="ms-newsResult ms-result"> <div class="ms-title"><a target="_blank" class="ms-title" href="http://www.xyz.com">bla bla:<b>keyword</b>short description</a></div> <div class="ms-publisher">xyz News</div> <div class="ms-publishedDate"> - Aug 05, 2011</div> <div class="ms-relativePublishedDate"> - 8 hours ago</div> <div class="ms-snippet">headline<b>keyword</b>description text<b>...</b></div> <div class="ms-watermark"><a target="_blank" class="ms-watermark" href="http://xyz.com/faq.html">clipped from my articles - 8/2011</a></div></div></div> <div class="msc-result"> <div class="ms-newsResult ms-result"> <div class="ms-title"><a target="_blank" class="ms-title" href="http://www.xyz.com">bla bla: <b>keyword</b>short description</a></div> <div class="ms-publisher">xyz News</div> <div class="ms-publishedDate"> - Aug 05, 2011</div> <div class="ms-relativePublishedDate"> - 8 hours ago</div> <div class="ms-snippet">headline<b>keyword</b>description text<b>...</b></div> <div class="ms-watermark"><a target="_blank" class="ms-watermark" href="http://xyz.com/faq.html">clipped from my articles - 8/2011</a></div></div></div> <div class="msc-result"> <div class="ms-newsResult ms-result"> <div class="ms-title"><a target="_blank" class="ms-title" href="http://www.xyz.com">bla bla: <b>keyword</b>short description</a></div> <div class="ms-publisher">xyz News</div> <div class="ms-publishedDate"> - Aug 05, 2011</div> <div class="ms-relativePublishedDate"> - 8 hours ago</div> <div class="ms-snippet">headline<b>keyword</b>description text<b>...</b></div> <div class="ms-watermark"><a target="_blank" class="ms-watermark" href="http://xyz.com/faq.html">clipped from my articles - 8/2011</a></div></div></div> <div class="msc-result"> <div class="ms-newsResult ms-result"> <div class="ms-title"><a target="_blank" class="ms-title" href="http://www.xyz.com">bla bla: <b>keyword</b>short description</a></div> <div class="ms-publisher">xyz News</div> <div class="ms-publishedDate"> - Aug 05, 2011</div> <div class="ms-relativePublishedDate"> - 8 hours ago</div> <div class="ms-snippet">headline<b>keyword</b>description text<b>...</b></div> <div class="ms-watermark"><a target="_blank" class="ms-watermark" href="http://xyz.com/faq.html">clipped from my articles - 8/2011</a></div></div></div> <div class="msc-result"> <div class="ms-newsResult ms-result"> <div class="ms-title"><a target="_blank" class="ms-title" href="http://www.xyz.com">bla bla: <b>keyword</b>short description</a></div> <div class="ms-publisher">xyz News</div> <div class="ms-publishedDate"> - Aug 05, 2011</div> <div class="ms-relativePublishedDate"> - 8 hours ago</div> <div class="ms-snippet">headline<b>keyword</b>description text<b>...</b></div> <div class="ms-watermark"><a target="_blank" class="ms-watermark" href="http://xyz.com/faq.html">clipped from my articles - 8/2011</a></div></div></div> /* ---------------------------------------end external articles------------------------------ */ /* -----------------display links page (ms publisher) will be link text---------------- */ /* -----------------Category is num1 thru 12 selection at top---------------- */ <div id="my_menu"> <ul> <li><a href=""><img src=""; /> </a></li> <ul></ul> <li><a href="#">Article category / keyword</a> <ul> <li><a href="" target="news">link text</a></li> <li><a href="" target="news">link text</a></li> <li><a href="" target="news">link text</a></li> <li><a href="" target="news">link text</a></li> </ul> </li> <li><a href="#">Article category / keyword</a> <ul> <li><a href="" target="news">link text</a></li> <li><a href="" target="news">link text</a></li> <li><a href="" target="news">link text</a></li> <li><a href="" target="news">link text</a></li> </ul> </li> <li><a href="#">Article category / keyword</a> <ul> <li><a href="" target="news">link text</a></li> <li><a href="" target="news">link text</a></li> <li><a href="" target="news">link text</a></li> <li><a href="" target="news">link text</a></li> </ul> </li> <li><a href="#">Article category / keyword</a> <ul> <li><a href="" target="news">link text</a></li> <li><a href="" target="news">link text</a></li> <li><a href="" target="news">link text</a></li> <li><a href="" target="news">link text</a></li> </ul> </li> !-- END MENU HTML--> </div> <div id="contentContainer"> </div> Thanks I have a page where a user can enter info into a text box named (usertext). Below the box I have a link that takes the user to another page. This page is just a test page for proof of concept. I am wondering if there is a way that I can dynamically populate a variable located within the url of my link. The info that will populate the variable will be whatever the user types into the text box. For example my link will be <a href="nextpage.cfm?textvariable='#usertext#'> So when the user clicks this link, it goes to the next page already populated by the value of the info the user typed into the text box. I am thinking javascript will be involved, but I am not really sure. I am using coldfusion 8. Total newbie, I (almost) know just basic HTML. I have my own website and I'm trying to find out how to make a popup window work from clicking on a part link in a parent window table so that my clients can make an inquiry. I have about 300 parts on 10 pages total and would like it to be something I can just enter the new varibles on the parent page and the code takes care of the rest. I would like the popup to have the part info as a variable from the table as a variable in the inquiry page header and also part description as a variable the hidden subject line. I have included the code I already have and I'm looking for the script to bring it all together. Example for header may read "Part 1" for example and the hidden subject variable to read "0001 Part 1 $20" for example. I hope this is possible and I hope I made sense. I really need help me with this. Parent page Code: <head> <meta http-equiv="Content-Type" content="text/html; charset=windows-1252"> <title>Parts Page</title> <link rel="stylesheet" type="text/css" href="../styles.css" /> <style type="text/css">body{font-family: Verdana, sans-serif;font-size: 14px;font-style: normal;line-height: normal;font-weight: normal;color: #000000;}</style> </head> <body> <div align="center"><table width="90%" style="border-collapse:collapse;" border="1" cellpadding="2"> <tr><td width="15%"><h2 align="center">Item #</h2><p align="center">Click to inquire</p></td> <td width="60%"><h2 align="center">Description - Used OEM Parts*</h2><p align="center">*Unless described differently</p></td> <td width="15%" valign="top"><h2 align="center">Coverage</h2><p align="center">*Sorted by Year</p></td> <td width="10%" valign="top"><h2 align="center">Price</h2></td></tr> <tr><td align="center"><a href="mailto:myemail@myweb.com?subject=0001 - My Part 1 - $20"><font size="2">0001</font></a></td><td align="left"><font size="2">My part 1</font></td><td align="center"><font size="2">1960-61</font></td><td align="center"><font size="2">$20</font></td></tr> <tr><td align="center"><a href="mailto:myemail@myweb.com?subject=0002 - My Part 2 - $25"><font size="2">0002</font></a></td><td align="left"><font size="2">My part 2</font></td><td align="center"><font size="2">1960-61</font></td><td align="center"><font size="2">$25</font></td></tr> </table></div> </body> Popup window Code: <head> <meta http-equiv="Content-Type" content="text/html; charset=windows-1252"> <title>Parts Inquiry</title> <link rel="stylesheet" type="text/css" href="../styles.css" /> <style type="text/css">body{font-family: Verdana, sans-serif;font-size: 14px;font-style: normal;line-height: normal;font-weight: normal;color: #000000;}</style> </head> <body> <form action="http://www.myweb.com/cgi/FormMail.pl" method="post"> <input type="hidden" name="recipient" value="myemail@myweb.com" /> <input type="hidden" name="subject" value="variable 2" /> <input type="hidden" name="redirect" value="http://myemail@myweb.com/used_parts/thank_you6.html" /> <input type="hidden" name="required" value="realname, email" /> <input type="hidden" name="env_report" value="REMOTE_HOST, HTTP_USER_AGENT, REMOTE_USER, REMOTE_ADDR " /> <div align="center"><table width="90%" border="0"> <tr><td align="center"><h1>variable 1</h1> <p align="center"><font size="2" color="#FF0000">"*" Indicates required field.</font></p> <p><font>Fill out the form below to find out more about this this part.</font></p> </td></tr></table></div> <div align="center"><table width="50%" border="2" bgcolor="#99CCFF"> <tr><td align="right" width="50%"><font color="#FF0000">*</font>Your Name : </td> <td align="left" width="50%"><input type="text" size="35" maxlength="256" name="realname" /></td></tr> <tr><td align="right" width="50%"><font color="#FF0000">*</font>Email Address : </td> <td align="left" width="50%"><input type="text" size="35" maxlength="256" name="email" /></td></tr> <tr><td align="right" width="50%">Phone Number : </td> <td align="left" width="50%"><input type="text" size="14" maxlength="256" name="Phone" /></td></tr> <tr><th colspan="2">Please type your question(s) in the space below: <textarea name="Question(s)" rows="5" cols="70"></textarea></th></tr></table></div><br /> <div align="center"><table width="90%" border="0"> <tr><td align="center"> <input type="submit" value="Submit Form" /> <input type="reset" value="Clear Form" /> </td></tr></table></div></form> </body> I also have some parameters for the desired popup window size and position. Code: width=625,height=450,left=275,top=100,resizable=no,status=no,toolbar=no,menubar=no,location=no'); Any other suggestions for the popup window parameters would be welcome! Thanks, John Hi, I'm new to Javascript and need to help with something, I'll try and explain this as best as I can but feel free to ask questions if it doesn't make sense. I'm basically building a javascript/html calculator but I need the calculation to appear gradually in a table, the table need to be 3 columns accross and add a row each time a calculation button is pressed, the first column can remain blank for now but will need to contain a text field eventually, second column needs to show the calculation symbol, third column shows the number. Here's an example: 4+2+7-5=8 |Blank| | 4 | |Blank| + | 2 | |Blank| + | 7 | |Blank| - | 5 | |Blank| = | 8 | Here's the code I have so far so you can get a feeling of what it looks like, this table need to go into the area div and will replace what is currently the 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> <title>Sample Widget</title> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> <link href="basic.css" rel="stylesheet" type="text/css" /> <script type="text/javascript" src="basic.js"></script> <meta name="generator" content="Nokia WRT extension for Visual Studio 2.0" /> <script type="text/javascript" language="javascript"> function UpdateInput(a, b) { var MyElement = document.getElementById("Input"); MyElement.innerHTML = MyElement.innerHTML + a; var MyElement = document.getElementById("Area"); MyElement.innerHTML = MyElement.innerHTML + b; } function Calculate() { var result = eval(document.getElementById("Input").innerHTML); var total = document.getElementById("Total"); total.innerHTML = result; var MyElement = document.getElementById("Area"); MyElement.innerHTML = MyElement.innerHTML + '<br>=' + result; } </script> </head> <body onLoad="init()"> <div id="Main"> <table cellpadding="0" cellspacing="0" width="100%"> <div id="Area"> </div> </table> <table cellpadding="0" cellspacing="0" width="100%"> <tr> <td class="style1">Total:</td> <td> <div id="Total"></div> </td> </tr> <tr> <td colspan="2"> <div id="Input"></div> </td> </tr> </table> <table cellpadding="0" cellspacing="0"> <tr> <td><img src="Images/plus.png" onclick="UpdateInput('+','<br>+')" /></td> <td><img src="Images/minus.png" onclick="UpdateInput('-','<br>-')" /></td> <td><img src="Images/times.png" onclick="UpdateInput('*','<br>*')" /></td> <td><img src="Images/divide.png" onclick="UpdateInput('/','<br>/')" /></td> </tr> <tr> <td><img src="Images/7.png" onclick="UpdateInput(7,7)" /></td> <td><img src="Images/8.png" onclick="UpdateInput(8,8)" /></td> <td><img src="Images/9.png" onclick="UpdateInput(9,9)" /></td> <td><img src="Images/percent.png" onclick="UpdateInput('%','<br>%')" /></td> </tr> <tr> <td><img src="Images/4.png" onclick="UpdateInput(4,4)" /></td> <td><img src="Images/5.png" onclick="UpdateInput(5,5)" /></td> <td><img src="Images/6.png" onclick="UpdateInput(6,6)" /></td> <td><img src="Images/oneoverx.png" /></td> </tr> <tr> <td><img src="Images/1.png" onclick="UpdateInput(1,1)" /></td> <td><img src="Images/2.png" onclick="UpdateInput(2,2)" /></td> <td><img src="Images/3.png" onclick="UpdateInput(3,3)" /></td> <td><img src="Images/plusminus.png" /></td> </tr> <tr> <td><img src="Images/0.png" onclick="UpdateInput(0,0)" /></td> <td><img src="Images/dot.png" onclick="UpdateInput('.','.')" /></td> <td><img src="Images/equals.png" onclick="Calculate()" /></td> <td><img src="Images/sub.png" /></td> </tr> </table> </div> </body> </html> I have two slightly different forms on the same page, but I want the values in form1 to auto populate the same form fields in form2. 1 field is a text field, the rest are drop down menus. How would I accomplish this? Link to tutorial would be much appreciated. Thanks
Hi All, My first question on this forum. I have a form where we are capturing the Members Children information. I want to insert age in years to a field within this table by calculating age from Date of Birth (DOB). DOB format is mm/dd/yyyy and is a datetime data type in SQL. The DOB is added by the member while registering their child. Is there an onchange script that I could use here. Is it possible to auto populate a field from an other field within the same form?? Does anyone have any code samples that I could use?? Any pointers will be greatly appreciated. Thanks Vinny I have a table where when the cursor passes/hovers over a cell, the current cell, as well as the top cell in its column and the first cell in its row change backgroundColor. I have text fields outside the table which I want to populate with the contents of the cells affected by the mouseover event. So as the mouse moves over different cells, the contents of the text fields changes accordingly. I've got the backgroundColor to change, but when I try to assign the contents of the cells to the text fields, nothing happens. The change of backgroundColor even stops working. This is the code I'm usign to populate the fields. Code: document.getElementById("tableID").textfieldID.value = Col1Cell[0].innerHTML; document.getElementById("tableID").textfieldID.value = HeaderCell[n].innerHTML; document.getElementById("tableID").textfieldID.value = this.innerHTML; I'm traversing through the <th> and <td> tags to find the header cell HeaderCell[n] and first column cell Col1Cell[0] associated with the current cell. If I leave out these lines the backgroundColor changes, if I use them, nothing happens at all. Can't figure out why. Any suggestions? Hi, How can I auto populate the data by dropdown selected? and my dropdown result already appear as well, the code as following: PHP Code: <?php echo '<tr> <td>'.$customer_data.'</td> <td><select name="customer_id">'; foreach ($customers as $customer) { if ($customer['customer_id'] == $customer_id) { echo '<option value="'.$customer['customer_id'].'" selected="selected">'.$customer['name'].'</option>'; } else { echo '<option value="'.$customer['customer_id'].'">'.$customer['name'].'</option>'; } } echo '</select> </td> </tr>'; ?> and the result of dropdown above listed as admin customer1 FREE loaded from following db PHP Code: INSERT INTO `my_customer` (`customer_id`, `name`, `firstname`, `lastname`) VALUES (8, 'admin', '', ''), (6, 'customer1', 'ok', ''), (7, 'FREE', 'marj', 'om'); so whenever dropdown selected i want the all data below: PHP Code: <tr> <td><?php echo $firstname; ?></td> <td><?php echo $lastname; ?></td> </tr> also auto populate, it seem need javascript/ajax/jquery to fixed it, I was Wondering if someone could help me, and thanks in advance Hi. I am not sure if this has been answered to other posts but I tried to search and I can't find the right answer for my problem. I am trying to learn javascript for my self and can't figure out my self. Actually this is the same like the pop-up calendar but the only difference is I don't want numbers, I need a list of options so user can choose and when they select, it will transfer to the textbox right away like the calendar. I have a form and trying to use a pop-up window to select an option then transfer the option selected to show on the textbox. I have 10 textboxes and all of them has a "Select" button to pop-up the option list. BTW, the "SELECT" button will populate the same option list. Here is my html code: Code: <select id="droplist" name="droplist" size="1" > <option>Click to select...</option> <?php foreach ($designation_list as $descode => $prompt) : ?> <option <?php echo helper_selected($prompt == $form['droplist']); ?> value="<?php echo $prompt; ?>" style="width:500"><?php safeEcho($prompt); ?> </option> <?php endforeach; ?> </select> below is my array: PHP Code: <?php $designation_list = array( "00111" =>"Aloha of the Pacific/Transfer Assistance Program for High Income Students", "71122" =>"Aloha", "71231" =>"Free Housing Information", "71232" => "Drama Queen and King", "98765" => "Aloha Boy Home of the Land", "12345" => "Aloha Home", ); I wanted to use the option list over and over again for the 10 textboxes. Is that possible? Below is my sample code but didn't work. Please help.... Code: //javascript var testpopup5 = new PopupWindow("testdiv5"); testpopup5.offsetX=-20; testpopup5.offsetY=20; testpopup5.autoHide(); var testpopup5input=null; testpopup5.populate('<select>Select: <select name="sel" id="sel" onChange="testpopup5pick(this.options[this.selectedIndex].value);"><OPTION VALUE="A">A</option> <OPTION VALUE="B">B</option><OPTION VALUE="C">C</option></SELECT>'); function test5popupactivate(obj,anchor) { testpopup5input=obj; testpopup5.showPopup(anchor); } function testpopup5pick(val) { testpopup5input.value = val; testpopup5.hidePopup(); } //html <INPUT NAME="test5" SIZE=30 id="I"> <A HREF="#sel" onClick="test5popupactivate(document.getElementById['I'].test5,'anchor5');return false;" NAME="anchor5" ID="anchor5">Select</A> <DIV ID="testdiv5" STYLE="position:absolute;visibility:hidden;background-color:#CCCCCC;width:200px;height:50px;"></DIV> As you can see I get this code from somewhere else but it doesn't work on me. Is there an easy way to do it? Please help. Thanks in advance. |