Jump to content

How Do I Get The Value Of A Button Using Php


confused and dazed

Recommended Posts

if the form sent with method='get' then all the data will be available in $_GET asscociative superglobal array if method='post' it will be in $_POST asscociative superglobal array.

Link to comment
Share on other sites

and , you may like to post your question in appropiate forum so that more of related people will be able answer your question

Link to comment
Share on other sites

I will try to post in the appropriate forums from now on. I am using Post but it will not work. Here is the code and it is not returning the value of the button. Why wont it return the value "commando" with the data that the user populates. HTML code <html><body><form action="form_lessons_post_process.php" method="post">Name: <input type="text" name="fname" />Age: <input type="text" name="age" /><input type="button" name="test" value="commando" /><input type="submit" /></form></body></html> PHP code <html><body><?php echo $_POST["fname"]; ?><br /><?php echo $_POST["age"]; ?><br /><?php echo $_POST["test"]; ?><br /></body></html>

Link to comment
Share on other sites

This: <input type="button" name="test" value="commando" /> you have as type="button". The type button usually is associated with JavaScript; where you assign a function to that button. When it's clicked on, whatever you wrote for the function to do, it will do. That's basically what the "onclick" command is all about when it comes to an HTML element.

Link to comment
Share on other sites

The values of buttons inside a form do not get submitted with the form data. The only button value which gets submitted is the value of the submit button you clicked on, as long as the button has a name. You need to use something other than a button, like a hidden field.

Link to comment
Share on other sites

This has already been discussed, in a duplicate topichttp://w3schools.inv...view=getnewpost Which now seems to have been removed completely? instead of merged. last post

confused and dazed has just posted a reply to a topic that you have subscribed to titled "How Do I Get The Value Of A Button Using Php".----------------------------------------------------------------------I ended up writing a function called placevalue and I used scorewinner and placevalue all on the same onclick operator and it worked!!! Thanks for your help. It was a big step forward for me. I think I am starting to understand a few things. function placevalue(teamvalue, newteamvalue){newteamvalue.value = teamvalue.value}----------------------------------------------------------------------The topic can be found here: http://w3schools.invisionzone.com/index.php?showtopic=40676&view=getnewpost
Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...