Jump to content

noochies

Members
  • Posts

    10
  • Joined

  • Last visited

    Never

Everything posted by noochies

  1. Well how stupid do I feel? I apologize about that. This application I adopted has it's front end written in php and the back end written in perl. I guess I got the two temporarily mixed up. WHOOPS. Thanks for all your responses...
  2. Hello, I am very baffled with some lines of code from a program I took over that was written by someone else. Here is the code: my $ext=$file; $ext =~ /(\..{3,4}$)/; $ext = $1; my $documentFormatId = isAllowedExtension($ext); I know that this is ultimately getting the file extension into the $ext variable, but that's as far as I've gotten. I can't figure out what the second line is trying to do. I put in print statements in between each of those lines printing out what the var $ext had in it. After the second line, the var is the same as it was before the second line (it equals $file). I know that the tilde character (~) is the bitwise negation character, but I'm not sure how the regular expression fits into the mix. Can someone tell me how you bitwise negate a string with a regular expresson involved?
  3. Yeah, I tried parensthesis (didn't help) and the 'case: 0' statement DOES work. So kenrbnsn, I think I see what you are saying, it makes total sense but didn't occur to me. But here's a follow up question. Why did it work for all numbers >= 1? For example, if 75 was passed into the switch statement, following your logic, it would try to compare 75 to 1 in the ($stock_price < 100) case and it would go to the default case because 75 != 1. But it doesn't. Is that because it is coercing the 75 to a boolean (since it's trying to compare it to a boolean) which would turn it into a 1 and so then the comparison succeeds because 1 == 1? (By the way I am SUPER impressed with this forum. I can't believe how quickly I got responses, this is great!)
  4. Hello, I am having a hard time understanding what a switch statement I have is doing. I am running php version 4.4.7. When zero is the value passed to the switch statement and it tries to compare zero to another number (in this case 10), execution will fall to the default case statement, even though clearly, zero is less than 10. Can someone explain to me what's going on? (Obviously, this is simplified code) //set stock price to zero $stock_price = 0; //make sure it's an int settype($stock_price, "integer"); switch($stock_price) { case $stock_price<10: print("stock price is less than 10"); break; case $stock_price<100: print("stock price is less than 100"); break; case $stock_price<1000: print("stock price is less than 1000"); break; default: print('ERROR!'); } This will print 'ERROR!', instead of 'stock price is less than 10' like I would expect. I'm stumped
  5. Yeah, I have the web developer tool bar and there are no errors in the javascript. When I save the page to my local machine the javascript runs fine. I think that injecting Javascript into the page via AJAX doesn't 'run' the Javascript code when it is injected. Er....at least thats what it seems like. But again, I swear it was working for me at one point.
  6. Hello, I have an application where I am using AJAX to inject some html into a page on the fly. This html code also includes some javascript that I would like to run. It doesn't seem like the javascript I am injecting is running at all even though I can see the rest of the html. If I save the page I'm trying to get to work and then run it on my local machine, the javascript works....go figure.The frustrating thing is that I swear it was working for me at one time. So, I've been trying to get a very simplified version to work and I just can't get the javascript to run. Here is the code I'm using: test.php <html> <head> <script language="javascript"> function ajaxFunction(url) { var xmlHttp; try { // Firefox, Opera 8.0+, Safari xmlHttp=new XMLHttpRequest(); } catch (e) { // Internet Explorer try { xmlHttp=new ActiveXObject("Msxml2.XMLHTTP"); } catch (e) { try { xmlHttp=new ActiveXObject("Microsoft.XMLHTTP"); } catch (e) { alert("Your browser does not support AJAX!"); return false; } } } xmlHttp.onreadystatechange=function() { if(xmlHttp.readyState==4) { document.getElementById('extra').innerHTML=xmlHttp.responseText; } } xmlHttp.open("GET",url,true); xmlHttp.send(null); } </script> </head> <body> <form method="post" action=""> Ticketsubmit<input type="text" name="ticketsubmit" value="ticketsubmit" onBlur="ajaxFunction('test2.php')"> <input type="submit" name="submit" id="submit" value="submit"> <div id='extra'> <p>heello</p> </div> </form> </body> </html> the page called asychronously (test2.php): <?php echo "<script type='text/javascript'> function hello(){ alert('hello!') } </script> Another<input type='text' name='another' value='another' onchange='hello()'>"; ?> (my original code has the <script> code all in one line but I broke it up here for readability) I CAN however get the alert in this test2.php to work <?php echo " Another<input type='text' name='another' value='another' onchange='alert(\"hello!\")'>"; ?> Has anyone been able to make this work and if so, can you see what I'm doing wrong?
  7. Well, I put together the simplest form possible with the simplest ajax possible, and it did work. So, yeah there must be something in my code that is messing something up. My elements have both names and ids so thats not it... I guess now I'll just pick the code apart until I find out whats messing with it. But at least I know that it DOES work! Thanks for your help!
  8. I'm not sure I see what you are trying to say.... I've got the application putting the fields into the div. I see the entire form and I can fill it out. The problem is that those fields that I added dynamically, their data does not show up in the $_POST var when I submit. Am I misunderstanding what you are trying to say?
  9. Hello, here is my problem. I want to add input fields to a form depending on what is selected in another drop down input field. I have this part working. However, when I submit the form, I don't get any of the additional data in the $_POST variable. I'll give you an example. This is a service ticket type application. When someone is entering a ticket, they choose the category of help they need from a drop down box. Examples are 'Hire/Exit', 'Software Purchase', 'Password Problems'. Depending on what category they pick, I'm using AJAX with the drop down box onChange event to write in additional input fields specific to that category. For example, if they choose 'Software Purchase', I want to add input fields for the name of the software, the quantity, and the chartfield information for purchasing, to the form for the user to fill in. But when I try to test this and I hit submit, I get all the other form element data except the data from the input elements I dynamically added (with AJAX) in the $_POST global variable. Is this even possible?
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.