• Web Dev Questions That Don't Need Their Own Thread v4
    5,001 replies, posted
[QUOTE=NoFaTe;42987292]If you need to process the selection server-side I would do something like that. [code] <form name="weirdForm" action="someEndpoint" method="POST"> <label>Hvilken something Moofy</label><br/> <input type="radio" name="selection1" value="option1" checked/>Mit har er turist<br/> <input type="radio" name="selection1" value="option2"/>What language is this?<br/> <input type="radio" name="selection1" value="option3"/>Danish?<br/> <hr> <label>Er dit blah bananas</label><br/> <input type="radio" name="selection2" value="option1" checked/>Ja<br/> <input type="radio" name="selection2" value="option2"/>Neg<br/> <hr/> <input type="submit" name="submit"/> </form>[/code] And then check the contents of the selection1/2 POST variables to determine what to output. In PHP for instance: [code] $_POST['selection1']; // Will be either option1, option2 or option3 $_POST['selection2']; // Will be either option1 or option2 [/code] If you want to do it client-side, you can use the same code without the submit button, and then listen for the "change" event using JavaScript.[/QUOTE] Well I need the submit button with no JavaScript at all, it has to be pure PHP for that selection. - So still not sure how to tackle it with this solution since you recommend the JavaScript bit with no submit button. And yes, its Danish. :v: [editline]27th November 2013[/editline] [QUOTE=xianlee;42990207]Never mind seem to of got it working.. (for now). EDIT: I do have a new question.. On my website, I want to create a like 'ticker' that presents random facts about me after x amount of seconds / minutes.. what would be the best language to learn and program this? would it be easy?[/QUOTE] I don't know about timing that process, but for random try and look at [URL="http://php.net/rand"]PHP rand();[/URL]
[QUOTE=xianlee;42990207]Never mind seem to of got it working.. (for now). EDIT: I do have a new question.. On my website, I want to create a like 'ticker' that presents random facts about me after x amount of seconds / minutes.. what would be the best language to learn and program this? would it be easy?[/QUOTE] Javascript would be the best one. Have an array filled with the facts, and then present a random one of them. (You could also do this sererside and call it with AJAX) [code] // By some cool person at http://phpjs.org because I didn't want to bother with the default random number generator function rand(e,t){var n=arguments.length;if(n===0){e=0;t=2147483647}else if(n===1){throw new Error("Warning: rand() expects exactly 2 parameters, 1 given")}return Math.floor(Math.random()*(t-e+1))+e} var arr = new Array("I love ponies","I love long walks","I love sunshine"); var max = arr.length - 1; var randomNumber; var str; setInterval(function(){ randomNumber = rand(0, max); str = arr[randomNumber]; },1000); [/code]
[QUOTE=Moofy;42995543]I don't know about timing that process, but for random try and look at [URL="http://php.net/rand"]PHP rand();[/URL][/QUOTE] Ehh, I wouldn't call PHP a good thing to do this in, unless you want to call it with AJAX...
[QUOTE=gokiyono;42997750]Ehh, I would say call PHP a good thing to do this in, unless you want to call it with AJAX...[/QUOTE] Meh, it's for a fact box, I don't think it's super important to get the latest tips the second after they're added to a list. I'd say adding them with javascript (the one previously posted) should work. If you add/remove tips, it's going to be noticed by the browser anyways (on the next page reload).
Having only really used C# with ServiceStack for dynamic web pages I was looking to learn some other tools of the trade, I have an idea for a neat project and was thinking of using Java/Scala for it but I hve no idea what framework to use for the actual server side stuff, I have heard of Grails and Play before but dontreally know which has the better features/is more robust. Ideally I would want to look into one that is used more in the real world as the main point of this exccersice is to learn about industry used frameworks. Any suggestions?
[QUOTE=gokiyono;42997750]Ehh, I would say call PHP a good thing to do this in, unless you want to call it with AJAX...[/QUOTE] why would php be a good thing to do this in? javascript is much easier to run, and much easier to test.
does anyone recommend anywhere cheaper than godaddy for buying domain names? $10/year is okay but if I get less that would be cool [editline]27th November 2013[/editline] Also: Any clue why it seems that the rest of the code on my site after an inserted, centered iframe is ignored? I put a highly customized iframe on a sandboxed version my site and it worked before but now everything after the iframe in the markup won't show [B]it entirely ends the page so much that my website's background-image even starts repeating at the end of the iframe[/B] Lastly: How to remove vertical scrolling bar of iframe while still allowing scrolling? overflow: hidden does not work and scrolling=no works but prevents scrolling
[QUOTE=RusselG;43002280]why would php be a good thing to do this in? javascript is much easier to run, and much easier to test.[/QUOTE] Whoops, let me just fix that. I meant wouldn't :/
In PHP what would be the best way of replacing a lot of keywords with other words based on the values in an associative array? Or is a foreach and regular expression a good idea?
The [URL="http://php.net/manual/en/function.str-replace.php"]str_replace [/URL]function will probably do just fine.
[QUOTE=gokiyono;43007198]In PHP what would be the best way of replacing a lot of keywords with other words based on the values in an associative array? Or is a foreach and regular expression a good idea?[/QUOTE] Untested: [code] <?php function filterText($text){ $filters = array( 'boobs' => 'Lady bumps', 'dongs' => 'gentlemen sausage', 'poowizard' => 'kevin', ); foreach ($filters as $filter => $replacement) { $text = preg_replace('/\b'.$filter.'\b/', $replacement, $text); } return $text; } ?> [/code] Using preg_replace means you can use boundaries (\b) which means the filter won't replace words within words which leads to lots of false positives.
[QUOTE=gokiyono;42997038]Javascript would be the best one. Have an array filled with the facts, and then present a random one of them. (You could also do this sererside and call it with AJAX) [code] // By some cool person at http://phpjs.org because I didn't want to bother with the default random number generator function rand(e,t){var n=arguments.length;if(n===0){e=0;t=2147483647}else if(n===1){throw new Error("Warning: rand() expects exactly 2 parameters, 1 given")}return Math.floor(Math.random()*(t-e+1))+e} var arr = new Array("I love ponies","I love long walks","I love sunshine"); var max = arr.length - 1; var randomNumber; var str; setInterval(function(){ randomNumber = rand(0, max); str = arr[randomNumber]; },1000); [/code][/QUOTE] Thanks
[QUOTE=CBastard;43007601]Untested: [code] <?php function filterText($text){ $filters = array( 'boobs' => 'Lady bumps', 'dongs' => 'gentlemen sausage', 'poowizard' => 'kevin', 'u' => 'you', 'ur' => 'you\'re', 'fag' => 'homosexual' ); foreach ($filters as $filter => $replacement) { $text = preg_replace('/\b'.$filter.'\b/', $replacement, $text); } return $text; } $str = "ur a fag, i bet u like dongs u poowizard"; $result = filterText($str); var_dump($result); ?> [/code] Using preg_replace means you can use boundaries (\b) which means the filter won't replace words within words which leads to lots of false positives.[/QUOTE] Tested, added three keywords, and it returns [code] string 'you're a homosexual, i bet you like gentlemen sausage you kevin' (length=63) [/code] Thank you so much :v:
is <iframe seamless> deprecated
[QUOTE=Cronos Dage;43010587]is <iframe seamless> deprecated[/QUOTE] As far as I know, it isn't, it's new. But it is only supported in Chrome. (Don't hold me to it)
[QUOTE=gokiyono;43015183]As far as I know, it isn't, it's new. But it is only supported in Chrome. (Don't hold me to it)[/QUOTE] If I recall correctly it's only supported on webkit and now blink, so... opera, safari and chrome? Don't know why mozilla doesn't support it... Edit: [url=https://developer.mozilla.org/en-US/docs/Web/HTML/Element/iframe#Browser_compatibility]Yup...[/url]
If I join a column from one table to another in a mysql database does that physically alter the original table to have a new column?
Stumped on doing a silly web calculator. A JavaScript function's not being called. [url=http://pastebin.com/hP3EJ6qD][i]index.html[/i][/url] [url=http://pastebin.com/zhMj77W8][i]logic.js[/i][/url] (Don't nag at me for using tables or eval(), this is just a quick homework assignment I got down pat.) More specifically... [code]<TD COLSPAN="2"><BUTTON NAME="clear" ONCLICK="clear()">C</BUTTON></TD>[/code] [code]function clear() { var entry = document.getElementById("entry"); entry.value = null; // Doesn't work on null, blank string, or anything. Doesn't matter since clear()'s not being called. console.log("Clear! Bzzzzt!"); // Console reminder clear()'s being called, but this is not showing up, indicating clear()'s not being called. } // End CLEAR[/code]
[QUOTE=Rofl my Waff;43022752]If I join a column from one table to another in a mysql database does that physically alter the original table to have a new column?[/QUOTE] If you mean you call a right/inner/left join, then not really.
snip, wrong thread.
[QUOTE=Stonecycle;43023510]Stumped on doing a silly web calculator. A JavaScript function's not being called. [url=http://pastebin.com/hP3EJ6qD][i]index.html[/i][/url] [url=http://pastebin.com/zhMj77W8][i]logic.js[/i][/url] (Don't nag at me for using tables or eval(), this is just a quick homework assignment I got down pat.) More specifically... [code]<TD COLSPAN="2"><BUTTON NAME="clear" ONCLICK="clear()">C</BUTTON></TD>[/code] [code]function clear() { var entry = document.getElementById("entry"); entry.value = null; // Doesn't work on null, blank string, or anything. Doesn't matter since clear()'s not being called. console.log("Clear! Bzzzzt!"); // Console reminder clear()'s being called, but this is not showing up, indicating clear()'s not being called. } // End CLEAR[/code][/QUOTE] Don't have time to check it out but: - Don't use caps, please. -Put it on jsfiddle or something similar. -I built one recently [url=https://dl.dropboxusercontent.com/u/5169714/Dev/calculadora/index.html]if you want to look at it[/url]. (comments in portuguese)
[QUOTE=asantos3;43026161] -Put it on jsfiddle or something similar.[/QUOTE] Doesn't run properly on JSFiddle (Buttons aren't firing).
[QUOTE=Stonecycle;43027057]Doesn't run properly on JSFiddle (Buttons aren't firing).[/QUOTE] You most likely have some other problems in the code then.
[QUOTE=gokiyono;43027063]You most likely have some other problems in the code then.[/QUOTE] Never mind, the problem was stupidly simple in retrospect. Apparently clear() is a native JS function.
[QUOTE=Stonecycle;43027103]Never mind, the problem was stupidly simple in retrospect. Apparently clear() is a native JS function.[/QUOTE] That's why it's a good idea to prefix custom functions :v:
Anybody know where I can learn php ? do you guys have any good source?
[QUOTE=efecanefe;43029989]Anybody know where I can learn php ? do you guys have any good source?[/QUOTE] The only I know are [URL="http://www.php.net/manual/en/"]php.net/manual/en/[/URL] and [URL="http://www.codecademy.com/tracks/php"]codecademy.com[/URL]
[QUOTE=efecanefe;43029989]Anybody know where I can learn php ? do you guys have any good source?[/QUOTE] [url]https://compilr.com/[/url]
I want to make a website that has lots of my cool little Javascript powered stuff on it. So basically, you get to a homepage and you select which one you want to look at and it shows you. I don't want to hard code it, I want it to be run through a database. What's the best way to do this? Do I put all the code for everything into a database and run it like that, Or do I just store the links to the files in the database? I want it to be very clean. I don't want to edit 500 files every time I add a site.
[QUOTE=Coffeee;43037801]I want to make a website that has lots of my cool little Javascript powered stuff on it. So basically, you get to a homepage and you select which one you want to look at and it shows you. I don't want to hard code it, I want it to be run through a database. What's the best way to do this? Do I put all the code for everything into a database and run it like that, Or do I just store the links to the files in the database?[/QUOTE] IMO I'd store all the code on a db (and would show something else on the page), so it's not possible to just grab the link to the file and hotlink it (stealing your server resources).
Sorry, you need to Log In to post a reply to this thread.