0

I have a HTML page with about 10 inputs.

There are two forms, one inside the second. I want check first the small form before sending the big one, but when I check the submit button, it refresh the page with all inputs.

How can I discriminate all inputs except one I'm interested to?

    <html>
    <body>
    <form id="big" name="big">
    <input type="text" name="input1" value= "" />
    <input type="text" name="input2" value= "" />
    <input type="text" name="input3" value= "" />
    <input type="text" name="input4" value= "" />


     <form id="small" name="small"><input type="text" name="sendonlythisinput" value="" />
     <inputtype="submit" value="Send only this" />
     </form>

    <buton type="submit" value="SEND ALL!" />
    </form>

    </body>
    </html>
Alex Deiwor
  • 117
  • 3
  • 9
  • You cannot do this without JavaScript. Also, what's the problem with sending all inputs and then only using the value from the "selected" input? – ThiefMaster Dec 26 '13 at 17:04
  • 1
    `"There are two forms, one inside the second."` - Then you have invalid HTML. http://stackoverflow.com/questions/379610/can-you-nest-html-forms With invalid markup, expect the behavior to be undefined and browser-specific. – David Dec 26 '13 at 17:05
  • Oh, that's true. May be I try import the second from trhu a function – Alex Deiwor Dec 26 '13 at 22:09
  • @ThiefMaster I make a simple check with conditions, if the $_GET vars exist all time, it's difficult to take specific control, for that reason I just want one $_GET depending the button pressed – Alex Deiwor Dec 26 '13 at 22:10

2 Answers2

1

you can create a custom function for your button :

   <button type="button"   onclick="submit_custom();">submit</button>   



<script type="text/javascript" charset="UTF-8">
    function submit_custom(){

//do things here
and then send data via ajax or something 

    } 
</script> 
0

You have used one form in inside the another <form> s in your html. You can split like below and use,

Form1:

    <form id="big" name="big">
    <input type="text" name="input1" value= "" />
    <input type="text" name="input2" value= "" />
    <input type="text" name="input3" value= "" />
    <input type="text" name="input4" value= "" />    

    <input type="submit" value="SEND ALL!" />
    </form>

Form 2:

     <form id="small" name="small"><input type="text" name="sendonlythisinput" value="" />
     <input type="submit" value="Send only this" />
     </form>
Krish R
  • 22,583
  • 7
  • 50
  • 59