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 7530769
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T05:00:05+00:00 2026-05-30T05:00:05+00:00

I have the following script: <script type=text/javascript> $(document).ready(function(){ $(#ProjModelChoose).change(function() { $(#ProjModelChooseCOM).attr(name,form + $(this).val()); $(input[name=’buyid’]).attr(value,

  • 0

I have the following script:

<script type="text/javascript">
$(document).ready(function(){

$("#ProjModelChoose").change(function() {
    $("#ProjModelChooseCOM").attr("name","form" + $(this).val());
    $("input[name='buyid']").attr("value", $(this).val());
});

$("#ProjModelChoose2").change(function() {
    $("#ProjModelChooseOEM").attr("name","form" + $(this).val());
    $("input[name='buyid']").attr("value", $(this).val());
});

$(".atcButton").click(function() {
    if($("select option:selected").val("Choose Your Projector Model")) {
    event.preventDefault();
    alert("Please choose a projector model");
    }
    });
});
</script>

The HTML:

<table cellpadding="0" cellspacing="0" border="0">
<tr>
<span>Purchase today for: </span><h3 class="atcPrice">$192</h3>
<select name="chooseModelOEM" id="ProjModelChoose">
<option value="Choose Your Projector Model">Choose Your Projector Model</option>
<option value="126648">PLC-SU70</option>
<option value="126682">PLC-WXE45</option>
<option value="126684">PLC-WXE46</option>
<option value="126686">PLC-WXL46</option>
<option value="126717">PLC-XE40</option>
<option value="126719">PLC-XE45</option>
<option value="126795">PLC-XL40</option>
<option value="126797">PLC-XL45</option>
<option value="126998">PLC-XU73</option>
<option value="127000">PLC-XU74</option>
<option value="127006">PLC-XU83</option>
<option value="127008">PLC-XU84</option>
<option value="127010">PLC-XU86</option>
<option value="127012">PLC-XU87</option>
</select>
<form name="" action='someaction' method=post id="ProjModelChooseCOM" target="_blank"><input type='hidden' name='buyid' value=""><input type='hidden' name='c' value="1025622"><input type='hidden' name='n' value='5'><td class='text'><input name='add' id='add' size=4 value=1 class='qtyButton' border="0" ></td><td class='text'><input type="image" src="olp-atcbutbg.png" border='0' value='Add to Cart' alt='Add to Cart' class='atcButton'></td></form>
</tr>
</table>

Ok, so basically I am inserting the value from the selected option into the form when a user makes a selection from the drop down. That works fine. But if a user does not make a selection (Leaves the dropdown on the “Select your projector model”) and tries to add the product to the cart, I want it to stop the form submit (it’s dynamic so it’s going to try to perform the action regardless) and display an alert. My code above does neither =/

  • 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-05-30T05:00:07+00:00Added an answer on May 30, 2026 at 5:00 am

    Try this:

    $(".atcButton").click(function() {
        if($("select option:selected").val() === "Choose Your Projector Model") {
            alert("Please choose a projector model");
            return false;
        }
    });
    

    You may also want to change your event handler from $(".atcButton").click() to $("#ProjModelChooseCOM").submit().

    Update Sorry I misunderstood the issue. Edited to address the value comparison issue.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the following code that works: <script type=text/javascript> $(document).ready(function() { // Initialise the
I have the following code that works: <script type=text/javascript> $(document).ready(function() { // Initialise the
I have the following and in this order: <script type=text/javascript> $(document).ready(function(){ var overwrite =
I have the following: <script type=text/javascript> $(document).ready(function () { $(input[id^='Position_'], select[id^='Level_'], input[id^='Title_'], select[id^='Status_'],).change(function (e)
I have a ajax function as below <script type=text/javascript> $(document).ready(function () { var timer,
I have the following script, where the first and third document.writeline are static and
I have the following script: Timer=0; function countdown(auctionid){ var auctions; var divs; Timer=Timer+1; if((Timer%10==0)||(Timer==1)){
I have the following script in my homepage $(function () { // same as
I have the following Javascript code which controls an accordion type set of divs.
I have the following file: <html> <head> <title></title> <link rel=css type=text/css href=/empty.css title=css />

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.