JavaScript - Help Using Javascript Within A Perl Script
I have a Perl script that contains a variety of inputs including a HTML <SELECT> and RADIO buttons. I would like to alter the presentation of a RADIO button choice with a DISABLED, based upon the earlier selection of from a <SELECT> drop down menu.
In Perl I attempted to capture the selection from the <SELECT> and use that value in a IF ELSE block, but this does not work. I have been told that this can be done with a Javascript. I did a little bit of coding with Javascript around five years ago, so I am a rusty newbie. Can anyone give me a hand on how this should be constructed? The more detailed your examples or suggestions can be the easier it will be for me to grasp the solution. Similar TutorialsHello, I have a perl code and I am animating using js. Can anyone explain how far they are compactible. Here is one of my problem... code: print "Qword(l);"; print "function Qword(l){"; print "if(l<5){"; print "$j=l;"; print "alert($j);"; print "l++;"; print "Qword(l);"; print "}"; print "}"; This is going into a infinite loop, this code comes from a perl fn I have declared $j. I changed it, still j is not incremented. print "function Qword(l){"; print "if(l<5){"; $j++; print "alert($j);"; print "l++;"; print "Qword(l);"; print "}"; print "}" Can anyone help me please.. Thank you, jv123 Hi everyone, I've been coding Perl for quite some time, but I'm new to Javascript and can't quite figure this out. I want to call a Javascript function that is sent to the browser via a perl script. When I hard code the string "Fargo" into the code it works just fine, when I pass the word Fargo via a variable the script will not call the function what so ever. Is it possible to call a javascript function via a Perl script with Perl providing all the necessary data? Here is my code: #!/usr/local/bin/perl use CGI qw(:all); use CGI::Carp qw(fatalsToBrowser); use Cwd; print header; print "top<br><br>"; $data = "fargo"; print <<html; <html><head></head>my heading is here<br><body></body> <script type="text/javascript"> function testz(inbound) { document.write("im in ", inbound); } //the script will only work if I uncomment the line below and comment out two lines below //var data1="fargo"; var data1 = $data; testz(data1); </script> </html> html Thanks to everyone in advance for your help. Hi, I'm still in the early stages of learning Javascript so I'm not sure how (or if it's possible) to do this. I know HTML, CSS, etc... just not too familiar with Javascript. Here's the deal.... I run a website that features a chat room written in Perl for CGI. The chat room will automatically email a user their password if it's forgotten but there is one issue.....it does not have the "Forgot Password?" link. To achieve the Lost Password page, the user must enter an invalid password FIRST on the login screen, otherwise they cannot get to that option and are often requesting assistance. What I had in mind was an easier way for the user to get their password since new novice members are not sure how to get to the lost password page. I'm not trying to edit the Perl code for the chat, but I wanted to build a "Forgot Password?" page using a Javascript code that will automatically take their username from the "username" login field and direct them to the lost password page which would be "chat2.cgi?action=send_pwd&name=..." I'm sorry if this is confusing, I'm not sure that I am explaining this right. When the user enters an invalid password, it takes them to the lost password page which contains a link "lost password" and will automatically email them their login details when clicked on. When they click that link, the URL contains the string "chat2.cgi?action=send_pwd&name=username" What I would like to do is put a link on the login page (like most normal chat rooms have) that says "Forgot Password?". When clicked on, I want it to take them to a page where all they have to do is enter their username in a form and click Submit, then have a Javascript code automatically extract their username from that field and insert their username automatically to the end of that URL (chat2.cgi?action=send_pwd&name=...) where ... would be the name extracted from that form field. This would result in the browser taking them to that URL which would trigger the chat to automatically email the password. Can I do this with Javascript?? If so, any help would be greatly appreciated! hello all, I am new to javascript, i just wanted to know how can i send a array from perl to javascript function.... if anybody having any idea about this please reply me..thanks in adbvance I am creating an html document with perl. I wrote an event mouseover and mouseout to happen for every perl variable (over a loop). But looks like the event controls all the variables at the same time. How do I write the event only once but enable it to individually be applied for each item: this is what I have currently but this html when displayed, does not let me control the event separately for each $key. Even though the buttons do get created for each $key, clicking on one, controls the $stats_data{$out}{$key} of all. I even tried passing the id to the show/hide script, but no luck. Some help would be greatly appreciated. thanks Code: <header><script> function hideit() { var x1 = document.getElementsByTagName("ol").item(0); var x = document.getElementsByTagName("ol"); for (var i = 0; i < x.length; i++) x[i].style.display="none"; } function showit() { var x1 = document.getElementsByTagName("ol").item(0); var x=document.getElementsByTagName("ol"); for (var i = 0; i < x.length; i++) x[i].style.display=""; } </script><header> <body> foreach $key (keys %{$stats_data{$out}}) { print $indexfd ("<input onclick=\"showit()\" type=\"button\" id=\"<?perl echo $key; ?>\" value=\"showit\"><br><input onclick=\"hideit()\" type=\"button\" id=\"<?perl echo $key; ?>\" value=\"hideit\"><br><b><ol id=$key>$stats_data{$out}{$key}<ol id=$key> </b><br>"); }</body> Hello, I am trying to retrieve a cookie I stored with Perl through javascript. Based on the contents of the cookie, I want the javascript to print/not print an extra link on my page. Below is the code, in Perl, I am using to store the cookie. In the Perl forum I was told to post in here for the javascript help. The basic idea is that if the cookie has a "Role" of "Super," the ADMIN link displays on the page. If the role doesn't have "Super," the link is hidden. Any help you could offer would be greatly appreciated. Thanks a lot. Code: #!/usr/local/bin/perl # This page was created and worked on by 2/C Collard, 2/C Waymouth, 2/C Troisi, and 2/C Cunha #source: http://forums.speedguide.net/showthread.php?t=190821 # PERL MODULES WE WILL BE USING use DBI; use DBD::mysql; use CGI qw( :standard ); use CGI::Carp qw(fatalsToBrowser); #print "Content-type: text/html \n\n"; $userPassed = param("userID"); # CONFIG VARIABLES $platform = ""; $database = ""; $host = ""; $port = ""; $tablename = ""; $user = ""; $pw = ""; # DATA SOURCE NAME $dsn = "dbi:$platform:$database:$host:$port"; # PERL DBI CONNECT $connect = DBI->connect($dsn, $user, $pw) or die "Connection Error: $DBI::errstr\n"; # PREPARE THE QUERY my $query = "SELECT * FROM $tablename WHERE User = '$userPassed'"; my $query_handle = $connect->prepare($query); #print ($query); # EXECUTE THE QUERY $query_handle->execute(); while (@row = $query_handle->fetchrow_array) { $roleIn = "$row[2]"; #print ("$roleIN"); } $query = new CGI; # create a new CGI object $cookie = $query->cookie ( -name => 'Role', -value => '$roleIn', -path => '/', -expires => '+60m'); $location = ''; print $query->header(-cookie=>$cookie); print qq{<meta http-equiv="REFRESH" content="0;URL=http://www.togoto.com">\n}; # HTTP HEADER #print( header() ); #print ( start_html() ); # Print XHTML footer #print ( end_html() ); Hi, I was wondering how to load an external .php script file in javascript, and make use of a php variable in the javascript. Thanks in advance. EDIT: If this is not possible, is there some way to send the php data to the javascript by using php, and then accessing the data that was sent in the javascript, and making use of it? What I'm trying to do is get a OpenTok session id from a .php script to javascript. Hi peeps I found this script on another forum, It is nearly perfect, I was wondering if you peeps could help me make a few changes... how do I change the cut off to 8pm I have tried var c_t = 8; but it does 8am I have also tried var c_t = 20; but it doesnt work... Any ideas? Also instead of just saying "your order will ship shifted to tommrow" would it be possible to insert tomorrows date, i.e Thursday 13th and then for "and your order will ship to Monday" could it say Monday 15th etc Here is the script, Code: <html> <head> <script type="text/javascript"> function ord() { var c_t = 4; var dd = new Date(); var ti_h = dd.getHours(); var ti_m = dd.getMinutes(); if(ti_h > c_t) { var di_t_h = ti_h - c_t; var di_t_mi = 60 - ti_m; var h = 24 - di_t_h; var mi = di_t_mi; var mess = h+"hours"+mi+"minutes"; } var da = dd.getDay(); //var da = document.getElementById("da").value; switch(da) { case 2: case 3: case 4: case 5: document.write("Place your order within the next 1 day"+mess+"and your order will ship shifted to tommrow"); break; case 6: case 7: case 1: document.write("and your order will ship to Monday"); break; } } ord(); </script> </head> <body> </body> </html> Hi, I am trying to add one image in footer of my application. Code: <div class="rightLinks"> <a href="#"><script src=https://seal.somesign.com/getseal?host_name=www.validsite.com&size=S&use_flash=NO&use_transparent=NO&lang=en></script></a> </div> But this is not working. Please let me know, what is wrong in it. And how can we correct it. Thanks!! Regards, Neha I embedded the following into my blog; Code: <br><script language="javascript" src="http://www.quotedb.com/quote/quote.php?action=random_quote&=&=&"></script> <br> It works fine, but I'm trying to find a way to refresh only the script on my blog, instead of having to reload the entire page. Coding a refresh button, for instance. How would I go about doing this? Thank you in advance. Hey all I am not that much good in JS and J* kind of thigs .. help me out on this .. I am opening a Dhtmml poopup ,and it's having two buttons say YES and NO if user click on YES (mysql table) field say Yes should increse else if No (mysql table) field No should increse I hope understand the problem bascically on onclick I m using "window.open " a phpFile which is updating this all .. but I dont want to do this with window.open any help would be appreciated Thanks ayiamas Hi, I have a little problem with placing a javascript into a php script If the action "Change" is true then I want to open a new window with a javascript below. I get an error message: Parse error: syntax error, unexpected '<' in /home/........ on line xx On that xx line starts the Javascript What must I do to solve this problem. <?php.................... if($_REQUEST['action']=="Change") { mysql_query("UPDATE Persons SET Itemstate = '{$_REQUEST['Nr']};' WHERE Nr={$_REQUEST['Nr']};"); <SCRIPT LANGUAGE="javascript"> <!-- window.open ('Examplepage.html') --> </SCRIPT> ........ ?> Hello everyone, I have setup a script called Uploadify it is a basic file uploader script however by default it does not show a link to the uploaded file. I have had to look in the documentation on to do this but there is no clear guide on how to do it. I found this function though which I belieave is the solution: http://www.uploadify.com/documentati.../oncomplete-2/ Here are the functions I am using: Code: 'onComplete' : function(event, ID, fileObj, response, data) { document.write('http://www.cqwebdesign.co.uk' + fileObj.filePath +''); } This works kinda but when it shows the link the page continues loading as if it is stuck in some loop? You can try it out he http://www.cqwebdesign.co.uk/SC2/index.html Thanks Hi, I have a a-z brand menu on my site. I want the user to be able to select a letter and a list of brands appear. The problem I have is that I want the layer to appear at the position of the mouse (from the top left). I have this working fine but then when you rollover a link (brand) within the layer div it reactivates the call command and re positions the layer to the mouse again. Please Please help. My code is as follows; POSITION CODE; Code: var cX = 0; var cY = 0; var rX = 0; var rY = 0; function UpdateCursorPosition(e){ cX = e.pageX; cY = e.pageY;} function UpdateCursorPositionDocAll(e){ cX = event.clientX; cY = event.clientY;} if(document.all) { document.onmousemove = UpdateCursorPositionDocAll; } else { document.onmousemove = UpdateCursorPosition; } function AssignPosition(d) { if(self.pageYOffset) { rX = self.pageXOffset; rY = self.pageYOffset; } else if(document.documentElement && document.documentElement.scrollTop) { rX = document.documentElement.scrollLeft; rY = document.documentElement.scrollTop; } else if(document.body) { rX = document.body.scrollLeft; rY = document.body.scrollTop; } if(document.all) { cX += rX; cY += rY; } d.style.left = (cX+5) + "px"; d.style.top = (cY+5) + "px"; } TOGGLE HIDE SHOW LAYER; Code: function toggle_visibility(id) { var e = document.getElementById(id); AssignPosition(e); if(e.style.display == 'block') e.style.display = 'none'; else e.style.display = 'block'; } EXAMPLE OF A-Z MENU; Code: <a href="#" onclick="toggle_visibility('uniquename0');">A</a> EXAMPLE OF LAYER TO DISPLAY WHICH CONTAINS THE OFFENDING LINKS; Code: <div id="uniquename0" style="border-style: solid; padding: 5px; display: none; position: absolute; background-color: white; left: 482px; top: 428px;" onmouseout="toggle_visibility('uniquename0');"> <a href="Manufacturer-view.asp?ManID=1">All American EFX <img src="images/bul.gif" alt="View" border="0" width="4" height="6"></a><br> <a href="Manufacturer-view.asp?ManID=3">Animal <img src="images/bul.gif" alt="View" border="0" width="4" height="6"></a><br> </div> Thank you Dan Hello all, I'm new to PHP (and web development in general) and have come across something that to me seems really, really bizarre! Background I am currently designing and developing an online enrolment form for my employer, a training company. The form consists of 3 pages - pages 1 and 2 are for data input whilst page 3 is a summary page with only one input, a box to check that the customer agrees to our T&Cs. Page 3 also includes a box where calculations are made as to the price of the selected training course based on choices made earlier in the form. The form displayed on page 2, and some of the text on page 3, changes depending on a choice made on page one - that is, whether they are paying for the course themselves or their employer is funding it. If they choose employer, they get one form, if they choose self funding they get a different one. However, both of these forms are contained within a single .php file, using session variables to decide which one should be displayed. I am using sessions to transfer the data between the pages. Each page has been made sticky using session variables. Real-time validation is carried out using javascript on each individual page, then a final PHP validation check is run on the whole thing when the customer tries to submit the final page. Javascript is also used on page one to calculate the price of the course in real time so the customer can see how much he/she will be paying before proceeding further. The Problem I find this really strange: In Firefox, everything works perfectly In Internet Explorer, when JavaScript is turned off, everything is fine. But when JS is switched on, the PHP validation on the final page seems to go haywire, thus making it impossible to submit the form. In Chrome, again when JS is switched off, everything works, but when switched on, I can't even get past the first page. Instead of loading the correct form for page 2, I just get a blank screen. Can anyone help? This is my first major project and I've been working on it for weeks, coming up against all sorts of problems and tearing my hair out but managing to solve them. Now I'm completely stumped, when I'm almost within touching distance of completion!! I can't post the code here as it's 3 separate documents and very complicated, but if you want to have a look at the form itself go to: http://testing.xenongroupadmin.com/t.../enrolment.php I hope someone can help! Thanks very much! All the best Chris I have an age script running in the attachment below. It works fine for numbers such as 1 22 1980. Code: if ((input.search(/\b([1-9]|[12][0-9]|3[01])\b/)!= -1) && (input.search(/\b([1-9]|1[0-2])\b/)!=-1) && (input.search(/\b(19[0-9]{2}|200[0-9]|201[01])\b/)!= -1)) { function getBirth() { var now = new Date(); var myMatchy = input.match(/\b(19[0-9]{2}|200[0-9]|201[01])\b/); var myMatchm = input.match(/\b([1-9]|1[0-2])\b/) var myMatchd = input.match(/\b([1-9]|[12][0-9]|3[01])\b/); var year = myMatchy[0]; var month = myMatchm[0]; var day = myMatchd[0]; var today = { "year" : now.getFullYear(), "month": now.getMonth()+1, "day" : now.getDate() } var age = today["year"] - year; if (month > today["month"]) age--; else if (month == today["month"]) if (day > today["day"]) age-- return age; } document.result.result.value = "Your age is "+getBirth()+"."; return true;} However, if someone writes out the month it doesn't. Such as January 22 1980. I did a work-around by inserting the month value. Highlighted below. But that means I would have to duplicate this lengthy code 12 times for each month of the year. Anybody know a better way to handle this? You can test it in the small attachment below. Any help would be appreciated. Code: if ((input.search(/\b([1-9]|[12][0-9]|3[01])\b/)!= -1) && (input.search(/(january)/)!= -1) && (input.search(/\b(19[0-9]{2}|200[0-9]|201[01])\b/)!= -1)) { function getJan() { var now = new Date(); var myMatchy = input.match(/\b(19[0-9]{2}|200[0-9]|201[01])\b/); var myMatchd = input.match(/\b([1-9]|[12][0-9]|3[01])\b/); var month = 0; var year = myMatchy[0]; var day = myMatchd[0]; var today = { "year" : now.getFullYear(), "month": now.getMonth()+1, "day" : now.getDate() } var age = today["year"] - year; if (month > today["month"]) age--; else if (month == today["month"]) if (day > today["day"]) age-- return age; } document.result.result.value = "Your age is "+getJan()+"."; return true;} I am really new to JavaScript, and was following a tutorial that was using everything inline (probaby as its less confusing for the noob). Now I want to split it off into a script area, like my CSS has been. I have: Code: <SPAN onclick="document.getElementById('glance').style.display='block';document.getElementById('front').style.display='none';"> Is something like this valid (this is a guess BTW)? Code: <SCRIPT type="text/javascript"> function getElementById('glance') { .style.display='block'; } function getElementById('front') { .style.display='none'; } </SCRIPT> <SPAN onclick="document.getElementById('glance'); document.getElementById('front')"> ... </SPAN> ... or should function be document in the script area and document not be present in the SPAN attribute? ... Better yet, is there a way to put both the 'glance' and 'front' together like this: Code: <SCRIPT type="text/javascript"> function getElementById ('glance') { .style.display='block'; getElementById ('front') { .style.display='none'; } } </SCRIPT> Hi they all, I want make autocompleted searching for my site. I find HTML5 autocompleted script in google. I use Laravel and PHP and MongoDB. My script PHP Code for search autocompleted. PHP Code: publicfunction searchAutoCompleteAjax(){ $keyword =Input::get('keyword'); $result = array();if(!empty(trim($keyword))){ $mongoResult =MongoDB::instance(true)->collection("items")->like('name',$keyword)->limit(0,10)->fetch(); if($mongoResult){foreach($mongoResult as $key => $item){ $result[]= $item['name'];}}} echo json_encode(array("error"=>0,"message"=>"Success","result"=>$result));} I result 10 query PHP Code: $mongoResult =MongoDB::instance(true)->collection("items")->like('name',$keyword)->limit(0,10)->fetch(); My old javascript code and working for me. Is there a way to use inline javascript that will prevent any javascript after it (in the same page) from executing? So, for instance I could have something like: -Content- -JS A- -Content- -JS B- -JS C- 'JS A' would execute, 'JS B' would be the code I'm asking about and it would cause 'JS C' to not do anything. Sorry if this is an off-the-wall question. I good with C/C++, VB, Ruby, Lua, HTML, etc, but I haven't gotten to Javascript (or Java) yet so I have no idea what the capabilities or environment setup are like. Thanks in advance for any advice. Hi I'm Terbinafine I do online school, and it utilizies a popular, virtual education system known as "OdysseyWare". I found a javascript 'cheat' per se, online, which is supposed to reveal the answers to your questions. Here's an example of the source code for a multiple choice question: Code: [EDIT] OdysseyWare Code removed. The code that was removed was a very small javascript piece of code, totaling less than 70 lines. The javascript that was removed here could be recreated by an individual inside of a day, or even 30 minutes or less. It is the Editor’s opinion that, given the ease with which one is able to, apparently, find the answers to the OdysseyWare testing software, the OdysseyWare software is not fit for educational use. What good is testing software that, apparently, allows the user to be able to find all of the answers to the questions by using simple code that they can find on the internet or make themselves? As an educator for many years, I would NOT and will NEVER use this software and cannot recommend that anyone else use it. |