Jump to content

HawkDev

Members
  • Posts

    8
  • Joined

  • Last visited

Posts posted by HawkDev

  1. 6 minutes ago, dsonesuk said:

    Using document.write is a problematic  option to code with, you might  also have problem with jquery function running before the element has rendered fully. Try placing code after html elements it is referring  to.

    <html charset='ISO-8859-1'>
    
    <head>
    
    <link rel="stylesheet" type="text/css" href="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8/themes/base/jquery-ui.css">
    <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.4/jquery.min.js"></script>
    <script src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8/jquery-ui.min.js"></script>
    
    <script type="text/javascript">
    
    function getBrowserName() {
        var name = "Unknown";
        if(navigator.userAgent.indexOf("MSIE")!=-1){
            name = "MSIE";
        }
        else if(navigator.userAgent.indexOf("Firefox")!=-1){
            name = "Firefox";
        }
        else if(navigator.userAgent.indexOf("Opera")!=-1){
            name = "Opera";
        }
        else if(navigator.userAgent.indexOf("Chrome") != -1){
            name = "Chrome";
        }
        else if(navigator.userAgent.indexOf("Safari")!=-1){
            name = "Safari";
        }
        return name;   
    }
    
    
    var datefield=document.createElement("input");
    datefield.setAttribute("type", "date");
    
      
     
    </script>
    </head>
    
     
    <body>
    <form>
    <b>Date of birth:</b>
    <input type="date" id="birthday" name="birthday" size="20" />
    <input type="button" value="Submit" name="B1"></p>
    </form>
    
    
    <script type="text/javascript">
    
    if(getBrowserName() == "Safari"){
       jQuery(function($){ 
          $('#birthday').datepicker();
       });
    } else {
        alert("You are surfing on " + getBrowserName(name));
    } 
    </script>
    </body>
    </html>

    Do you mean like this? There is no change in whether it is working.

  2. This problem is driving me nuts!!!

    I have checked using browser detection, and I can get the code to recognise the browser. I also managed to get it to load the jQuery as a consequence of that, but no matter what I do, I am not getting the drop down calendar that I was getting in the date picker field. I have checked that the type of the field is being recognised, and it is. It is just not producing the calendar. What could I possibly be doing wrong at this point? I created a brief sample of code to show the basic elements of what is in my code. Can you please explain where I might be going wrong?

     

    <html charset='ISO-8859-1'>
    
    <head>
    <script type="text/javascript">
    
    function getBrowserName() {
        var name = "Unknown";
        if(navigator.userAgent.indexOf("MSIE")!=-1){
            name = "MSIE";
        }
        else if(navigator.userAgent.indexOf("Firefox")!=-1){
            name = "Firefox";
        }
        else if(navigator.userAgent.indexOf("Opera")!=-1){
            name = "Opera";
        }
        else if(navigator.userAgent.indexOf("Chrome") != -1){
            name = "Chrome";
        }
        else if(navigator.userAgent.indexOf("Safari")!=-1){
            name = "Safari";
        }
        return name;   
    }
    
    
    var datefield=document.createElement("input");
    datefield.setAttribute("type", "date");
    if( getBrowserName() == "Safari" ){
    
        document.write('<link href="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8/themes/base/jquery-ui.css" rel="stylesheet" type="text/css" />\n');
        document.write('<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.4/jquery.min.js"><\/script>\n');
        document.write('<script src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8/jquery-ui.min.js"><\/script>\n');
    }
    
      
    if(getBrowserName() == "Safari"){
       jQuery(function($){ 
          $('#birthday').datepicker();
       });
    } else {
        alert("You are surfing on " + getBrowserName(name));
    } 
     
    </script>
    </head>
    
     
    <body>
    <form>
    <b>Date of birth:</b>
    <input type="date" id="birthday" name="birthday" size="20" />
    <input type="button" value="Submit" name="B1"></p>
    </form>
    </body>
    </html>

     

  3. I have been using a jquery work around for a datepicker which until today has been working perfectly. Suddenly, it has stopped functioning, so that the drop down calendar no longer appears. The code that I have used for the date picker is as follows:

    <script type="text/javascript">
        var datefield=document.createElement("input");
        datefield.setAttribute("type", "date");
    
        if (datefield.type!="date"){ //if browser doesn't support input type="date", load files for jQuery UI Date Picker
            document.write('<link href="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8/themes/base/jquery-ui.css" rel="stylesheet" type="text/css" />\n');
            document.write('<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.4/jquery.min.js"><\/script>\n');
            document.write('<script src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8/jquery-ui.min.js"><\/script>\n');
        }
    </script>
     
    <script>
    if (datefield.type!="date"){ //if browser doesn't support input type="date", initialize date picker widget:
        jQuery(function($){ //on document.ready
            $('#eventDate').datepicker({
    			dateFormat: "dd-mm-yy"
    		})
        })
    }
    </script>

    In the past, this was always a work around for the lack of  compatibility with the Safari browser. Has something changed? 

  4. Thank you. I understand that I can use an event handler like ‘onchange’. That is not difficult. However, what I am struggling with is how to save the data between the change of choice in the drop down menu, and the reload of the page. 

  5. I have an online form, which has various dropdown lists. One of these is for names of clients, one is for the location, one is for time of appointment, etc. It also has a function to add items onto the dropdown lists if it is a new client. This means that the page has to be reloaded to repopulate the dropdown list with the new client name.

    However, there are a lot of different dropdown lists on the form, and if the page is reloaded, I want the particular selections that the user has already made to be reloaded when the page is reloaded, so that they do not have to start again just because one dropdown list needed to be edited.

    Can you please explain how to do this? Thank you.

×
×
  • Create New...