duplo1
Posts: 67
|
| Posted: 06/21/2005, 8:18 PM |
|
I would need help with a big problem ... LOL
I work with CCStudio 2.2 / ASP / MsAccess Database
I have an editable Grid and would like to POST a value from one of the fields in this Grid to another form after users click on the submit button.
Please help ... how do I do that ???
Christoph
|
 |
 |
peterr
Posts: 5971
|
| Posted: 06/22/2005, 12:15 AM |
|
AFAIK, the HTML standard and therefore Web browsers do not allow submitting two forms at once. Thus if a user submits the Grid data then another form cannot be submitted.
_________________
Peter R.
YesSoftware Forums Moderator
For product support please visit http://support.yessoftware.com |
 |
 |
dataobjx
Posts: 181
|
| Posted: 06/22/2005, 5:17 AM |
|
One alternative is to utilize 2 frames.
I'm only going to provide the logic here...
If you are unable to write Javascript, you'll need to locate via google or what-ever those functions you'll need from sites such as a1javascripts.com, etc.
You'll need to create a function in the
<head>
<script>
!-->
// search google on "Javascript+Submit+iFrame"
function submitChildFrame()
{
//Submit the child frame first
//Now submit the parent frame (primary grid or record)
}
//-->
</script>
</head>
section that will be called when the user clicks the submit button.
On the submit button, place an onClick="submitChildFrame();"
You may need to modify the button's properties to be a button rather than a submit.
This logic will prepare the forms for submission sequentially.
To get the value from the first grid to the second can also be accomplished using client-side javascript.
For the sake of the example, I'll call the editable field "txtField1".
Again, you'll need to create a function
<head>
<script>
!-->
// search google on "Javascript+Submit+iFrame"
function submitChildFrame()
{
//Submit the child frame first
//Now submit the parent frame (primary grid or record)
}
function sendValueToFrame(vTextBoxToPopulate)
//search google for "javascript+iFrame+change value"
//or similar search criterion
{
//send the value to the form or document on the child frame
}
//-->
</script>
</head>
Create an OnChange="" event on the txtField1 input box. Given what you may find through your searches on google, your function signature may look different, but again - it's the logic that's being provided.
In the HTML for the txtField1 input box add an onChange event.
e.g,
<input id="txtField1" onChange="sendValueToFrame('txtRecipientTextBox')">
Where txtRecipientTextBox is the name of the field in the child iFrame that should be populated when this event is triggered.
Overall, the logic goes like this;
As the user changes the value in the primary grid, the onChange event is fired causing the javascript to write the value to the relevant text box on the secondary (child) form.
This continues with each editable field as required until the user clicks submit.
Since the value changes in the parent grid are immediately reflected in the child grid, all is ready for submission.
When the user clicks submit, the javascript function submitChildFrame() kicks in, causing the child to submit followed by the parent.
I hope this helps to at least point you in a helpful direction.
_________________
www.DataObjx.net
www.mydigitalapps.com |
 |
 |
dataobjx
Posts: 181
|
| Posted: 06/22/2005, 6:16 AM |
|
Working Example in pure asp.
It's the client side script that does the work....
You'll need to replace the recordset loop with the .net equivalent or php equivalent, etc.
<!-- METADATA TYPE="typelib" UUID="00000200-0000-0010-8000-00AA006D2EA4" NAME="ADO Type Library" -->
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<meta name="GENERATOR" content="Microsoft FrontPage 4.0">
<meta name="ProgId" content="FrontPage.Editor.Document">
<title>New Page 2</title>
<script type="text/javascript">
/***************
"search"
select Element Type-Ahead for IE/Windows by Danny Goodman (www.dannyg.com)
A bonus recipe for readers of O'Reilly's
"JavaScript & DHTML Cookbook"
This recipe first published at O'Reilly Network (www.oreillynet.com)
For full implementation notes, read the article.
****************/
// global storage object for type-ahead info, including reset() method
var typeAheadInfo = {last:0,
accumString:"",
delay:500,
timeout:null,
reset:function() {this.last=0; this.accumString=""}
};
// function invoked by select element's onkeydown event handler
function typeAhead() {
// limit processing to IE event model supporter; don't trap Ctrl+keys
if (window.event && !window.event.ctrlKey) {
// timer for current event
var now = new Date();
// process for an empty accumString or an event within [delay] ms of last
if (typeAheadInfo.accumString == "" || now - typeAheadInfo.last < typeAheadInfo.delay) {
// make shortcut event object reference
var evt = window.event;
// get reference to the select element
var selectElem = evt.srcElement;
// get typed character ASCII value
var charCode = evt.keyCode;
// get the actual character, converted to uppercase
var newChar = String.fromCharCode(charCode).toUpperCase();
// append new character to accumString storage
typeAheadInfo.accumString += newChar;
// grab all select element option objects as an array
var selectOptions = selectElem.options;
// prepare local variables for use inside loop
var txt, nearest;
// look through all options for a match starting with accumString
for (var i = 0; i < selectOptions.length; i++) {
// convert each item's text to uppercase to facilitate comparison
// (use value property if you want match to be for hidden option value)
txt = selectOptions.text.toUpperCase();
// record nearest lowest index, if applicable
nearest = (typeAheadInfo.accumString > txt.substr(0, typeAheadInfo.accumString.length)) ? i : nearest;
// process if accumString is at start of option text
if (txt.indexOf(typeAheadInfo.accumString) == 0) {
// stop any previous timeout timer
clearTimeout(typeAheadInfo.timeout);
// store current event's time in object
typeAheadInfo.last = now;
// reset typeAhead properties in [delay] ms unless cleared beforehand
typeAheadInfo.timeout = setTimeout("typeAheadInfo.reset()", typeAheadInfo.delay);
// visibly select the matching item
selectElem.selectedIndex = i;
// prevent default event actions and propagation
evt.cancelBubble = true;
evt.returnValue = false;
// exit function
return false;
}
}
// if a next lowest match exists, select it
if (nearest != null) {
selectElem.selectedIndex = nearest;
}
} else {
// not a desired event, so clear timeout
clearTimeout(typeAheadInfo.timeout);
}
// reset global object
typeAheadInfo.reset();
}
return true;
}
</script>
</head>
<body>
<form name="form1">
<select name="employeeList" onkeydown="typeAhead()">
<%
Dim cn
Dim rs
Dim strSQL
Set cn = Server.CreateObject("ADODB.Connection")
Set rs = Server.CreateObject("ADODB.Recordset")
Set cn = GetConnection
strSQL = "SELECT user_id, last_name + ', ' + first_name as full_name FROM users ORDER BY last_name"
set rs = cn.Execute(strSQL)
while not rs.EOF
response.write("<option value=""" & rs(0) & """>")
response.write(rs(1) & "</option>" & vbcrLf)
rs.MoveNext
wend
%>
</select>
</form>
</body>
</html>
<%
Function GetConnection()
Dim Conn: Set Conn = CreateObject("ADODB.Connection")
ConnectionString = "Provider=SQLOLEDB.1;Integrated Security=SSPI;Persist Security Info=False;User ID=;Initial Catalog=CorporateIntranet;Data Source=Intranet"
Conn.open ConnectionString
set GetConnection = Conn
end function
%>
_________________
www.DataObjx.net
www.mydigitalapps.com |
 |
 |
|