Form button to have different diplay and CGI value

Hi,
   I want a form button to have different display value than
the value passed to the CGI . How do I do that?
Any pointers are appreciated.


Regards,
Pankaj
pankaj_gargAsked:
Who is Participating?
 
xabiConnect With a Mentor Commented:
You can do two things:

1.- Use a hidden field instead of the button field:

if you have this button:
<input type="button" name="myfield" value="Foo">

You can change into this:

<input type="button" value="foo">
<input type="hidden" name="myfield" value="your_new_value">

2.- You can change the button value before submit the form. This way:

..
..
<script language="javascript">
<!--
function sendit() {
 idform = document.myform
 idform.myfield.value = "New value"
 idform.submit()
}
//-->
</script>
</head>
<html>
..
..
<form name="myform" action="go.htm" method="get">

<input type="button" name="myfield" value="press me">
<input type="button" value="Submit" onClick="sendit()">
</form>

xabi
0
 
pankaj_gargAuthor Commented:
Thanks a lot...
0
 
knightEknightCommented:
Another way is to change the value only when the button is pressed -- that way the user sees the correct display value, and the new value is only displayed for a second or so while the form submits:

<INPUT type='submit' value='display val' onClick='this.value="new value";return(true);'>

0
Never miss a deadline with monday.com

The revolutionary project management tool is here!   Plan visually with a single glance and make sure your projects get done.

 
knightEknightCommented:
oops, as xabi already said  :)
0
 
Jan LouwerensSoftware EngineerCommented:
can't you just use:

<INPUT TYPE="submit" NAME="sub1" VALUE="Click Me">

the name of the submit button will be "sub1" in the cgi scripts, but will show "Click Me" on the page...
0
 
Jan LouwerensSoftware EngineerCommented:
Sorry! I misread the question...  I don't know what made me think you wanted a submit button...
0
 
xabiCommented:
So ... what aabout my points? :)

xabi
0
All Courses

From novice to tech pro — start learning today.