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

  • SEARCH
  • Home
  • 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 9023787
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T05:50:46+00:00 2026-06-16T05:50:46+00:00

I have a javascript related question. I have a form with multiple comboboxes being

  • 0

I have a javascript related question. I have a form with multiple comboboxes being generated while loading:

<select id="email_adrs" class="input-medium">
<option>-Ontvanger-</option>
<?php while ($veri = mysql_fetch_array($verwijzer)) { ?>
   <option value="<?php echo $veri['email'];?>"><?php echo $veri['aanvrager']; ?></option>
<?php 
   }
?>
</select>

When the submit button is clicked, the following code is executed:

<input onclick="sendmail('<?php echo $plist['patient_id']; ?>');" class="submit-green" type="submit" value="Versturen"   name="form_submit" />

The sendmail function is defined as:

function sendmail(pid)
{
    var email = document.getElementById('email_adrs').value;
    var xmlhttp1=new XMLHttpRequest();
    xmlhttp1.onreadystatechange=function()
    {
        if(xmlhttp1.readyState==4 && xmlhttp1.status==200)
        {
            MailNotification();
        }
    }
    xmlhttp1.open('GET','html2pdf/examples/email.php?id='+pid+'&email='+email,true);
    xmlhttp1.send();
}

The problem I am facing is that if I restrict myself to the first record generated, the email is sent. If I select any other record and its corresponding combobox, I get the notification that the mail is sent, however while troubleshooting I found out that there is no value being passed for the email address. It appears to me that the code is not able to detect which combobox was selected.

Please help!

Regards,

Babu

  • 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-16T05:50:47+00:00Added an answer on June 16, 2026 at 5:50 am

    You should change your input to

    <input onclick="sendmail(this, '<?php echo $plist['patient_id']; ?>');" class="submit-green" type="submit" value="Versturen"   name="form_submit" />
    

    And your function to

    function sendmail(clickedElement, pid)
    {
        var formElem = clickedElement.parentElement; // (1)
        var selectElem = formElem.getElementsByTagName("select")[0]; // (2)
        var email = selectElem.value;
    
        /*
          [Ajax call here]
        */
    }
    

    (1): You have to apply as many .parentElement as neded to reach the form, depending on your layout.
    (2): If you have more than 1 select element, use the appropiate index of the array.

    If you are using JQuery, then you can do the same with

    var email = $(clickedElement).closest("form").find("#email_adrs").val();
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am very new to Javascript MVC frameworks and have a question related to
I have one question related to Javascript Validation: How could I find the difference(the
I have JavaScript code which copies the value of input file and paste it
I have JavaScript form validation functions like so: function validate_name(field) { if (field ==
This is related to a previous question I asked with Jquery. If I have
in a related question I have posted this code. It almost works, but the
I posed a question that related where I could display Page loading in asp.net
related question with unsatisfactory answers: Changing CSS Values with Javascript Here's what I want
question relates to PHP and Javascript for now every table has a form with
This question is related to Javascript event handling and flow control , but it

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.