Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8478373
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T18:43:40+00:00 2026-06-10T18:43:40+00:00

See example here . Clicking [Email Me] in the President’s header should open up

  • 0

See example here. Clicking [Email Me] in the President’s header should open up the contact form with Webmaster selected from the dropdown, but that’s not happening.

I know it should be trivial, but it’s not turning out that way. get stuff in email() is working alright but when it gets to the selecting an option, the code craps out. All relevant code is below.

My HTML:

<form method="get">
    <select name="to" id="to-field">
      <option name="President" value="President">President</option>
      <option name="Webmaster" value="Webmaster">Webmaster</option>
    </select>
</form>

My JS/jQuery:

function email(to){
    $(document).ready(function() {
         $.get('/inc/email.php', 
               function(data){
                    $('#email-form').html(data);
                    $('#email-form form').submit( function(){
                        var d = $('#email-form form').serialize();
                        $.ajax({
                          type:     'GET',  
                          url:      '/inc/email.php?submit=true&'+d,
                          success:  function(data) {
                                        $('#email-form').html(data);
                          }
                        });
                        return false;
                    });
            }
         );
     });

    if(to !== undefined){
        $('select#to-field').val(to);
        console.log( 'item selected -> ' + $('select#to-field').val() );
    }
}

This is being triggered by:

<span onclick="javascript:email('Webmaster');">[Email Me]</span>

And console.log() is returning:

item selected -> undefined

I’ve also tried setting selected using this:

$("select#to-field[value=" + to + "]").attr("selected","selected");

And even this for good measure:

$("select#to-field[value=" + to + "]").attr("selected",true);

Any help would be greatly appreciated!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-10T18:43:41+00:00Added an answer on June 10, 2026 at 6:43 pm

    Your $.get is an async event!! As it is, your

    if(to !== undefined){
            $('select#to-field').val(to);
            console.log( 'item selected -> ' + $('select#to-field').val() );
        } 
    

    will execute before the inner email page is even finished loading! Put that part inside your $.get callback to be done after the email page is loaded!

    Put it between like this

    $('#email-form').html(data);
    //RIGHT HERE
        if(to !== undefined){
                $('select#to-field').val(to);
                console.log( 'item selected -> ' + $('select#to-field').val() );
            } 
    //
    $('#email-form form').submit( function(){...
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm new to Jquery. See an example at http://w3schools.com/jquery/tryit.asp?filename=tryjquery_hide_p . Here, clicking 'Click Me'
You can see the example here: http://jsfiddle.net/8EHED/8/ This is a tricky problem because I
I'm working on a jquery carousel. You can see the example here: http://jsfiddle.net/6fwbS/2/ Click
Checking the datagrid example here http://www.silverlight.net/content/samples/sl4/toolkitcontrolsamples/run/default.html see the datagrid section It says that if
See example: <!DOCTYPE html> <html> <head> <title>language</title> <script type=text/javascript src=http://www.google.com/jsapi> </script> </head> <body> <div
everyone. Please see example below. I'd like to supply a string to 'schedule_action' method
Why can't I set $_SERVER['DOCUMENT_ROOT'] as attribute? see example code class foo { private
See this example! int main( int argc, char ** argv ) { int *ptr
Please see this example: if (strlen($_SESSION['userDetails']['THISNAME']) == 0) { $_SESSION['userDetails'][''.$THISNAME.'Error'] = autofocus; include $docRoot/html/forms/reg/user_info.html.php;
For more information see this Example use strict; use warnings; use CGI::Simple; use DBI;

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.