www.webdeveloper.com
Results 1 to 6 of 6

Thread: [RESOLVED] drop down

Hybrid View

  1. #1
    Join Date
    Feb 2013
    Posts
    3

    resolved [RESOLVED] drop down

    Hello,

    i have a problem with drop down menu, it doens't gives the value trough.

    HTML Code:
    <label>Boogschieten of Valkerij</label>
               <select id = "keuze" name="keuze">
               <option value = "">Keuze</option>
              <option value = "Boogschieten">Boogschieten</option>
              <option value = "Valkerij">Valkerij</option>
             </select>
    javascript :
    Code:
    	
    var keuze = $("input#keuze").val();
    if ( document.getElementById('keuze').selectedIndex == 0 ) {
    $("#error").fadeIn().text("Gelieve een keuze  te maken");
    $("input#web").focus();
    return false;
    }
    PHP Code:
    <?php
    //vars
    $subject $_POST['subject'];
    $to explode(','$_POST['to'] );

    $from $_POST['email'];

    //data

    $msg .= "KEUZE: " .$_POST['keuze']    ."<br>\n";

    //Headers
    $headers  "MIME-Version: 1.0\r\n";
    $headers .= "Content-type: text/html; charset=UTF-8\r\n";
    $headers .= "From: <".$from">" ;


    //send for each mail
    foreach($to as $mail){
       
    mail($mail$subject$msg$headers);
    }

    ?>

    what I get for KEUZE in the email is : [object HTMLSelectElement]

  2. #2
    Join Date
    Mar 2009
    Location
    Wherever i lay my hat
    Posts
    180
    Can you post your whole code? It's really hard to guess with the info you provided. But for starters,

    $("input#keuze")

    returns an empty set, because you are looking for select, not input.

  3. #3
    Join Date
    Feb 2013
    Posts
    3
    Quote Originally Posted by haulin View Post
    Can you post your whole code? It's really hard to guess with the info you provided. But for starters,

    $("input#keuze")

    returns an empty set, because you are looking for select, not input.
    HTML Code:
    <script type="text/javascript" src="js/form_bestel-validation.js"></script>
    							<form id="contactFormBestel" action="#" method="post">
    								<fieldset>
    									<p>
    										<label>NAAM:</label>
    										<input name="name"  id="name" type="text" />
    									</p>
    									<p>
    										<label>EMAIL:</label>
    										<input name="email"  id="email" type="text" />
    									</p>
    									<p>
    										<label>TELEFOON:</label>
    										<input name="tele"  id="tele" type="text" />
    									</p>
                                        <p>
    										<label>ADRES:</label>
    										<input name="adres"  id="adres" type="text" />
    									</p>
                                         <p>
               							  <label>Boogschieten of Valkerij</label>
               							  <select id = "keuze" name="keuze">
               							    <option value = "">Keuze</option>
              							     <option value = "Boogschieten">Boogschieten</option>
                                             <option value = "Valkerij">Valkerij</option>
              								   </select>
         							    </p>
                                        <p>
    										<label>AANTAL BONNEN:</label>
    										<input name="bon"  id="bon" type="text" />
    									</p>
    									<p>
    										<label>COMMENTAAR:</label>
    										<textarea  name="comments"  id="comments" rows="5" cols="20" ></textarea>
    									</p>
    									
    									<!-- send mail configuration -->
    									<input type="hidden" value="info@boogschieteninbelgie.be" name="to" id="to" />
    									<input type="hidden" value="info@boogschieteninbelgie.be" name="from" id="from" />
    									<input type="hidden" value="Bestelling via nieuwe website" name="subject" id="subject" />
    									<input type="hidden" value="Bestel.php" name="sendMailUrl" id="sendMailUrl" />
    									<!-- ENDS send mail configuration -->
    									
    									<p><input type="button" value="SEND" name="submit" id="submit" /></p>
    								</fieldset>
    								<p id="error" class="warning">Message</p>
    							</form>
    							<p id="success" class="success">Merci voor de aanvraag, we behandelen deze zo snel mogelijk.</p>
    							<!-- ENDS form -->

    Code:
    $(document).ready(function(){
    
    	// hide messages 
    	$("#error").hide();
    	$("#success").hide();
    	
    	// on submit...
    	$("#contactFormBestel #submit").click(function() {
    		$("#error").hide();
    		
    		//required:
    		
    		//name
    		var name = $("input#name").val();
    		if(name == ""){
    			$("#error").fadeIn().text("Gelieve u naam in te vullen");
    			$("input#name").focus();
    			return false;
    		}
    		
    		// email
    		var email = $("input#email").val();
    		if(email == ""){
    			$("#error").fadeIn().text("Gelieve u email in te vullen");
    			$("input#email").focus();
    			return false;
    		}
    		
    		// telefoon
    		var tele = $("input#tele").val();
    		if(tele == ""){
    			$("#error").fadeIn().text("Gelieve u telefoon in te vullen");
    			$("input#web").focus();
    			return false;
    		}
    		
    		// adres
    		var adres = $("input#adres").val();
    		if(adres == ""){
    			$("#error").fadeIn().text("Gelieve u adres in te vullen");
    			$("input#web").focus();
    			return false;
    		}
    
    	// keuze lijst
    		var keuze = $("input#keuze").val();
    		if ( document.getElementById('keuze').selectedIndex == 0 ) {
           		 $("#error").fadeIn().text("Gelieve een keuze  te maken");
    			$("input#web").focus();
            return false;
    		}			
    			
    		// Aantal bonnnen
    		var bon = $("input#bon").val();
    		if(bon == ""){
    			$("#error").fadeIn().text("Gelieve het aantal bonnen in te vullen");
    			$("input#web").focus();
    			return false;
    		}
    		
    		// comments
    		var comments = $("#comments").val();
    		if(comments == ""){
    			$("#error").fadeIn().text("Gelieve u vraag in te vullen");
    			$("input#web").focus();
    			return false;
    		}
    		
    		// send mail php
    		var sendMailUrl = $("#sendMailUrl").val();
    		
    		//to, from & subject
    		var to = $("#to").val();
    		var from = $("#from").val();
    		var subject = $("#subject").val();
    		
    		// data string
    		var dataString = 'name='+ name
    						+ '&email=' + email        
    						+ '&tele=' + tele
    						+ '&adres=' + adres
    						+ '&keuze=' + keuze
    						+ '&bon=' + bon
    						+ '&comments=' + comments
    						+ '&to=' + to
    						+ '&from=' + from
    						+ '&subject=' + subject;						         
    		// ajax
    		$.ajax({
    			type:"POST",
    			url: sendMailUrl,
    			data: dataString,
    			success: success()
    		});
    	});  
    		
    		
    	// on success...
    	 function success(){
    	 	$("#success").fadeIn();
    	 	$("#contactFormBestel").fadeOut();
    	 }
    	
        return false;
    });
    PHP Code:
    <?php
    //vars
    $subject $_POST['subject'];
    $to explode(','$_POST['to'] );

    $from $_POST['email'];

    //data
    $msg "NAME: "  .$_POST['name']    ."<br>\n";
    $msg .= "EMAIL: "  .$_POST['email']    ."<br>\n";
    $msg .= "TELEFOON: "  .$_POST['tele']    ."<br>\n";
    $msg .= "ADRES: "  .$_POST['adres']    ."<br>\n";
    $msg .= "KEUZE: " .$_POST['keuze']    ."<br>\n";
    $msg .= "AANTAL BONNEN: "  .$_POST['bon']    ."<br>\n";
    $msg .= "COMMENTS: "  .$_POST['comments']    ."<br>\n";

    //Headers
    $headers  "MIME-Version: 1.0\r\n";
    $headers .= "Content-type: text/html; charset=UTF-8\r\n";
    $headers .= "From: <".$from">" ;


    //send for each mail
    foreach($to as $mail){
       
    mail($mail$subject$msg$headers);
    }

    ?>

  4. #4
    Join Date
    Mar 2009
    Location
    Wherever i lay my hat
    Posts
    180
    Well, try what i suggested. Change this line:

    var keuze = $("input#keuze").val();

    to this:

    var keuze = $("select#keuze").val();

    however, you don't really need to specify the tag name, when you refer to the elements with IDs, because they are supposed to be unique anyway, so this should work, too:

    var keuze = $("#keuze").val();

  5. #5
    Join Date
    Feb 2013
    Posts
    3
    of course, so obvious...

    Works great!

    many thanks !

  6. #6
    Join Date
    Mar 2009
    Location
    Wherever i lay my hat
    Posts
    180
    You can thank me by marking this thread Resolved ( On top of all these comments look for Thread tools )

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.11874 seconds
  • Memory Usage 3,094KB
  • Queries Executed 13 (?)
More Information
Template Usage (33):
  • (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
  • (2)bbcode_code
  • (2)bbcode_html
  • (2)bbcode_php
  • (1)bbcode_quote
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)headinclude_bottom
  • (6)memberaction_dropdown
  • (1)navbar
  • (4)navbar_link
  • (1)navbar_moderation
  • (1)navbar_noticebit
  • (1)navbar_tabs
  • (2)option
  • (6)postbit
  • (6)postbit_onlinestatus
  • (6)postbit_wrapper
  • (1)showthread_list
  • (1)spacer_close
  • (1)spacer_open
  • (1)tagbit_wrapper 

Phrase Groups Available (6):
  • global
  • inlinemod
  • postbit
  • posting
  • reputationlevel
  • showthread
Included Files (27):
  • ./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
  • ./includes/functions_threadedmode.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 (71):
  • 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_threaded
  • showthread_threaded_construct_link
  • 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