www.webdeveloper.com
Results 1 to 2 of 2

Thread: Submitting forms thru javascript

  1. #1
    Join Date
    Jun 2005
    Posts
    128

    Submitting forms thru javascript

    I currently have the following page in which I call a function to check which button is clicked then submitting the form. However, I'm not able to get the form to submit. Can someone please help me?

    HTML Code:
    <html>
    <head>
        <title>ECD Form</title>
        <script type="text/javascript">
            function deleteECP(delYesNo) {
                if (delYesNo) {
                    delYN = confirm("Deleting this ECP will also delete all associated CNs.\n\nAre you sure you want to delete this ECP?");
                    if (delYN) {
                        document.form1.submit();
                    } else {
                        return false;
                    }
                } else {
                    document.form1.submit();
                }
            }
        </script>
    </head>
     
    <body>
     
        <form id="form1" action="ECD_propsSubform.asp" method="post">
            <input type="hidden" id="id" name="id" value="36" />
            <input type="hidden" name="ecpID" id="ecpID" value="2175" />
            <table cellspacing="1" border="0">
                <tr>
                    <td colspan="3">
                        <table width="100%" border="0">
                            <tr>
                                <td><img src="trnsp.gif" width="75" height="1" border="0" /></td>
                                <td><img src="trnsp.gif" width="270" height="1" border="0" /></td>
                                <td><img src="trnsp.gif" width="150" height="1" border="0" /></td>
                                <td><img src="trnsp.gif" width="150" height="1" border="0" /></td>
                            </tr>
                            <tr>
                                <td>ECP</td>
                                <td>Title</td>
                                <td>&nbsp;</td>
                            </tr>
                            <tr valign="top">
                                <td><input type="text" class="text" id="ecp" name="ecp" size="5" value="445" /></td>
                                <td><textarea name="title" id="title" rows="2" cols="50">Testing</textarea></td>
                            </tr>
                            <tr>
                                <td>Description</td>
                            </tr>
                            <tr>
                                <td colspan="3"><textarea name="desc" id="desc" rows="4" cols="80"></textarea></td>
                            </tr>
                        </table>
                    </td>
                </tr>
                <tr>
                    <td colspan="3" align="center"><input type="button" value="Update ECP Data" name="update" onclick="deleteECP(false)" id="update" />&nbsp;&nbsp;<input
                        type="button" onclick="deleteECP(true)" value="Delete ECP" name="delete" id="delete" /></td>
                </tr>
                
            </table>
        </form>
    </body>
    </html>

  2. #2
    Join Date
    Dec 2003
    Location
    Bucharest, ROMANIA
    Posts
    15,428
    the reference
    Code:
    document.form1
    is looking for an element with the name="form1", not with the id="form1". name and id are not the same (well, yes, IE do a mismatch in this case, but let's forget about it). Try this fully crossbrowser:
    Code:
    document.getElementById('form1').submit();
    Last edited by Kor; 07-28-2009 at 09:58 AM.

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

"

"

X vBulletin 4.2.2 Debug Information

  • Page Generation 0.15545 seconds
  • Memory Usage 2,861KB
  • Queries Executed 15 (?)
More Information
Template Usage (34):
  • (1)SHOWTHREAD
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_global_above_footer
  • (1)ad_global_below_navbar
  • (1)ad_global_header1
  • (1)ad_global_header2
  • (1)ad_navbar_below
  • (1)ad_showthread_firstpost_sig
  • (1)ad_showthread_firstpost_start
  • (1)ad_thread_first_post_content
  • (1)ad_thread_last_post_content
  • (2)bbcode_code
  • (1)bbcode_html
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)headinclude_bottom
  • (2)memberaction_dropdown
  • (1)navbar
  • (4)navbar_link
  • (1)navbar_moderation
  • (1)navbar_noticebit
  • (1)navbar_tabs
  • (2)option
  • (2)postbit
  • (2)postbit_onlinestatus
  • (2)postbit_wrapper
  • (1)spacer_close
  • (1)spacer_open
  • (1)tagbit_wrapper 

Phrase Groups Available (6):
  • global
  • inlinemod
  • postbit
  • posting
  • reputationlevel
  • showthread
Included Files (26):
  • ./showthread.php
  • ./global.php
  • ./includes/class_bootstrap.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/functions_navigation.php
  • ./includes/class_friendly_url.php
  • ./includes/class_hook.php
  • ./includes/class_bootstrap_framework.php
  • ./vb/vb.php
  • ./vb/phrase.php
  • ./includes/functions_facebook.php
  • ./includes/functions_calendar.php
  • ./includes/functions_bigthree.php
  • ./includes/class_postbit.php
  • ./includes/class_bbcode.php
  • ./includes/functions_reputation.php
  • ./includes/functions_notice.php
  • ./packages/vbattach/attach.php
  • ./vb/types.php
  • ./vb/cache.php
  • ./vb/cache/db.php
  • ./vb/cache/observer/db.php
  • ./vb/cache/observer.php 

Hooks Called (70):
  • init_startup
  • friendlyurl_resolve_class
  • init_startup_session_setup_start
  • database_pre_fetch_array
  • database_post_fetch_array
  • init_startup_session_setup_complete
  • global_bootstrap_init_start
  • global_bootstrap_init_complete
  • cache_permissions
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • load_show_variables
  • load_forum_show_variables
  • global_state_check
  • global_bootstrap_complete
  • global_start
  • style_fetch
  • global_setup_complete
  • showthread_start
  • showthread_getinfo
  • strip_bbcode
  • friendlyurl_clean_fragment
  • friendlyurl_geturl
  • forumjump
  • cache_templates
  • cache_templates_process
  • template_register_var
  • template_render_output
  • fetch_template_start
  • fetch_template_complete
  • parse_templates
  • fetch_musername
  • notices_check_start
  • notices_noticebit
  • process_templates_complete
  • friendlyurl_redirect_canonical
  • showthread_post_start
  • showthread_query_postids
  • showthread_query
  • bbcode_fetch_tags
  • bbcode_create
  • showthread_postbit_create
  • postbit_factory
  • postbit_display_start
  • postbit_imicons
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • postbit_display_complete
  • memberaction_dropdown
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • build_navigation_data
  • build_navigation_array
  • check_navigation_permission
  • process_navigation_links_start
  • process_navigation_links_complete
  • set_navigation_menu_element
  • build_navigation_menudata
  • build_navigation_listdata
  • build_navigation_list
  • set_navigation_tab_main
  • set_navigation_tab_fallback
  • navigation_tab_complete
  • fb_like_button
  • showthread_complete
  • page_templates