473,385 Members | 1,548 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Simulating a button click

Given the following somewhat abbreviated code:
------------------------------------------
<table>

<form name="aForm1" action="doStuff" method="post">
<input type="hidden" name="id" value="1">
<tr onClick="aForm1.myButton.value='View'; aForm1.submit();">
<td>
<input type="submit" name="myButton" value="View">
<input type="submit" name="myButton" value="Edit">
</td>
<td>Value 1</td>
</tr>
</form>

<form name="aForm2" action="doStuff" method="post">
<input type="hidden" name="id" value="2">
<tr onClick="aForm2.myButton.value='View'; aForm2.submit();">
<td>
<input type="submit" name="myButton" value="View">
<input type="submit" name="myButton" value="Edit">
</td>
<td>Value 2</td>
</tr>
</form>

</table>
------------------------------------------

If I click on the View button, then the form gets submitted, and the
form handler reads that the value of myButton as 'View"

But if I click on the row, then no value for the myButton gets passed
to the form handler.

I did try aForm1.myButton[0].value='View'

How do I get the form submit to set the passed value of myButton to
'View'?

--
Wojtek :-)
Mar 28 '07 #1
3 3435
Wojtek wrote:
Given the following somewhat abbreviated code:
------------------------------------------
<table>

<form name="aForm1" action="doStuff" method="post">
<input type="hidden" name="id" value="1">
<tr onClick="aForm1.myButton.value='View'; aForm1.submit();">
<td>
<input type="submit" name="myButton" value="View">
<input type="submit" name="myButton" value="Edit">
</td>
<td>Value 1</td>
</tr>
</form>

<form name="aForm2" action="doStuff" method="post">
<input type="hidden" name="id" value="2">
<tr onClick="aForm2.myButton.value='View'; aForm2.submit();">
<td>
<input type="submit" name="myButton" value="View">
<input type="submit" name="myButton" value="Edit">
</td>
<td>Value 2</td>
</tr>
</form>

</table>
------------------------------------------

If I click on the View button, then the form gets submitted, and the
form handler reads that the value of myButton as 'View"

But if I click on the row, then no value for the myButton gets passed to
the form handler.

I did try aForm1.myButton[0].value='View'

How do I get the form submit to set the passed value of myButton to 'View'?
.... onclick="document.aForm1.myButton.value= 'View' ">
Mick
Mar 28 '07 #2
Michael White wrote :
... onclick="document.aForm1.myButton.value= 'View' ">
Yes, I do have the 'document.' before each element call. I trimmed it
from the example because it causes a word wrap, and it is more readable
without the word-wrap :-)

--
Wojtek :-)
Mar 28 '07 #3
Wojtek wrote :

Hmmm, just read the HTML spec on buttons.

The HTML spec states that if a form has multiple buttons, then only the
clicked button's value will be processed and sent to the CGI.

So if NO button is clicked by the user, then no button value is sent to
the CGI.

I would prefer not to use a hidden field for a shadow button value as
that adds another thing to be proccessed by the CGI. And it is not
"elegant" enough....

--
Wojtek :-)
Mar 28 '07 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

47
by: Lauren Quantrell | last post by:
I have constructed the following code that simulates the common rollover effect when moving the mouse over a label (this example makes the label bold.) I'm wondering if anyone has come up with...
3
by: Doug Eleveld | last post by:
Hi Everyone, I have been playing aroung with 'object-oriented' C for a while now and I have come up with an interesting way to simulate C++ inheritance and non-member functions in C in a 100%...
11
by: CW | last post by:
I have message entry screen that's causing me a bit of an issue. At the moment, there are 2 buttons, one is used to send message to another user (btnSend) and another is used to send messages to...
4
by: Roger Withnell | last post by:
I would like to freeze column and row headings on a webpage, simulating freeze panes as in an Excel spreadsheet. Don't seem to be able to do it with Frames. Is there a way with Javascript...
0
by: bolinc | last post by:
I have some code and right now it has a submit button. Users select a date and region (state, country, etc.) and when both are selected they press the button and whamo. What I want to do is if they...
7
by: daveyand | last post by:
Is there a way in javascript to trigger the clicking of the left mouse button. Basically i have a floating div that is translucent (40% opacity) this div covers the whole screen. when a user...
4
by: oliver james | last post by:
I'm trying to automate an Excel spreadsheet from Access. I've established a link and loaded data from a recordset onto a worksheet in Excel. I now want to perform some manipulation on the data. I...
5
by: Xu, Qian | last post by:
Hello All, I have some problem by simulating a link click using javascript. The webpage uses a js-library named interface (jQuery like) ------------------------------ <a id="foo" href="#">Try...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.