Jump to content

Webworldx

Members
  • Posts

    347
  • Joined

  • Last visited

Everything posted by Webworldx

  1. You could - i'm not much of a fan of inline javascript like that if I can help it though =) Isn't it cursor: pointer ?
  2. It's up to you really... switch() has relative speed differences in PHP, but not really that much in JS. if (val) { } else if (val) {} else if (val) {} else {}
  3. Why would you want to use ajax if it's just a simple form - with no large dynamic content? I'd understand if the form was bigger (which I added in the downsides), but as it was a small form - I don't think it's worth implementing an ajax interface for it.
  4. I thought i'd add this: http://blogs.ifcode.com/webworldx/114/my-online-time/It's part-discussion, part-rant but there's some good points in there I think. I switched to Firefox last week in one of those "don't use IE and see what the competition is like" periods. Overall, i'm impressed with the speed and some of the features of Firefox Beta 2, but to be honest - there's not an overall jump in number of features between it and IE7 w/ Maxthon.
  5. It would be \" not /" :)If you're wanting to add that much content though, there is an easier way - drop it all onto the page completely, and hide it. .... select stuff here...<div id='home_content' style='display: none;'> ... all the home content HTML in here, form etc etc</div><div id='about_content' style='display: none;'> .... all the about content in here...</div> Then you just need to dodocument.getElementById('about_content').style.display="block";and it'll add it to the page. There's downsides - obviously all the content gets loaded onto the page every time it's accessed rather than progressively as JS would do - but if you can live with that - it might be quicker - and certainly cleaner
  6. <script type='text/javascript'>/*Random Independent NumbersCreated by Webworldx - w3Schools*/var highest_number = 10;var num_you_want = 5;var current_list = new Array();function draw_number(){ var selected_num = Math.ceil( Math.random() * highest_number); for(j=0;j<current_list.length;j++){ if(selected_num == current_list[j]){ //Number already selected return draw_number(); } } return selected_num;}function go_get_numbers(){ if(num_you_want > highest_number){ // You can't ask for more numbers than it's possible to get return false; } for(i=0;i<num_you_want;i++){ current_list[current_list.length++] = draw_number(); } return current_list;}var independent_numbers = go_get_numbers();alert(independent_numbers);</script>
  7. An interesting one! I'm sure someone will come up with a better solution (RegExp test with a while loop that I couldn't quite manage...), but here's my idea: <div id='the_text'>hello<br>dog<br />cat<br></div><script type='text/javascript'>var my_div = document.getElementById('the_text')var my_div_matches = my_div.innerHTML.split(/<br(.*?)>/i);for(i=0;i<my_div_matches.length;i++){ my_div.innerHTML = my_div.innerHTML.replace( my_div_matches[i] , "{1}" + my_div_matches[i] );}</script> Obviously it's on a small scale - so don't know how it'll transfer into what you're doing.
  8. <html><head><script type="text/javascript"><!--function change_pages(val){ if(val == ""){ document.getElementById('updater').innerHTML = "Please select which page you would like to edit"; } else { document.getElementById('updater').innerHTML = "You selected " + val + "."; }}//--></script></head><body><form><select name="pages" onchange="change_pages(this.value);"><option value=""></option><option value="home">Home</option><option value="about">About</option><option value="services">Services</option><option value="media credits">Media Credits</option><option value="testimonials">Testimonials</option><option value="links">Links</option></select></form><div><h2 id="updater"></h2></div></body></html> How's that? I think it basically emulates what you were trying to do. I put the id on the h2 to save a bit of code, but obviously you can put it back on the <div> and add it to the innerHTML in the javascript.
  9. Hi again,Just change:onclick="gotoPage('My Other Page.htm')"toonclick="gotoPage('Whatever_Page.php')"etc, and you can use as many gotoPage(..)'s on the page as you like
  10. Is the website page you're wanting to fetch from on the same domain as the other pages?
  11. Check Chocolate's topic ( http://w3schools.invisionzone.com/index.php?showtopic=7340 ) on page changing. I think you're both basically wanting the same thing - i'll add in my two line loadXMLObject call later there
  12. Dan the Prof had a nicer one that he was using last week - i'm sure he'll head over here and give you his one. But yes, replacing the menu completely is the only way.I blogged about this a few weeks ago at: http://blogs.ifcode.com/webworldx/99/what-if-1/
  13. Webworldx

    NAS

    http://www.pricegrabber.com/search_getprod...terid=11165851/
  14. Yes you can, just put the first result in a div container, then keep adding the new results usingmy_div.innerHTML = extra_content + my_div.innerHTMLor use pure DOM methods like insertBefore to add the node in.
  15. Are you using IE? Unless you define the style through<div id='blog' style='display: block;'>IE won't show anything for style.display.
  16. Hi there - there is lots of them! SharePoint, Frontpage 2000/XP/03 and i'm sure Dreamweaver does.
  17. or a while loop and keep bringing up the prompt box until they enter a number or exit out :)I've never used Number() to be honest, although not sure why - I just prefer the Math.floor() and parseInt() functions
  18. Apologies for the content on there (i'm playing about with someone's site layout) - but have a look at:http://www.ifcode.com/projects/project/sc-photos_new/Is that the sort of thing you want?
  19. You can't access external sites data using javascript alone - so you're going to need something like curl or snoopy in PHP to help you if you're wanting to do that.I'm not quite getting exactly what you're wanting to do though - retrieving field values from "world wide web" :/
  20. Doesn't seem to be anything wrong with that snippet... i've extended it a bit just to show it does work without the alert: <script>function getstatus(){ return "playing";}var status = getstatus();if ( status != "playing"){ alert('not playing');} else{ alert('is playing');}</script> Runs fine and displays the correct result.
  21. I much prefer a short RegExp validation like: var theString = 'test@email.com';function testEmail(str){ var reg_email = /^[a-zA-Z0-9._-]+@([a-zA-Z0-9.-]+\.)+[a-zA-Z0-9.-]{2,4}$/; return reg_email.test(str);}var is_valid_email = testEmail(theString);alert(is_valid_email); Obviously it doesn't test correct domain extensions etc, but it's not a bad starting point. I don't really see the point in smartwebby's multiple indexOf statements, but maybe it's just me.
  22. Hi, Just to add, you had your slashes the wrong way around too:replace(/this/,"that")or replacing all matches:replace(/this/g,"that");=)
  23. Hi Martyn,Just following up on that - QuirksMode has always provided me with the best object position finder: http://www.quirksmode.org/js/findpos.html, along with what works in each browsers. Very informative
  24. Hi there LaLaLa.Most browsers won't display the status text on image maps if you've got a href attribute, so the workaround is to use onclick. <html><body><script type='text/javascript'>function gotoPage(page){ window.location.href = page;}</script><map id="links" name="links"><area shape="rect" coords="0,0,100,100" alt="Other Page" onclick="gotoPage('My Other Page.htm')" onmouseover="window.status='Click here to go to my other page'"></map><img src="Some big picture that I have.jpg" usemap="#links"></body></html>
×
×
  • Create New...