Forum Moderators: open

Message Too Old, No Replies

Button's value and text

         

yllai

8:45 am on Jun 13, 2005 (gmt 0)

10+ Year Member



In my form, have a submit button and value is "submit":

<input type="Submit" name="btn_submit" value="Submit">

but I want the word of "OK" displayed for the button instead of the word of submit, when visitor click on the button, the value of button to be pass is "submit" but not "OK". Can it be done? Any example?

BlobFisk

9:25 am on Jun 13, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Hi yllai,

If you want to change the text displayed on a Submit button, change the value to "OK":

<input type="Submit" name="btn_submit" value="OK">

I don't quite understand exactly what you mean about passing the value of the button as submit though... sorry!

Romeo

10:15 am on Jun 13, 2005 (gmt 0)

10+ Year Member



Hi Yllai,

as BlobFisk wrote, just start and change the value.
Most forms don't check this value.
However, if your form would do such a check (perhaps if the form has more than one SUBMIT button), then search in the form processing logic of the ACTION page for a
if ($_POST['btn_submit'] == "Submit") {...}
or similar and change it there into an "OK" accordingly.

Or create an own 'OKbutton.gif' showing an "OK" to the user instead of the underlying form's value="Submit", but this may not look good if you have other buttons as well in the form.

Regards,
R.

yllai

12:12 am on Jun 14, 2005 (gmt 0)

10+ Year Member



the value of button will be used in php script.

if ($btn_submit=="Submit"){
//submit process script here
}elseif ($btn_submit=="OK"){
//another process here
}

actually, both of this button (Submit, OK) are submit button but different submit process. In this case, value of both button can't be same else they will going for same process. So I'm thinking to make both button displayed as Submit but the value are different, with this they can work well in the if statement.

any ideas?

garann

8:45 pm on Jun 15, 2005 (gmt 0)

10+ Year Member



What if, instead of trying to give the buttons different values, you give them different names?


if ($btn_submit!=""){
//submit process script here
}elseif ($btn_ok!=""){
//another process here
}

If that won't work, or some other change to the PHP, all I can think of is maybe change the value using Javascript when the button's clicked?


<input type="button" name="btn_submit" value="OK" onclick="this.value='Submit';this.form.submit();">