/    Sign up×
Community /Pin to ProfileBookmark

how to get the VALUE of a button using POST?

hi have a problem here,can anyone tell me how can i post the value of a button?

here’s a sample:

[code=html]
<body>
<form method=”POST” action=”2ndpage.php”>
<input type=”button” value=”THIS IS THE VALUE I WANT TO GET” name=”MyBUTTON”>This button calls a javascript that changes its VALUE

<input type=”submit” value=”SEND MyBUTTON VALUES”>

</form>
</body>
[/code]

[code=php]
Here in the 2ndpage.php i want something like this
<?
echo $_POST[‘MyBUTTON’];
?>
[/code]

That’s i want to do,if it’s not possible is there a workaround for it?tnx in advance..

to post a comment
PHP

3 Comments(s)

Copy linkTweet thisAlerts:
@furnissgMay 30.2008 — The button value does not get passed by the post,

try using a hidden field along side the button, you can always use javascript to change that value aswell.
Copy linkTweet thisAlerts:
@nebchill26authorMay 30.2008 — i already have s javascript that changes the value of the button,all i have to do now is to transfer that javascript variable to become a php variable,is that possible?if it is can you give me a simple example?
Copy linkTweet thisAlerts:
@furnissgMay 30.2008 — ima ssuming your javascript functon is something along the lines of

onclick="document.MyButton.value = 'SOME VALUE';"

so all you need to do is create a hidden field

[code=php]

<input type="hidden" name="MyButtonValue" value="SOME Value" />


[/code]


Then change the javascript function to change that value instead of the button


[code=php]

onclick="document.MyButtonValue.value = 'SOME VALUE';"

[/code]
×

Success!

Help @nebchill26 spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.18,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...