JavaScript - How To Scrape Hidden Text Displayed By Javascript ?
Is it possible to scrape displayed text you can't find in html source code ?
The text shows up only when you click a link, but is still not visible in source code. That link has got a userid and is used as a variable in function ShowUserPhone(userid). If someone knows how to solve this mystery, please help. I added http://www.mediafire.com/file/9eo72u...wUserPhone.txt file as available .js source linked to that smart page. I've also put some comments there about URL original location. Here is the main function where the process started I guess: Code: function ShowUserPhone(userid){ var UserPhoneLink=document.getElementById("UserPhoneLink"); var UserPhone = document.getElementById("UserPhone"); if(document.images){ (new Image()).src="/pp-owners-list-click-counter.asp?UserId="+escape(userid)+"&counterType=detailsphone"; } if (UserPhoneLink){ UserPhoneLink.style.display="none"; } if (UserPhone){ UserPhone.style.display="block"; } } Please help. Similar TutorialsHello, I am fairly new to javascript so patience is appreciated. I have some javascript I need to execute that is located in an SSI footer. The purpose of the code is to find out what domain the page was loaded at and then to tailor some links to match. Because of how the hosting environment is set up (which I have no control over) when the links don't match the domain they aren't included. I also have to use a complete url (as opposed to relative url) because the footer is included in many different web pages. The problem is that the code is executed but it also is displayed as plain text in firefox. The test site is http://test.ci.edina.mn.us Help! The code is: Code: <script type="text/javascript"> var domainName, strOut; domainName = document.domain; strOut = '<link rel="stylesheet" type="text/css" href="http://' + domainName + '/js/jquery.fancybox/jquery.fancybox.css" media="screen" />'; document.write(strOut); strOut = '<script src="http://' + domainName + '/js/jquery-1.3.2.min.js" type="text/javascript"></script>'; document.write(strOut); strOut = '<script src="http://' + domainName + '/js/jquery.fancybox/jquery.fancybox-1.2.1.js" type="text/javascript"></script>'; document.write(strOut); strOut = '<script src="http://' + domainName + '/js/jquery.easing.1.3.js" type="text/javascript"></script>'; document.write(strOut); </script> Hello, My goal is to show a series of embedded youtube videos on one page but allowing the user to hide or show any youtube video by clicking a button associated with a specific youtube video on the page. I made a form that submits the youtube embed code to a mysql database and I created a php file to retrieve every embed code using a for loop. For each iteration of the for loop, a youtube video will pop up with a corresponding button which will allow the user to hide or show the youtube video. It works when there is only one entry in the mysql table but does not work when more youtube embed codes are uploaded. For example, when there are two youtube embed codes uploaded, two buttons are created, but when I click either of the two buttons, it will only show or hide the first youtube embed. None of the buttons will show the second youtube video. Here is my code: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html> <head> <title>hide/show iframe</title> <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"/> <style type="text/css"> <!-- #frDocViewer { width:70%; height:50%; display:none; } --> </style> <script type="text/javascript"> <!-- function HideFrame() { var fr = document.getElementById ("frDocViewer"); if(fr.style.display=="block") { fr.style.display="none"; } else { fr.style.display="block"; } } //--> </script> </head> <body> <?php mysql_connect ("","","") or die(mysql_error()); mysql_select_db ("") or die(mysql_error()); $lastid = mysql_query ("SELECT * FROM embed ORDER BY id DESC LIMIT 1"); $lastid = mysql_fetch_assoc($lastid); $lastid = $lastid['id']; for ($count=1; $count<= $lastid ; $count++) { $iframe = mysql_query ("SELECT * FROM embed WHERE id=$count "); $iframe = mysql_fetch_assoc($iframe); $iframe = $iframe['url']; echo " <img src='utube.gif' onclick='HideFrame()' /> <div id='frDocViewer'> $iframe </div> "; } ?> </body> </html> thanks in advance Hello, I use a iplocator api, which is javascript and gives out the city name, country and zipcode output PHP Code: <script language="JavaScript" src="http://www.somesite.com/somefile.js?key=apikey"></script> <script language="JavaScript"> <!-- document.write(ip2location_isp() + ', ' + ip2location_city() + ', ' + ip2location_zip_code() + ', ' + ip2location_net_speed()); //--> </script> my question or where i need help is that, i would like to output each of those as a hidden text field, so later i can store into mysq database with POST method from the hidden field. thank you in advance for your time n help Hello, I'm looking for help as I have the jCarouselLite feature functioning on my website and am looking for a way of displaying another image to the right of the carousel, dependent upon which image is visible in the carousel. I toyed with the idea of implementing another snippet of JavaScript to swap the text to the right and manually synching the swap time wise, but quickly abandoned this idea for a number of reasons, particularly as the carousely has buttons to scroll through the images displaying. I have to admit I'm not particularly great with JavaScript, but was thinking along the lines of another function that listens for the image that is displayed, but have no idea if am way off the mark, or even if this is the right track - no idea how to implement. Any help would be very gratefully recieved. Thanks, Matt I'm coding a simple random sentence generator & this is the beginning part of what I'm trying to accomplish. I created 3 different functions with 3 separate buttons & 3 separate text areas to display the noun, verb, or article once the button is pressed. However, when I press a button, nothing shows up in the text area! Can someone please tell me what I'm doing wrong & give me a fix? It has to be a simple problem, but I am very very new to this & need help. Thanks in advance! Code: <?xml version="1.0" encoding="ISO-8859-1"?> <!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 language="JavaScript"> function noun() // Assumes: nothing // Returns: a random noun { return RandomOneOf(["man", "woman", "ball"]); } </script> <script language="JavaScript"> function verb() // Assumes: nothing // Returns: a random noun { return RandomOneOf(["hit", "liked", "smelled"]); } </script> <script language="JavaScript"> function article() // Assumes: nothing // Returns: a random noun { return RandomOneOf(["the", "a", "some"]); } </script> </head> <body> <input type="button" value="Noun" onclick="document.getElementById('OutNoun').value = noun();" /> <TEXTAREA ID="OutNoun" ROWS=1 COLS=15 WRAP VALUE=""></TEXTAREA> <input type="button" value="Verb" onclick="document.getElementById('OutVerb').value = verb();" /> <TEXTAREA ID="OutVerb" ROWS=1 COLS=15 WRAP VALUE=""></TEXTAREA> <input type="button" value="Article" onclick="document.getElementById('OutArticle').value = article();" /> <TEXTAREA ID="OutArticle" ROWS=1 COLS=15 WRAP VALUE=""></TEXTAREA> </body> </html> Good Day, I am very new to JavaScript and I am working on an assignment that is almost finished, but I have a problem getting the result to work. When I enter the two values and then hit submit, nothing is returned. I am guessing that either my code is incorrect or I have used the wrong ids maybe. Basically, the user enters 2 parameters (hourly wage and hours worked) and the first function turns the parameters into the gross pay (depends on if the hours are standard pay or if overtime is involved). The second function takes the gross pay and does the tax amounts for local, state and federal. Then it adds all taxes to give a total of tax amount paid. The input for the parameters is done by <input> tag. The return reslut is supposed to be just the number which is the total amount of taxes to be taken out. This all has to be done by <input> tags. Could someone look over the html and JS and help me find where the problem is at. The instructor said we could use ? : operator for determining the pay rates, but I found it easier to do if/else staements because I was not sure how you would script that. Any help would be great. Thanks HTML Code Code: <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> <title>Calculate Tax Amount</title> <link href="style.css" rel="stylesheet" type="text/css"> <script type="text/javascript" src="calculateGross.js"></script> <script type="text/javascript" src="calculateTax.js"></script> </head> <body> <table width="60%" border="0" cellpadding="0" cellspacing="2" align="center" class="view"> <tr> <td colspan="3" class="textview">Calculate the gross pay:</td> </tr> <tr> <td class="labeltext">Pay rate(dollars per hour)</td> <td>:</td> <td><input type="text" name="payrate" id="payrate" class="textval"></td> </tr> <tr> <td class="labeltext">Hours worked</td> <td>:</td> <td><input type="text" name="hours" id="hours" class="textval"></td> </tr> <tr> <td colspan="3" align="center"><input type="button" name="" value="Submit" onclick="return calculate(); "> </td> </tr> </table> <br> <br> <table width="60%" border="0" cellpadding="0" cellspacing="2" align="center" class="view"> <tr> <td colspan="3" class="textview">Total Tax Paid:</td> <tr> </tr> <td class="labeltext">Grand Total of Taxes</td> <td>:</td> <td><input type="text" name="total" id="totalTax" class="textval" disabled="disabled"></td> </tr> </table> </body> </html> First Function JS Code: function calculate() { var payRate = document.getElementById("payrate").value; var hoursWorked = document.getElementById("hours").value; var oTime; var oPay; var oHour; var grossPay; if(hoursWorked > 40) { oTime = Number ( hoursWorked ) - 40; oPay = Number ( ( payRate ) * 1.5 ) * oTime; oHour = Number ( hoursWorked )- Number ( oTime ); grossPay = Number ( payRate ) * Number ( oHour ) + Number ( oPay ); } else grossPay = Number ( hoursWorked ) * Number ( payRate ); } The second function JS Code: function calculateTax(gross) { var gross; var localTax; var localTaxBal; var stateTax; var stateTaxBal; var fedTax; var fedTaxBal; var totalTax; localTax = Number ( gross ) * 2/100; localTaxBal = Number ( gross ) - Number ( localTax ); stateTax = Number ( localTaxBal ) * 8/100; stateTaxBal = Number ( localTaxBal ) - Number ( stateTax ); fedTax = Number ( stateTaxBal ) * 31/100; fedTaxBal = Number ( stateTaxBal ) - Number ( FedTax ); totalTax = Number ( localTax.toFixed(2) ) + Number ( stateTax.toFixed(2) ) + Number ( fedTax.toFixed(2) ); return totalTax.toFixed(2); } Hi I have the following code. What I want to do is for certain questions to remain hidden inless certain conditions are met, then they appear to be answered. I am thinking with the <div> but not sure how. I also thought maybe with css but cant write a if statement in css so that a no go. Please help. Code: <tr><td align="left">Do you own a Yorkie?<br /> <input type="radio" name="owner" value="yes" /> Yes <input type="radio" name="owner" value="no" checked="checked" /> No<br /> <!-- If answer is no above the below questions are hidden, if yes then they appear -->> <div id="breeders"> How many? <select name="qnty" size="1"> <option value="1">1</option> <option value="2">2</option> <option value="3">3</option> <option value="4">4</option> <option value="5">5+</option></select> Are you a breeder? <input type="radio" name="breeder" value="yes" checked="checked" /> Yes <input type="radio" name="breeder" value="no" /> No</div></td></tr> JavaScript Code: I am using a onload within the form opening tag Code: function showDiv() { if(document.forms[2].owner.value == "yes") { document.getElementById('breeders').style.visibility = 'visible'; } else document.getElementById('breeders').style.visibility = 'hidden'; } I need for the form to do the following: when age is greater than or equal to 65 enter "yes" in the hidden field when age is less than 65 enter "no" in the hidden filed return true Create a page processAge.htm that Writes the message on the page Hi name. At age # you may retire. or Hi name. At age # you are not ready to retire. Get to work. name is the name entered on the form. # is the age entered on the form. Java: Code: <script type="text/javascript"> /* <![CDATA[ */ function validateSubmission() { var retValue = true; if (document.forms[0].name.value == "") { window.alert("You did not fill in one of the following required fields: Name or Age."); retValue = false; } } function checkForNumber(fieldValue) { var numberCheck = isNaN(fieldValue); if (numberCheck == true) { window.alert("You must enter a numeric value!"); return false; } } /* ]]> */ </script> Body: Code: <form action="processAge.htm" method="get" onsubmit="makeList(); return validateSubmission(); "> <table frame="border" rules="cols" > <tr> <td valign="top"> <h2>Retirement</h2> <p>Name<br /> <input type="text" name="name" size="40" /></p> <p>Age<br /> <input type="text" name="age" size="40" onchange="return checkForNumber(this.value);" /></p> <p style="text-align: center"><input type="submit" value="Send" /><input type="reset" /> <input type="hidden" name="Retirement" /></p> </td></tr> </table> </form> Process Page: Code: <script type="text/javascript"> /* <![CDATA[ */ document.write("<h1>Your form has been submitted!</h1><h2>You entered the following data:</h2>"); 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 />"); } /* ]]> */ </script> Thanks for any help! Hi guys, I have a javascript drop-down navigation bar on my website. While I am creating the website, the drop-down have no problem overlaying the javascript (embed with flash) photo gallery in Firefox. But when I tested it in IE, it did not overlay the javascript script and the drop-down was covered by the photo gallery instead. I tried methods like Z-index, using Div etc but it still doesn't work on Internet Explorer. I tested on Safari, Opera and Firefox doesn't seem to have any problem. Here is my links to my CSS use for my website. Really need help, have no idea what I did wrong. Can anyone advise me what to do? Thank you so much!!!! Much appreciated!!! Working Website: http://17thstop.sg/demo CSS Files: http://17thstop.sg/demo/styles.css http://17thstop.sg/demo/css/default.advanced.css http://17thstop.sg/demo/css/default.css http://17thstop.sg/demo/css/dropdown.css 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"> <!-- #BeginTemplate "index.dwt" --> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <link rel="stylesheet" href="styles.css" type="text/css" /> <link rel="shortcut icon" href="favicon.ico" ></link> <link rel="icon" type="image/gif" href="animated_favicon1.gif" ></link> <title>Four Musketters Studio</title> <script type="text/javascript" src="gallery/swfobject.js"></script> <!-- Menu CSS and JS --> <link href="css/dropdown.css" media="screen" rel="stylesheet" type="text/css" /> <link href="css/default.advanced.css" media="screen" rel="stylesheet" type="text/css" /> <!--[if lt IE 7]> <script type="text/javascript" src="js/jquery/jquery.js"></script> <script type="text/javascript" src="js/jquery/jquery.dropdown.js"></script> <![endif]--> <!-- End of Menu and JS --> </head> <body> <div id="content"> <h1><a href="index-blueprint.htm"><span>Four Musketeers</span> Studio</a></h1></div> <!-- Start of Menu --> <div id="contentmenu"><ul id="nav" class="dropdown dropdown-horizontal"> <li><a href="index.htm">Home</a></li> <li class="dir">About Us <ul> <li><a href="about_us.htm">The Four Musketters</a></li> <li class="dir">The Team <ul> <li><a href="darren.htm">Darren</a></li> <li><a href="jon.htm">Jonathan</a></li> <li><a href="hweek.htm">Hwee Key</a></li> <li><a href="gavin.htm">Gavin</a></li> </ul> </li> <li><a href="./">Clients</a></li> <li><a href="./">Testimonials</a></li> <li><a href="./">Press</a></li> <li><a href="./">FAQs</a></li> </ul> </li> <li class="dir">Services <ul> <li><a href="cne.htm">Event & Commercial Photography</a></li> <li><a href="portrait.htm">Portrait Photography</a></li> <li><a href="wedding.htm">Wedding Photography</a></li> <li><a href="studio.htm">Rental of Studio</a></li> <li><a href="./">Training & Consulting</a></li> </ul> </li> <li><a href="gallery3/gllery.htm">Gallery</a></li> <li><a href="./">Events</a></li> <li><a href="./">Careers</a></li> <li><a href="./" class="dir">Contact Us</a> <ul> <li><a href="contact.htm">Enquiry Form</a></li> <li><a href="locationc.htm">Contact Us & Location</a></li> </ul> </li> </ul> </div> <!-- End of Menu --> <div id="content1"> <!-- #BeginEditable "BodyContent" --> <div id="flashcontent">AutoViewer requires JavaScript and the Flash Player. <a href="http://www.macromedia.com/go/getflashplayer/">Get Flash here.</a> </div> <!-- #EndEditable --> <script type="text/javascript"> var fo = new SWFObject("gallery/autoviewer.swf", "autoviewer", "100%", "100%", "8", "#181818"); fo.addVariable("xmlURL", "gallery/gallery.xml"); //Optional Configuration //fo.addVariable("langOpenImage", "Open Image in New Window"); //fo.addVariable("langAbout", "About"); //fo.addVariable("xmlURL", "gallery/gallery.xml"); fo.write("flashcontent"); </script></div> <div id="footer"> <p id="links"> Copyright © 2010 − Four Musketters Studio · Your Number 1 Choice. </p> <p> <a href="#">Home</a> <a href="#">Practice</a> <a href="#">Attorneys</a> <a href="#">Accidents</a> <a href="#">News</a> <a href="#">About Us</a> <a href="#">Contact Us</a> </p> </div> </body> <!-- #EndTemplate --> </html> Hi, I was tasked with creating a JavaScript quiz... I succeeded in doing so but part of the requirement was to use hidden fields for the answers. Would this be possible using the code I currently have: Thanks Code: <html> <head> <script type="text/javascript"> function valid() { cor = "0" incor = "0" test0 = document.myform.elements[0].value; test1 = document.myform.elements[1].value; test2 = document.myform.elements[2].value; test3 = document.myform.elements[3].value; test4 = document.myform.elements[4].value; test5 = document.myform.elements[5].value; test6 = document.myform.elements[6].value; test7 = document.myform.elements[7].value; test8 = document.myform.elements[8].value; test9 = document.myform.elements[9].value; if (test0 == "64") { alert("Congratulations you got question one correct!"); ++cor } else alert("Sorry, you got question one incorrect!"); if (test1 == "56") { alert("Congratulations you got question two correct!"); ++cor } else alert("Sorry, you got question two incorrect!"); if (test2 == "7") { alert("Congratulations you got question three correct!"); ++cor } else alert("Sorry, you got question three incorrect!"); if (test3 == "8") { alert("Congratulations you got question four correct!"); ++cor } else alert("Sorry, you got question four incorrect!"); if (test4 == "100") { alert("Congratulations you got question five correct!"); ++cor } else alert("Sorry, you got question five incorrect!"); if (test5 == "1947") { alert("Congratulations you got question six correct!"); ++cor } else alert("Sorry, you got question six incorrect!"); if (test6 == "1") { alert("Congratulations you got question seven correct!"); ++cor } else alert("Sorry, you got question seven incorrect!"); if (test7 == "7") { alert("Congratulations you got question eight correct!"); ++cor } else alert("Sorry, you got question eight incorrect!"); if (test8 == "132") { alert("Congratulations you got question nine correct!"); ++cor } else alert("Sorry, you got question nine incorrect!"); if (test9 == "5280") { alert("Congratulations you got question ten correct!"); ++cor } else alert("Sorry, you got question ten incorrect!"); //else ++incor alert("you got " + cor + " right\n You got " + cor/10 * 100 + "% correct!"); } </script> </head> <body> <form name="myform"> <table border="1" cellpadding="10"> <tr><td>1. 64 added to what number gives a sum of 128?</td><td><input type="text" name="q1"></td></tr> <tr><td>2. The product of 8 and 7 is?</td><td><input type="text" name="q2"></td></tr> <tr><td>3. 35 divided by 5 is:</td><td><input type="text" name="q3"></td></tr> <tr><td>4. 40 divided by 5 is:</td><td><input type="text" name="q4"></td></tr> <tr><td>5. What is the area of rectangle that measure 5 by 20?</td><td><input type="text" name="q5"></td></tr> <tr><td>6. What is 3054 subtracted from 5001?</td><td><input type="text" name="q6"></td></tr> <tr><td>7. What is the result of 5 x 8-39?</td><td><input type="text" name="q7"></td></tr> <tr><td>8. What is the binary number 111 in decimal?</td><td><input type="text" name="q8"></td></tr> <tr><td>9. The sum of 33 and 44 and 55 is:</td><td><input type="text" name="q9"></td></tr> <tr><td>10. How many feet in a mile?</td><td><input type="text" name="q10"></td></tr> <tr><td><input type="button" onClick="valid()" value="score"></td><td><input type="reset"></td></tr> </form> </table> </body> </html> I really thought this would work, a user goes to a page, selects a value from a select box then clicks a link to run a report using that hidden variable as a parameter. I am attempting to place the value in the URL to pass it. I'm sure the javascript is working, and maybe it's the HTML I've messed up - not sure. Here is the javascript (the alert does return the correct value): Code: function OnChangeDay() { //assign the day id to the hidden variable $day x=eval(document.getElementById("day_loc_id_select").value) if(x) { document.getElementById("test_day_id").value=x; } else { document.getElementById("test_day_id").value=0; } // test alert(document.getElementById("test_day_id").value) } Here is the calling HTML: Code: <input type="hidden" name="test_day" id="test_day_id" value=""> <select name="day_loc_id" id="day_loc_id_select" onchange="OnChangeDay()"> <option></option> <?= form_options($day_loc_options) ?> </select> And here is the HTML that should send the value, but I get day= (nothing) Code: <a href='/depts/edoptions/excel_extract.php?ex=2&day=<? echo $test_day ?>'>SLIP Data to Excel</a> Can anyone point out where I've messed up? Thanks Hi, I wanted to know if there is way in Javascript to send a hidden variable to an external URL without actually submitting to the URL? Code below is what I intend to do. I want to use an image to do an onClick event and send the name to an external URL without actually doing a submit. Code: <td width="25"> </td> <input type="image" src="images/btn_Activate.gif" onClick="window.location.href='www.abc.com'"> <input type="hidden" name="name" value="<% = name %>"> </td> Thanks. Jeeten. Hi all, I'm having some trouble with the this... I have a PHP based calendar where the cells will change color depending on the number of clicks.. this all works fine, but is pointless if I can't send the outcome along in an email. I can do this with PHP but first need to get the values into a hidden field. This is what I have: Code: <script type="text/javascript"> function countClicks (obj){ if (!obj.count) { obj.count = 0; } obj.count++; if (obj.count > 4) {obj.count = 1}; if(obj.count == 1){ obj.style.color='#FFFFFF'; obj.style.backgroundColor='#66CC33'; obj.parentNode.style.backgroundColor='#66CC33'; document.getElementById("availability").value='Available'; } if (obj.count == 2){ obj.style.color='#FFFFFF'; obj.style.backgroundColor='#FF0000'; obj.parentNode.style.backgroundColor='#FF0000'; document.getElementById("availability").value='Not Available'; } if (obj.count == 3){ obj.style.color='#FFFFFF'; obj.style.backgroundColor='#FFCC33'; obj.parentNode.style.backgroundColor='#FFCC33'; document.getElementById("availability").value='Working'; } if (obj.count == 4){ obj.style.color='#000000'; obj.style.backgroundColor='#FFFFFF'; obj.parentNode.style.backgroundColor='#FFFFFF'; document.getElementById("availability").value='Not Set'; } } </script> and... Code: echo "<input type=\"hidden\" name=\"availability\" id=\"availability\" value=\"\">"; All I'm trying to do is populate value with either 'available', 'not available', 'working' or 'not set'... however, it is worth noting that each cell may have a different value, e.g. 1 cell might be working while the other is not available... so i need to pass the values of all the cells. Can anyone help me out here. Many thanks, Greens85 my code is below what i want this to do is take the x_cityid and add it to teh hidden field with the id of citiesid (I will do an ajax call before this but my simple javascript is not working) what am i doing wrong? function addtocitylist() { var x_cityid = document.getElementById('x_cityid'); var x_areaid = document.getElementById('x_areaid'); var scitiesid=document.getElementById('citiesid'); var areasid = document.getElementById('areasid'); if (!scitiesid) { scitiesid.value = x_cityid; } else { scitiesid.value = scitiesid + ',' + x_cityid; } scitiesid.value = scitiesid ; alert(scitiesid); } hi guyz i do have a problem in passing javascript variable to <input type=hidden value=""> here's my code: <?php while ($row = mysql_fetch_array($result)) { ?> <script type="text/javascript"> function viewcodec(){ var randomValueCodec = randomString(5, 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789'); document.getElementById('commentMarkCodeCompCodec-'+<?php echo $row['p_id'];?>).innerHTML = randomValueCodec; document.getElementById('commentMarkCodeComp-'+<?php echo $row['p_id'];?>).innerHTML = randomValueCodec; } </script> <form action="" method="post" name="postsForms"> <div class="commentBox" align="right" id="commentBox-<?php echo $row['p_id'];?>" <?php echo (($comment_num_row) ? '' :'style="display:none"')?>> <input type=text id="commentMarkname-<?php echo $row['p_id'];?>" name="commentmarkname" class="commentMarkname" size="35" maxlength="20"> <textarea class="commentMark" id="commentMark-<?php echo $row['p_id'];?>" name="commentmark" cols="60"></textarea> <input type=text id="commentMarkcode-<?php echo $row['p_id'];?>" name="commentmarkcode" class="commentMarkcode" size="35" maxlength="20"> <br clear="all" /> <span id='commentMarkCodeCompCodec-<?php echo $row['p_id'];?>'><b><script type="text/javascript">viewcodec();</script></b></span> <input type="hidden" id="commentMarkCodeComp-<?php echo $row['p_id'];?>" name="commentMarkCodeComp" value=""> <br clear="all" /> <br clear="all" /> <a id="SubmitComment" style="float:right" class="small button comment"> Comment</a> </div> </form> <?php } ?> Afternoon All, I have managed to secure some JavaScript code from another site that allows me to access values from within my Google Analytics cookie: <!-- begin Referer Check --> <script type="text/javascript"> var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www."); document.write("<script src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'>" + "</sc" + "ript>"); </script> <script type='text/javascript'> var pageTracker = _gat._getTracker("UA-1-1"); pageTracker._trackPageview(); // // This is a function that I "borrowed" from the urchin.js file. // It parses a string and returns a value. I used it to get // data from the __utmz cookie // function _uGC(l,n,s) { if (!l || l=="" || !n || n=="" || !s || s=="") return "-"; var i,i2,i3,c="-"; i=l.indexOf(n); i3=n.indexOf("=")+1; if (i > -1) { i2=l.indexOf(s,i); if (i2 < 0) { i2=l.length; } c=l.substring((i+i3),i2); } return c; } // // Get the __utmz cookie value. This is the cookies that // stores all campaign information. // var z = _uGC(document.cookie, '__utmz=', ';'); // // The cookie has a number of name-value pairs. // Each identifies an aspect of the campaign. // // utmcsr = campaign source // utmcmd = campaign medium // utmctr = campaign term (keyword) // utmcct = campaign content // utmccn = campaign name // utmgclid = unique identifier used when AdWords auto tagging is enabled // // This is very basic code. It separates the campaign-tracking cookie // and populates a variable with each piece of campaign info. // var source = _uGC(z, 'utmcsr=', '|'); var medium = _uGC(z, 'utmcmd=', '|'); var term = _uGC(z, 'utmctr=', '|'); var content = _uGC(z, 'utmcct=', '|'); var campaign = _uGC(z, 'utmccn=', '|'); var gclid = _uGC(z, 'utmgclid=', '|'); // // The gclid is ONLY present when auto tagging has been enabled. // All other variables, except the term variable, will be '(not set)'. // Because the gclid is only present for Google AdWords we can // populate some other variables that would normally // be left blank. // if (gclid !="-") { source = 'google'; medium = 'cpc'; } // Data from the custom segmentation cookie can also be passed // back to your server via a hidden form field var csegment = _uGC(document.cookie, '__utmv=', ';'); if (csegment != '-') { var csegmentex = /[1-9]*?\.(.*)/; csegment = csegment.match(csegmentex); csegment = csegment[1]; } else { csegment = '(not set)'; } // // One more bonus piece of information. // We're going to extract the number of visits that the visitor // has generated. It's also stored in a cookie, the __utma cookis // var a = _uGC(document.cookie, '__utma=', ';'); var aParts = a.split("."); var nVisits = aParts[5]; /* function populateHiddenFields(f) { f.source.value = source; f.medium.value = medium; f.term.value = term; f.content.value = content; f.campaign.value = campaign; f.segment.value = csegment; f.numVisits.value = nVisits; alert('source='+f.source.value); alert('medium='+f.medium.value); alert('term='+f.term.value); alert('content='+f.content.value); alert('campaign='+f.campaign.value); alert('custom segment='+f.segment.value); alert('number of visits='+f.numVisits.value); return false; } */ document.forms["cforms2"].elements["cf2_field_1"].value = source; </script> The key outputs from this code are the vars: source medium term content campaign csegment nVisits My question is, how can I get the source var into the hidden field in the form in my footer http://www.yogaholidays.co? I have tried to pass just the source var from within the <script> tags. document.forms["cforms2"].elements["cf2_field_1"].value = source; I have commented out part of original code that I did not think I needed. Any help that can be offered I would be grateful, ultimately I would like to be able to pass all these values to hidden fields. Thanks Paul Brown As of right now I have a code that will work in IE but wont work in FireFox...go figure. Basically what I want to have happen is when you type in an area code it will provide an output in a predetermined area of the page. For Example: Input- 512 Output - Austin, TX The code that I have doesn't work with firefox and I was just wondering if there was a code that would allow that to happen. Thanks! I'm a long time lurker on here just barely created an account to ask this question. I work at a call center, and we use different webapps to fill out tickets. One I've used for a long time allows dynamically updating forms with javascript. I have a whole bunch of bookmarked javascript injections like: Code: javascript:if((top.detail.findObj('X31').value="Inquiry")!=""); That code will fill out most everything in that ticket, leaving me to fill in the details. I have one of those for all of the most common tickets, and can create and finish a ticket in less than 30 seconds when it takes others 3-4 minutes. I recently switched to a different system and I'm having trouble with my code. I'm a noob at javascript for sure, but I'm not new to programming. Anyway any pointers would be nice. The system we use doesn't allow me to see the source... I'm not sure how to explain it. It loads everything in a frame. In chrome I can right click then inspect element and get the ID but it the above javascript doesn't work. Examples: Old app source ex: Code: <label for="X31">Category:</label> was all i needed new app(before the body code is just code for the login form, etc): Code: <body onLoad="startit()" onUnload="stopit()"> </body> <div align="center" valign="center" id="LoadMessageID" style="position: relative; top:40%; color:#0069A5; font-size:100% ;"> <img src="/arsys/shared/images/Progress_NonModal-circle.gif" alt="wait image"/> Loading... </div> </html> formloader: Code: <form name="form1" action="/arsys/forms/bmcitsm/HPD:Incident+Management+Console/Default+User+View+(Support)/?cacheid=a22a36a8" method="post"> example of inspect element in chrome (something i want to change with javascript injection): Code: <input id="arid301602600" type="text" class="text " style="top:0; left:0; width:225; height:21;" readonly=""> Hi! I have a javascript in the head of the document which has a variable named "ref2" ... ref2 is already working as I can see its value working in another function. I need to send this variable as the value of a hidden field in the form which is in the body of the document. This is my JavaScript Code: Code: function WriteContactFormStatement1 () { var ContactFormValue = ref2; document.write('<input type="hidden" name="UReferrersName" value="' + ContactFormValue + '" />'); } var WriteContactFormStatement = WriteContactFormStatement1 (); And at the end of my form, before the submit button, I have the following code: Code: <!-- START -- Javascript to print the statement for UReferrersName --> <script language="JavaScript" type="text/JavaScript"> //WriteContactFormStatement(); document.write (WriteContactFormStatement); </script> <!-- End -- Javascript to print the statement for UReferrersName --> When I execute the form, it doesn't work the way it should, plus, gives me a word "undefined" next to the "Submit" button ..... Please help !... - Xeirus. |