Jump to content

nogray

Members
  • Posts

    930
  • Joined

  • Last visited

Posts posted by nogray

  1. You can modify the previous script to output a javascript array from php and use that array to loop through the elements

    function toggle_alpha(target) {
        var divs = ['A','B','C','Color','D','F','K','L','P','Q','R','S','Z']; // use php to output this array
        for (i=0; i<divs.length; i++)
            document.getElementById('Searchstring_'+divs[i]).style.display = "none";
    
        document.getElementById(target).style.display = "inline";
    }
    

     

    You can detch the document.all since IE support document.getElementById()

     

    Also, you can make a JS object that will update the HTML of the div based on the user click

    <script type="text/javascript">
    var cont = {};
    cont.A = 'this is a'; // use PHP to output these lines
    cont.B = 'this is b';
    cont.Color = 'this is color';
    
    function update_div(val){
        document.getElementById('div_id').innerHTML = cont[val];
    }
    </script>
    <div id="div_id"></div>
    

    Not tested

  2. Try to search this form on how to validate numbers (or search google) most likely you'll find a regular expression (something like value.match(/^\d+$/))

     

    Try to browse your site using firefox and after you get the error, click on "Tools" (next to File, Edit, View) and select "Error Console" This will help you find the bugs you have.

     

    I always use document.getElementById() for anything, for the select menu, try to get the option value

     

    document.AddProduct.ItemType.options[document.AddProduct.ItemType.selectedIndex].value

     

    and see if that's work.

  3. You only can access form fields by document.form.field, other elements you'll need to use document.getElementById('ID')

     

    In your code, you'll need to change

    document.mySpan5.innerHTML (or 1, 2,3,4,etc...)
    

     

    to

     

    document.getElementById('mySpan5').innerrHTML
    

     

    Hope this helps.

  4. Something like this

    function toggle_alpha(target) {
        var alphabits = "ABCDEF....Z"; // just fillin the blanks
        for (i=0; i<alphabits.length; i++)
            document.getElementById('Searchstring_'+alphabits.charAt(i)).style.display = "none";
        document.getElementById(target).style.display = "inline";
    }
    

    Not Tested

  5. okay, I just tested with document.onclick and it looks like it's working. Here is an example

    <!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>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>Untitled Document</title>
    <script language="javascript">
    	document.onclick = function(){
    		alert('here');
    	}
    </script>
    </head>
    
    <body>
    <div>Hello</div>
    
    </body>
    </html>
    

  6. Your second request override your first request. Your req variable must be a local variable in the function, try to add a var infront of it

    if (window.XMLHttpRequest) {
        var req = new XMLHttpRequest();
    }
    else if (window.ActiveXObject) {
        var req = new ActiveXObject("Microsoft.XMLHTTP");
    }
    

     

    hope that's work.

  7. For accessibility point of view, bronzemonkey is correct. Personally, if the user's browser doesn't support JS, they should either update their browser or enable JS to browse my site (if I am losing 5% because of JS is not enabled, oh well). Using a simple CSS style to make the tr looks clickable "such as cursor:pointer" will solve any display questions for the user. But the final discussion is for the website owner and how does s/he wants the user to interact with their site.

  8. it's because you're using curly quote marks in the script tag <script language=javascript>

     

    You should use normal quote marks "

     

    If you copied an example for MS Word or a website, make sure all the quote marks are " and not ”

×
×
  • 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.