Jump to content

nogray

Members
  • Posts

    930
  • Joined

  • Last visited

Posts posted by nogray

  1. If you remove the function or only allow it to work one time, you would need to create a function for each input field (which defeats the purpose of a function). You can do something like this instead (notice the title is the same as the default value)

    <input type="text" value="Default Value" title="Default Value" onfocus="if (this.value == this.title) this.value = '';" onblur="if (this.value == '') this.value = this.title;" />
    

  2. Since you are in an iframe within an iframe, you would need to create a few functions

     

    in the main page (outside the iframes), create a function that update the value

    ie function update_val(val) { document.getElementById('my_id').value = val; }

     

    in the first iframe window, you'll need to create a function that call the parnet update_val function. (function something(val) {parent.update_val(val);})

     

    In the last iframe, you'll need to make a function that call that function. You also try to call parent.parent.update_val(val) from the inside iframe.

     

     

  3. Try to change it to the following and see if that's solve the problem

     

    <html>
    <head>CSS</head>
    <body>
    html code
    
    JS source files
    
    script tag
    
    $(document).ready(function(){
    script code that require dom
    });
    
    </body>
    </html>
    

  4. This could be because of loading from cache and execution time. If javascript runs before the dom is created, you will get errors. This happens even if you put the code below the dom element because new browsers execute cached or local javascript very fast.

     

    You would need ot make sure everything is loaded and use the ready function.

  5. Yes, the function pass the entire query into a php via post and some scripts out there actually do some dumb stuff like that. A few years ago someone asked me to check why his video sharing website database was wiped clean. After reviewing the code, I found that the script was creating the mysql query in javascript and passing them into php via post. With so many scripts out there, there is always someone who contributes unsecure code without knowing the problems it can cause.

  6. Here is a very simple ajax request. If you are building a game and don't know how to do this, you might want to consider hiring someone.

    // call the ajax request by using update_xy(New X, New Y);
    
    function update_xy(x, y){
    // make sure to validate the x and y values in your php page
    var url = 'my_page.php?X='+x+'&Y='+y;
    
    var xhr = new XMLHttpRequest();
    this.privates.xhr.open("GET", url, true);
    xhr.send(null);
    }
    

    Not tested

  7. Simple, something like this will work

    <div id="my_cal_div"></div>
    ....
    later after adding the script files
    .....
    <script type="text/javascript">
    ng.ready(function(){
        // review the link in my previous post for all the possible options
        var my_cal = new ng.Calendar({object:'my_cal_div', visible:true});
    });
    </script>
    

  8. Databases are queried via user input all the time.  What do you think a user registration form ultimately does?  Or when data is retrieved based on a GET value?  The key is in sanitizing the input.

    Yes, but the data is validated and filtered before you store them in the database and the actual query happens in the backend. I've seen open source project where they use something like this

    ajax.query("update `sometable` set `something` = 'something'");
    

    on the front end javascript code. As you can see, that's a huge security risk. All I ment is to never run an actual sql query from a user input. Collect the parts you need for the query, validate, filter and run it in the backend.

  9. You connect to the database using PHP. Never run a query on your database from a user input or your website will be hacked right away. To change the session variable, simple call a php page that will change the session variable to whatever you want (directly or via ajax).

  10. I am not a jquery expret, but try to change

    $('#my_form').submit();

    with

    document.getElementById('my_form').submit();

     

    If still no luck, try to comment out the code inside the suggest function and comment out the 2 lines above the submit code to make sure nothing is causing an error in your code.

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