Discover Habbo's history
Treat yourself with a Secret Santa gift.... of a random Wiki page for you to start exploring Habbo's history!
Happy holidays!
Celebrate with us at Habbox on the hotel, on our Forum and right here!
Join Habbox!
One of us! One of us! Click here to see the roles you could take as part of the Habbox community!


Results 1 to 6 of 6
  1. #1
    Join Date
    Nov 2007
    Posts
    88
    Tokens
    0

    Default Form action help please

    How come:
    Code:
    <form method='post' action='javascript:ajaxpage\(\'http://www.*****.com/staff/request.php?op=reg\'\,%20\'contentarea\'\)\;'>
    doesn't work.

    it's on a php page to make a form do what i've put there.
    i take it i can't make a submit button do javascript?

    or i've totally messed it up somewhere.

    url blocked out btw.

    Current full page:
    Code:
    <? 
    
    include "config.php";
    include "front_page_stats.php";
    
    ?>
    
    <html>
    
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
    <title>Request Line</title>
    <style type="text/css">
    body {background-color: transparent}
    </style>
    <link href="../css/staff.css" rel="stylesheet" type="text/css" />
    
    </head>
    
    <body>
    
    <div class="headn blue">Request &amp; Shoutout Line</div>
    Want to send a message to a DJ? Well here is the place to do so. Whether you've come to enter a competition, ask for a song or just want to say something that's on your mind, this is the form <em>you</em> need to fill in.<br />
    Your IP is: <? $ip=$_SERVER['REMOTE_ADDR']; echo "<strong>$ip</strong>"; ?>. This is sent with the request for security issues.<br />
    
    <?
    
    if($_GET["op"] == "reg") {
    
    //$result = mysql_query("SELECT * FROM `staff`");
    
    //while($worked = mysql_fetch_array($result)) {
    
    //$get_word = $worked['username'];
    
    //if(preg_match("/$get_word/i", "$servertitle")) { $dj_name = "$get_word"; }
    
    //}
    
    $dj_name = addslashes($_POST["dj_name"]);
    
    if($dj_name == "Choose One...") { echo "<br /><br /><strong>You need to select a DJ or No one will receive your message!</strong>"; exit; }
    
    $habboname = $_POST["habboname"];
    $message = $_POST["message"];
    
    if($habboname == "") { echo "<br /><br /><strong>Please fill in your Habbo name.</strong><br />"; exit; }
    
    $habboname = addslashes($_POST["habboname"]);
    
    $request = addslashes($_POST["request"]);
    
    $type = addslashes($_POST["type"]);
    
    $ip = getenv("REMOTE_ADDR");
    
    $date = date("d.m.y - H:i:s");
    
    $query = mysql_query("INSERT INTO `requests` (`habboname`, `type`, `dj_name`, `message`, `ip`, `date`) VALUES('$habboname', '$type', '$dj_name', '$request', '$ip', '$date' )");
    
    echo "<br /><br /><strong>Thank you <em>$habboname</em> for your <em>$type</em> stay tuned your message may appear soon!<META HTTP-EQUIV='Refresh' CONTENT='2;URL=request.php";
    
    } else { echo "
    
    <form method=\"get\" action=\"#\" onsubmit=\"javascript:ajaxpage('http://eachhabbo.com/staff/request.php?op=reg', 'contentarea'); return false;\">
    
    <br /><br />Habbo Name:<br />
    <input type='text' name='habboname' size='30'></font><br /><br />
    
    Type:<br />
    <select name='type'>
    <option value='Request'>Request</option>
    <option value='Shoutout'>Shoutout</option>
    <option value='Joke'>Joke</option>
    <option value='Other'>Other</option>
    <option value='Comp'>Competition</option>
    </select><br /><br />
    
    Select A DJ:<br />
    <select name='dj_name'>";
    
    $result = mysql_query("SELECT * FROM `staff`");
    
    while($worked = mysql_fetch_array($result)) {
    
    $get_word = $worked['username'];
    
    if(preg_match("/$get_word/i", "$servertitle")) { echo "<option value='$get_word' selected>DJ $get_word</option>"; }
    
    else { echo "<option value='$get_word'>DJ $get_word</option>"; }
    
    }
    
    echo "</select><br /><br />
    
    Your Message:<br />
    <textarea rows='3' cols='35' type='text' name='request' class='button'></textarea><br /><br />
    
    <input type='submit' name='submit' value='Send Your Message'>";}
    
    ?> 
    
    </body>
    
    </html>
    Also tried (and a few variations of these):
    <form method="get" action="#" onsubmit="ajaxpage('http://www.*****.com/staff/request.php?op=reg', 'contentarea'); return false;">
    <form method="post" onsubmit="javascript:ajaxpage('http://www.*****.com/staff/request.php?op=reg', 'contentarea');">
    <form method='post' onsubmit='javascript:ajaxpage\(\'http://www.*****.com/staff/request.php?op=reg\'\,%20\'contentarea\'\)\;'>
    Do do do

  2. #2

    Default

    I suggest using unobtrusive javascript which means no inline javascript which allows you to manage it easier. If you want I could possible convert it to jQuery - I know this is not what you asked, but I think it could be beneficial. As for the 2nd variation you tried that looks like i'd work in my opinion. Maybe get Firebug (Firefox Plugin) and see if any errors occur.

  3. #3
    Join Date
    Nov 2007
    Posts
    88
    Tokens
    0

    Default

    Quote Originally Posted by Iszak View Post
    I suggest using unobtrusive javascript which means no inline javascript which allows you to manage it easier. If you want I could possible convert it to jQuery - I know this is not what you asked, but I think it could be beneficial. As for the 2nd variation you tried that looks like i'd work in my opinion. Maybe get Firebug (Firefox Plugin) and see if any errors occur.
    How do I use that then?
    I'm using http://dynamicdrive.com/dynamicindex17/ajaxcontent.htm that script.

    I'll try that Firebug thing
    Do do do

  4. #4
    Join Date
    Nov 2007
    Posts
    88
    Tokens
    0

    Default

    bump.

    anyone help?
    Do do do

  5. #5
    Join Date
    May 2006
    Posts
    1,797
    Tokens
    0

    Latest Awards:

    Default

    Ummm i dont think you can have the action as loading a javascript page lool, You'll need to make a function that converts the form data into $_GET data for example and load the page with JS using the parameters for $_GET and process that way if that makes any sense to you?
    Coming and going...
    Highers are getting the better of me

  6. #6
    Join Date
    May 2006
    Location
    Hull
    Posts
    7,701
    Tokens
    2,430
    Habbo
    Moh

    Latest Awards:

    Default

    To submit a form via javascript, I would use prototype.

    Simplest way =D

    HTML Code:
    <script>
    function submitRequest()
    {
        habboname = document.getElementById('habboname').value;
        type = document.getElementById('type').value;
        dj_name = document.getElementById('dj_name').value;
        request = document.getElementById('request').value;
    
        new Ajax.Request('sendrequest.php',
            {
                parameters: {habboname: habboname, type: type, dj_name: dj_name, request: request},
                onSuccess: function(transport)
                {
                    $('content').innerHTML = transport.responseText;
                }
            });
    }
    </script>
    then for your form:

    HTML Code:
    <form action="javascript: submitRequest();" method="post">

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •