• Resolved Armin100

    (@armin100)


    Hi, is it possible to have 2 forms with one submit button.
    I seem to have a problem since the action’s of the 2 forms are different.

    These are my two forms. I have tried to combine them using a similar action but one of the submits wouldn’t work.

    <form action="<?php echo htmlspecialchars($_SERVER['REQUEST_URI']); ?>" method="post">
    <form id="new_post" name="new_post" method="post" action="<?php bloginfo( 'url' ); ?>/">

    Any suggestions?

Viewing 11 replies - 1 through 11 (of 11 total)
  • Ok, but what exactly is your question? ??

    Thread Starter Armin100

    (@armin100)

    How can I have both of the forms with one submit button?

    If I can’t how can I combine them so that the information of the form is processed.

    If your wondering, I am basically trying to to combine QuickPress and WP-polls together.

    With JS you can.
    https://www.google.co.uk/search?q=two+forms+one+submit

    Havn’t tried it myself, but you’re certainly not the first person to ask… ??

    Thread Starter Armin100

    (@armin100)

    I have tried many of those codes including javascript but it wouldn’t work. I basically went through 2-3 pages looking for an answer.

    Is it because the actions are different?

    Well certainly if you have two different actions then it’s not going to work, you can’t submit to two seperate URLs at once.

    If you’d like to expand on what it is you’re trying to do, i’ll see if i can offer any further suggestions.

    Thread Starter Armin100

    (@armin100)

    If you know the WP-Polls plugin it operates inside of wordpress admin. I managed to get it to work outside of wordpress admin and inside the site. WP-Polls uses embed feature: Example: “[pollid=2]” onto a post. So i found out that the embed also works on quickpress. So now what I am trying to do is get both forms into one page with one submit button. Both of the forms work, but the problem is im trying to make them work together. 2 Forms, 2 different actions, 1 submit button.

    Above i showed the code for both of the forms. Top one is for wp-polls and bottom one is for quickpress. I tried to change the actions but it would disable one of the functions, either quickpress or wp-polls. So this is why I am trying to do 2 forms on one page with a submit.

    WordPress.com has WP-Polls intergrated with the QuickPress widget (i use a WordPress.com blog), i wonder how it was done there.

    Why wonder actually .. (looked whilst writing the reply)

    <a href="admin.php?page=polls&iframe&TB_iframe=true&width=640&height=632" onclick="return false;" id="add_poll" class="thickbox" title="Add Poll"><img src="/wp-content/admin-plugins/polldaddy/polldaddy.png" alt="Add Poll"></a>

    Looks like they use the thickbox modal(what the media uploads, theme preview and various other bits use) for loading the polls plugin.

    Thread Starter Armin100

    (@armin100)

    Im confused, how does this solve my problem?

    What im trying to do is get both the polls to submit and the quickpress content.

    So on a separate page (outside of wordpress admin) i had setup the wp-polls. The Add Poll form. So people can create the poll with the content rather than going to the poll, then getting the id for it and making the post. Basically AIO form.

    I really appreciate your help.

    No it doesn’t solve the problem, i don’t know how to solve it unfortunately, i was just pointing out that WordPress.com uses polls in the QuickPress widget and how they do it, if it’s over your head then it probably didn’t help much.

    Thread Starter Armin100

    (@armin100)

    Alright. Thanks anyways.

    I’ve realised my previous statement was actually wrong, wordpress.com uses the polldaddy plugin, not wp-polls, and i’ve come up with something for you…(read on).

    What about a jQuery solution that does the same thing as the post editor poll button?

    One small downside, it always places the poll shortcode at the end of the content, keeps the script light, and saves me hours of time figuring out how to track the position in the content. If you can live with that, try out the code below (assuming you still have wp-polls activated), most of the code below is borrowed from that plugin..

    if( is_admin() ) {
    	function add_poll_button_qp() {
    		?>
    		<script type="text/javascript">
    		/* <![CDATA[ */
    		var poll_messages = {
    			enter_poll_id: "Enter Poll ID",
    			enter_poll_id_again: "Error: Poll ID must be numeric\n\nPlease enter Poll ID again",
    		};
    		jQuery(document).ready( function($) {
    			$('#media-buttons').append('<a id="poll" href="#" title="Insert Poll Shortcode"><img src="<?php echo plugins_url('wp-polls/images/poll.png'); ?>" height="12" width="12" border="0" /></a>');
    			$('#poll').click( function() {
    				var poll_id = jQuery.trim( prompt( poll_messages.enter_poll_id ) );
    				while( isNaN( poll_id ) ) {
    					poll_id = jQuery.trim( prompt( poll_messages.enter_poll_id_again ) );
    				}
    				if( poll_id >= 1 && poll_id != null && poll_id != "") {
    					$( edCanvas ).val($( edCanvas ).val()+'[poll id="' + poll_id + '"]');
    				}
    				return false;
    			});
    		});
    		/* ]]> */
    		</script>
    		<?php
    	}
    	add_action( 'admin_head-index.php' , 'add_poll_button_qp' );
    }

    Can be placed in your theme’s functions.php to make it easy.. (can convert into plugin if you have a problem copying the above into your functions file).

    You’ll see the poll image next to the other media buttons in the QuickPress widget, it will work exactly the same as the button you have in the main post editor, with exception to tracking where your cursor currently is in the content.

Viewing 11 replies - 1 through 11 (of 11 total)
  • The topic ‘2 Forms with one Submit Button?’ is closed to new replies.