Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
1.1k views
in Technique[技术] by (71.8m points)

html submit without submit button or JavaScript

Currently I have a simple form with a plus and minus on it and a value in the middle. I am trying to create a href link under the plus and under the minus to call self but to either indicate which link was used (either plus or minus) or to pass the value after being incremented or decremented.

I do not want to use JavaScript/client side scripting because some browsers do not allow it but I am using PHP. I also did not want to use $_GET as other data needs to be sent to 'self' so I am using $_POST.

Any idea's are welcome.

snippet of code

var_dump($_POST);
< form action="?" method="post" action="Submit" >
< input type="hidden" id="currentvalue" name="currentvalue" value="2" / >

< div class="minus" >< a href="" onclick="document.forms[0].submit();return false;" > - < /a > < /div >
< div class="currentvalue">'.$_POST["currentvalue"].'< /div >
< div class="plus"> + < /div >

Thanks

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

You cannot submit an HTML form without using the button or input type=image/submit elements or JS.

What you can do:

  1. Specify an image for input type=image
  2. Apply a bg image to input type=submit and killing the text via text-indent:-999em; for modern browsers and line-height for IE
  3. Split areas into separate forms if you really have to

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...