Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 4 of 4
  1. #1
    Regular Coder
    Join Date
    Feb 2008
    Posts
    128
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Changing the location of a submit button & adding an image

    What code could add/change to this submit button to change it's location on the page, and to make it into an image/button. I've tried several things without success. Thanks


    Code:
    1.document.write("<form action='index.html?filename="+my_filename+"' method='POST'><input type='submit' name='record' value='record' id='record_button' />
    Here's more of the code:
    Code:
    <script type="text/javascript"><script type="text/javascript">
    var my_filename    = get_parm('filename');
     
    var file        = document.getElementById("form_filename");
    file.value        = my_filename;
    
    document.write("<form action='index.html?filename="+my_filename+"' method='POST'><input type='submit' name='record' value='Re-record' id='record_button' /></form>");
     
    var flashvars = {
    source: my_filename,
    server: "rtmp://67.xx.ww.xx./",
    type: "video",
    streamtype: "rtmp",
    poster: "poster.png",
    autostart: "false",
    logo: "logo.png",
    logoposition: "top left",
    logoalpha: "30",
    logowidth: "130",
    logolink: "http://xxxxxx",
    hardwarescaling: "false",
    darkcolor: "000000",
    brightcolor: "4c4c4c",
    controlcolor: "FFFFFF",
    hovercolor : "67A8C1"
    };
    var params = {
    allowFullscreen: "false",
    allowScriptAccess: "always",
    bgcolor: "#000000",
    quality: "high",
    scale: "noscale",
    wmode: "opaque",
    seamlesstabbing: "false"
    };
    var attributes = {};
     
    swfobject.embedSWF("JarisFLVPlayer.swf", "player", "448", "336", "9.0.0","expressInstall.swf", flashvars, params, attributes);
     
    function get_parm(name)
    {
    name        = name.replace(/[\[]/,"\\\[").replace(/[\]]/,"\\\]");
    var regexS    = "[\\?&]"+name+"=([^&#]*)";
    var regex    = new RegExp( regexS );
    var results    = regex.exec( window.location.href );
    if( results == null )
    {
    return "";
    }
    else
    {
    return results[1];
    }
    }
    </script>

  • #2
    Supreme Master coder! Old Pedant's Avatar
    Join Date
    Feb 2009
    Posts
    25,965
    Thanks
    79
    Thanked 4,429 Times in 4,394 Posts
    What possible reason is there to use document.write [which is considered obsolete and undesirable in most cases] just to create a simple HTML form?

    When possible, do not use JS code to create HTML. Prefer instead to use JS to *enhance* HTML. Which is *CERTAINLY* possible in this case.

    And now you can just use ordinary HTML to put anything you want anywhere on the page.

    And by the by, this is illegal:
    Code:
    <script type="text/javascript"><script type="text/javascript">
    You can't have one <script> tag embedded inside another.
    An optimist sees the glass as half full.
    A pessimist sees the glass as half empty.
    A realist drinks it no matter how much there is.

  • #3
    Supreme Master coder! Old Pedant's Avatar
    Join Date
    Feb 2009
    Posts
    25,965
    Thanks
    79
    Thanked 4,429 Times in 4,394 Posts
    Just for example:
    Code:
    <!DOCTYPE html>
    <html>
    <body>
    <div>
    <!-- put form tag at top of page -->
    <form id="myform" action="index.html?filename=" method='POST'>
         ... put anything you like anywhere on the page ...
    
        <button type="submit" name="record' value="Re-record" id="record_button">
            <img src="recordButtonImage.png" alt="record button"/>
        </button>
    
         ... put anything you like anywhere on the page ...
    
    <!-- end form at end of page -->
    </form>
    </div>
    <script type="text/javascript">
    var my_filename    = get_parm('filename');
    document.getElementById("myform").action += my_filename;
    </script>
    </body>
    </html>
    I realize that, because of the way you chose to do it, the JS code to create the swfobject has to be in-line in the page. But nothing else does.
    An optimist sees the glass as half full.
    A pessimist sees the glass as half empty.
    A realist drinks it no matter how much there is.

  • #4
    Supreme Master coder! Old Pedant's Avatar
    Join Date
    Feb 2009
    Posts
    25,965
    Thanks
    79
    Thanked 4,429 Times in 4,394 Posts
    One last thing... It seems strange to me that you would use method="post" with your <form> and yet still have a querystring in the action=.

    On top of that, you say the action page is "index.html". But HTML pages can't process method="post". Are you using URL rewriting to actually point index.html to some server-side code, a PHP or JSP page or whatever? If not, I don't see how you can use post.

    In any case, wouldn't it be better to be consistent? Send all the data to the next page as either get or post?

    In which case, change to
    Code:
    <form id="myform" action="index.html" method="??? which one???" >
    <input type="hidden" name="filename" />
    ...
    </form>
    </div>
    <script type="text/javascript">
    var my_filename    = get_parm('filename');
    document.getElementById("myform").filename.value = my_filename;
    </script>
    An optimist sees the glass as half full.
    A pessimist sees the glass as half empty.
    A realist drinks it no matter how much there is.


  •  

    Posting Permissions

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