Javascript Help.

Discussion in 'Web Design and Development' started by itemobile, Oct 13, 2009.

  1. itemobile macrumors newbie

    Joined:
    Oct 13, 2009
    #1
    I am trying to get a Javascript "script" to do a function for me.

    I am trying to write a a script that will run while the webpage is open, that is selected a randomized 9 digit number Less than 350000000 that will be put into a textbox and submitted. I want a adjustable time when it submits. Could this be made into an <iframe>? Also, this has to do it to a different website, not the one locally being opened.

    Thank you for your help.
     
  2. angelwatt Moderator emeritus

    angelwatt

    Joined:
    Aug 16, 2005
    Location:
    USA
    #2
    So, essentially, you're wanting a way to automatically submit data on someone else's web site form? Sounds like a spam bot.
     
  3. itemobile thread starter macrumors newbie

    Joined:
    Oct 13, 2009
    #3
    its seems like a spam script, correct. But in fact, it is a database script I want to run from my iphone while evaluating clients databases. I used to run a VB-created app that did this for me. Well, I have gone more mobile, and Vb doesnt run on my iPhone sadly.

    What i got so far is:

    Code:
    <html>
    <head>
    <script>
    function postNumber()
    {
        var randy = Math.floor(Math.random() * 250000000) +100000000;
        var fr = document.frames["postFrame"].document;
        fr.write( '<html><body>\n'
                +  '<form method="post" action="http://www.cnn.com">\n'
                +  '<input name="theNumber" value="' + randy + '">\n'
                +  '</form></body></html>');
        fr.forms[0].submit();
    }
    </script>
    </head>
    <body onload="postNumber()">
    This is the main page.
    <br/><br/>
    <iframe name="postFrame" style="width: 100%; height: 100px;">
    </iframe>
    </body>
    </html>
     
  4. angelwatt Moderator emeritus

    angelwatt

    Joined:
    Aug 16, 2005
    Location:
    USA
    #4
    Looks like you're trying to write content into another web site. This is a security issue and you won't be able to get around it. Otherwise, people could put content onto anyone's web site. The better approach is to submit the data with AJAX. You can use it to send post messages. Though, the site could block these attempts, I know I do. The other way involves using curl and spam bot tactics that I won't go into. If you're submitting data to a site you own then you can easily set something up that will let you do it with AJAX.
     
  5. itemobile thread starter macrumors newbie

    Joined:
    Oct 13, 2009
  6. angelwatt Moderator emeritus

    angelwatt

    Joined:
    Aug 16, 2005
    Location:
    USA
  7. itemobile thread starter macrumors newbie

    Joined:
    Oct 13, 2009

Share This Page