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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T01:08:06+00:00 2026-05-22T01:08:06+00:00

i am having trouble. i write HTML and jQuery and set same name attribute

  • 0

i am having trouble.

i write HTML and jQuery and set same name attribute in <select> tag and <input> tag.

<select name="questionBoxOne" id="questionBoxOne">
  <option selected="selected" value="">Choose a question</option>
  <option value="">---------------</option>
  <option value="custom">Create your own question</option>
  <option value="">---------------</option>
  <option value="My mother's maiden name?">My mother's maiden name?</option>
  <option value="The name of my first pet?">The name of my first pet?</option>
  <option value="My father's middle name?">My father's middle name?</option>
</select>

I use this area to show input box, if user select Custom Question option.

<div id="newQuestion">
  <input type="text" value="" id="questionBoxOne" name="questionBoxOne" />
  <a id="cancel">select question</a>
</div>

And i use jQuery codes.

 <script language="javascript">
        $(function() {
            $('#newQuestion').hide();

            $('#questionBoxOne').change(function() {
                if ($(this).val() === 'custom') {
                    $('#newQuestion').show();
                    $('#questionBoxOne').hide();
                }
            });

            $('#cancel').click(function () {
                $('#questionBoxOne').show();
                $('#newQuestion').hide();
            });
 </script>

as you can see in my earlier codes i am sending same name to my next finish.php file, but when i am trying this it isn’t showing <select> option question but this codes show custion question.

please help how i resolve this issue.

  • 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-22T01:08:07+00:00Added an answer on May 22, 2026 at 1:08 am

    Ok so I think I understand. You want to disable the name your not using at the time so here is some code

     <script language="javascript">
        $(function() {
            $('#newQuestion').hide();
            $('#newQuestion input').removeAttr('name');
            $('#questionBoxOne').change(function() {
                if ($(this).val() === 'custom') {
                    $('#newQuestion').show();
                    $('#newQuestion input').attr('name','questionBoxOne');
                    $('#questionBoxOne').hide();
                    $('#questionBoxOne').removeAttr('name');
                }
            });
    
            $('#cancel').click(function () {
                $('#questionBoxOne').show();
                $('#questionBoxOne').attr('name','questionBoxOne');
                $('#newQuestion input').removeAttr('name');
                $('#newQuestion').hide();
            });
     </script>
    

    that should work

    but instead of the first removeattr from the #newQuestion you should remove the name attribute in the html
    Yes AND ALSO VERY IMPORTANT GET RID OF THE ID FOR THE INPUT OF NEWQUESTION!!!

    However the way in which you should handle this is

    <form id="submit" action="finish.php" method="post">
       <select id="questionSelect" name="questionSelect">
             <option selected="selected" value="">Choose a question</option>
             <option value="">---------------</option>
             <option value="custom">Create your own question</option>
             <option value="">---------------</option>
             <option value="My mother's maiden name?">My mother's maiden name?</option>
             <option value="The name of my first pet?">The name of my first pet?</option>
             <option value="My father's middle name?">My father's middle name?</option>
       </select>
      <input type="text" value="" id="custQuestion" name="custQuestion" />
      <a id="cancel">select question</a>
    

    then keep your original jquery functions with the ids changed to the appropriate ones like so

     <script language="javascript">
            $(function() {
                $('#custQuestion').hide();
    
                $('#questionSelect').change(function() {
                    if ($(this).val() === 'custom') {
                        $('#custQuestion').show();
                        $('#questionSelect').hide();
                    }
                });
    
                $('#cancel').click(function () {
                    $('#questionSelect').show();
                    $('#custQuestion').attr('value','').hide();
                });
     </script>
    

    now on the finish.php you can look for both names returned and use the one depending if custom question is blank or not.

    like so

    if(!empty($_POST['custQuestion'))
      $question = $_POST['custQuestion'];
    else
      $question = $_POST['questionSelect'];
    

    now if that doesn’t help you need to do more research

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

Sidebar

Related Questions

I'm having some trouble with my Jquery code. <html> <head> <script type=text/javascript src=jquery.js></script> <script
I'm having trouble wrapping my head around how to write this query. A hypothetical
I am having trouble with XMLTextWriter.WriteStartElement throwing an exception: System.InvalidOperationException when trying to write
I having trouble in dividing the HTML frames. I have been using the following
After I upgraded to the beta, I'm having trouble with Html.RadioButtonList. Can someone show
I am having trouble with Lisp's backquote read macro. Whenever I try to write
Good morning, I am having trouble with the following code <html> <head> <title>highlight date</title>
I am trying to write a vCard Parser and am having trouble unfolding lines.
I'm pretty new with JQuery and I'm having trouble creating a behaviour that would
I am tryig to write an Android Honeycomb application and I am having trouble

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.