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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T06:14:36+00:00 2026-06-07T06:14:36+00:00

This is my code. Onclick of submit, if the answer is correct the value

  • 0

This is my code. Onclick of submit, if the answer is correct the value will be saved in database. What I want here is that, when I click on a submit button all other submit buttons in the form must be disabled. Can i do this? Please help me.

    <textarea name="questn" id="questn" readonly="readonly" cols="45" rows="5"><?php echo $quest['questnId']; ?>.&nbsp<?php echo $quest['question'];?></textarea>
   <input type="submit" class="myButton" name="option" value="<?php echo $quest['optiona'];?>"/>
   <input type="submit" class="myButton" name="option"  value="<?php echo $quest['optionb'];?>" />
   <input type="submit" class="myButton" name="option"  value="<?php echo $quest['optionc'];?>" />
   <input type="submit" class="myButton" name="option"  value="<?php echo $quest['optiond'];?>" />

The reason I used submit instead of radio is that i want the value on the button to be displayed over it dynamically.

  • 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-07T06:14:38+00:00Added an answer on June 7, 2026 at 6:14 am

    you can write an onsubmit event on your form to disable all buttons.

    <form action="xyz.html" onsubmit="handleSubmit()">
      <input type="submit" name="option" value="b1"/>
      <input type="submit" name="option" value="b2"/>
      <input type="submit" name="option" value="b3"/>
      <input type="submit" name="option"  value="b4"/>
    </form>
    
    
    
    function handleSubmit(){
       var list = document.getElementsByName('option');
    
       for(var i=0;i<list.length;i++){
          list[i].disabled=true;
       }
    
       alert('all disabled');
    }​
    

    http://jsfiddle.net/4BDaU/1/


    2) if you dont want to disable the one clicked, i will suggest use onclick on buttons to call the handleSubmit. the code will look like this.

      <input type="submit" name="option" onclick="handleSubmit(this)" value="b1"/>
      <input type="submit" name="option" onclick="handleSubmit(this)" value="b2"/>
      <input type="submit" name="option" onclick="handleSubmit(this)" value="b3"/>
      <input type="submit" name="option" onclick="handleSubmit(this)" value="b4"/>
    

    you handle function will now accept this which will be than excluded in the loop.

    function handleSubmit(current){
       var list = document.getElementsByName('option');
    
       for(var i=0;i<list.length;i++){
          if(list[i]!=current)   // new condition added
             list[i].disabled=true;
       }
    
       alert('all disabled');
    }​
    

    Also note that, you don’t need add onsubmit in your form in this case

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

Sidebar

Related Questions

Im having this code %button.aristo-default.accept{:href => #, :onclick => $.post('/sessions/accept_invite', { user_id: 1, friend_id:
I have this code snippet: $(function() { $('.toolbar [id^=button]').on('click', function () { $(this) .css('background-color',
Code is not running on .click when I have this: $(.cancel).click(function() { alert(got here);
I want to move same marker after submit the button. I have a code
So I have this javascript code onclick of button for a child window which
This code is suppose to add an onClick event to each of the a
I have code like this - (IBAction)onClick:(id)sender { NSThread *thread = [[NSThread alloc]initWithTarget:parser selector:@selector(adapter:)
This code disabled mouse scroll functionality, when i click on the document. $(document).on(click, function
i have this jquery code $(#eioShowLink).on('click',function(){ $(#ioEditRelatedConcepts).html(''); $.getJSON(http://localhost/Mar7ba/Ontology/getRelatedConceptsAndRelations/+conceptName+/TRUE, function(data){ var concepts = data[0]; var
I have a JS code like this <script type=text/javascript> $(document).ready(function(){ $('.main').on('click', '.block', function (){

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.