www.webdeveloper.com
Results 1 to 3 of 3

Thread: form submit

  1. #1
    Join Date
    Apr 2009
    Posts
    96

    form submit

    Hi
    Having some issues submiting a form with javascript. When I submit the form with a button I get the correct outcome however when I use document.formname.submit(); I don't. It's like some but not all of the elements of the form are being submited. I can't get server side to debug any thoughts?

    Code:
    <script language="JavaScript" type="text/javascript">
    function createcookie(name,value,days) {
        if (days) {
            var date = new Date();
            date.setTime(date.getTime()+(days*24*60*60*1000));
            var expires = "; expires="+date.toGMTString();
        }
        else{ var expires = "";}
        document.cookie = name+"="+value+expires+"; path=/";
    }
    function readcookie(name) {
        var nameEQ = name + "=";
        var ca = document.cookie.split(';');
    	var d = null;
        for(var i=0;i < ca.length;i++) {
            var c = ca[i];
            while (c.charAt(0)==' ') c = c.substring(1,c.length);
    		d = c.indexOf(nameEQ);
            if (d == 0){ return c.substring(nameEQ.length,c.length);
        }
        return null;
    }}
    function check(){
    var date = new Date();
    var mes = document.getElementById('message');
    mes.value = date.toGMTString();
    if(readcookie('coalitionlg')!=null){
    var e1 = document.getElementById('nochkedin');
    var e2 = document.getElementById('chkedinmesg');
           e1.style.display = 'none';
    		e2.style.display = 'block';
    }
    }
    function submt(){
    createcookie('coalitionlg','y','1');
    document.post.submit();
    }
    
    </script>
    <div id="nochkedin" style="display: block">
    <form action="/posting.forum" method="post" name="post">
    <input type="hidden" name="subject" id="subject" value="">
    <input type="hidden" name="notify" id="notify" value="off">
    <input type="hidden" name="mode" id="mode" value="reply">
    <input type="hidden" name="t" id="t" value="161">
    <input type="hidden" name="lt" id="lt" value="3231">
    <input type="hidden" name="message" id="message"  value="">
    
    <!-- doesn't work-->
    <a href="javascript:submt();"><img src="http://upload.wikimedia.org/wikipedia/commons/4/41/Crystal_Clear_action_loopnone.png"/></a>
    
    <!-- does work -->
    <input type="submit" name="post" value=" Check In " accesskey="s" class="button" onclick="createcookie('coalitionlg','y','1');" />
    
    </form>
    </div>
    <div id="chkedinmesg" style="display: none">
    <img src="http://upload.wikimedia.org/wikipedia/commons/d/d6/Crystal_Clear_action_apply.png" onload="check()"/>
    &nbsp;&nbsp; Great Thanks! You have already checked in.
    </div>

  2. #2
    Join Date
    Jan 2008
    Posts
    66
    Taking a shot in the dark, but could this be the problem?

    Code:
    <a href="javascript:submt();">

  3. #3
    Join Date
    Apr 2009
    Posts
    96
    that just calls
    Code:
    function submt(){
    createcookie('coalitionlg','y','1');
    document.post.submit();
    }

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

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



Recent Articles