By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
429,587 Members | 1,168 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 429,587 IT Pros & Developers. It's quick & easy.

Reference field in mult-record form

P: n/a
I want to use the javascript dom to reference the field of a record in a
multi-record html form when that field has been changed. How do I reference
the field? I have a JavaScript function coded as:

var zownerID = document.updOwners.ownerID.value
var zownerName = document.updOwners.ownerName.value
document.updOwners.mysql_update.value = zownerID
document.updOwners.newName.value = zownerName

I have tried calling it from onclick for the submit button and onsubmit for
the form with no success. Very new to javascript and would appreciate any
help. Thanks
Jul 23 '05 #1
Share this Question
Share on Google+
5 Replies


P: n/a
Rose wrote:
I want to use the javascript dom to reference the field of a record in a multi-record html form when that field has been changed. How do I reference the field? I have a JavaScript function coded as:

var zownerID = document.updOwners.ownerID.value
var zownerName = document.updOwners.ownerName.value
document.updOwners.mysql_update.value = zownerID
document.updOwners.newName.value = zownerName

I have tried calling it from onclick for the submit button and onsubmit for the form with no success. Very new to javascript and would appreciate any help. Thanks


Hi Rose.

'javascript dom' is a misnomer: the former is a scripting language, the
latter a language-independent object model.

Not entirely clear what you're trying to do. Post your HTML along with
a description of what you need to happen.

Jul 23 '05 #2

P: n/a
Lee
Rose said:

I want to use the javascript dom to reference the field of a record in a
multi-record html form when that field has been changed. How do I reference
the field? I have a JavaScript function coded as:

var zownerID = document.updOwners.ownerID.value
var zownerName = document.updOwners.ownerName.value
document.updOwners.mysql_update.value = zownerID
document.updOwners.newName.value = zownerName

I have tried calling it from onclick for the submit button and onsubmit for
the form with no success. Very new to javascript and would appreciate any
help. Thanks


Don't use the onclick of the submit button. Some browsers don't
support such a thing, and there are often other ways to submit a
form than clicking the button.

<form ... onsubmit="doStuff(this)">

function doStuff(formRef) {
formRef.mysql_update.value = formRef.ownerID.value;
formRef.newName.value = formRef.ownerName.value;
}

Jul 23 '05 #3

P: n/a
I am displaying names selected from a mysql database table. I want to be
able to change a name and have that change update the mysql database table.
This is the html, javascript, and php code. Thanks...

<html>
<head>
<link href="../../../../../../styles/canDC.css" rel="stylesheet"
media="screen">
<script type="text/javascript" name="fpownerID" language="JScript5.0">
<!--
function fpownerID()
{
var zownerID = document.updOwners.ownerID.value;
var zownerName = document.updOwners.ownerName.value;
document.updOwners.mysql_update.value = zownerID;
document.updOwners.newName.value = zownerName;
alert("Function Executed");
}
// -->
</script>
<csactions>
<csaction name="1AE4950" class="Call Function" type="onevent"
val0="fpownerID" val1=""></csaction>
</csactions>
<csscriptdict import>
<script type="text/javascript"
src="../../../../../../GeneratedItems/CSScriptLib.js"></script>
</csscriptdict>
<csactiondict>
<script type="text/javascript"><!--
CSAct[/*CMP*/ '1AE4950'] = new Array(CSCallFunction,'fpownerID','');

// --></script>
</csactiondict>
</head>
<body bgcolor="#ffffff" leftmargin="0" marginheight="0" marginwidth="0"
topmargin="0">
<form action="ProcessForm.php" method="post" name="updOwners"
onsubmit="CSAction(new Array(/*CMP*/'1AE4950'));" cssubm="1AE4950">
<table height='200px' width='385' border='1px' cellspacing='1px'
cellpadding='0' align='center'>
<tr><td class="can"><div style='align:center; height:100%; width:100%;
overflow:auto'>
<table class="can" height='100%' width='100%' border='1px'
cellspacing='2px' cellpadding='0' align='center'>
<?php
$zqueryRecords=" SELECT o.ownerID, o.ownerName FROM fp_owners o WHERE
o.ownerID> 0 ORDER BY o.ownerName";
$resultRecords=mysql_query($zqueryRecords);
echo mysql_error();
while($zRecords = mysql_fetch_array($resultRecords))
{
?>
<tr align='center'>
<td class='formField'>
<input type='hidden' name='ownerID' value='<?php echo
$zRecords[ownerID];?>'>
<input class="left" type='text' name='ownerName' size='40' maxlength='50'
value='<?php echo $zRecords[ownerName];?>'>
<input class="button" type="submit" name="updButton"
value="Update"></td></tr>
<?php }?>
</table>
</div>
</td>
</tr>
</table>
<div align="center">
<input type="hidden" name="newName" value="">
<input type="hidden" name="required" value="mysql_update_value, newName">
<input type="hidden" name="redirect" value="brmv_owners.php">
<input type="hidden" name="redirect_type" value="include">
<input type="hidden" name="mysql_table" value="fp_owners">
<input type="hidden" name="write_to_mysql" value="newName > ownerName">
<input type="hidden" name="mysql_update_field" value="ownerID">
<input type="hidden" name="mysql_update_value" value=""></div>
</form>
</body>
</html>
Jul 23 '05 #4

P: n/a
Thanks... will keep this in mind.
Jul 23 '05 #5

P: n/a
Believe it or not, I actually got it to work. I hate being so new to a
programming language that I don't even know how to properly refer to it.
Thanks for your response.

"RobB" <fe******@hotmail.com> wrote in message
news:11**********************@g47g2000cwa.googlegr oups.com...
Rose wrote:
I want to use the javascript dom to reference the field of a record

in a
multi-record html form when that field has been changed. How do I

reference
the field? I have a JavaScript function coded as:

var zownerID = document.updOwners.ownerID.value
var zownerName = document.updOwners.ownerName.value
document.updOwners.mysql_update.value = zownerID
document.updOwners.newName.value = zownerName

I have tried calling it from onclick for the submit button and

onsubmit for
the form with no success. Very new to javascript and would appreciate

any
help. Thanks


Hi Rose.

'javascript dom' is a misnomer: the former is a scripting language, the
latter a language-independent object model.

Not entirely clear what you're trying to do. Post your HTML along with
a description of what you need to happen.

Jul 23 '05 #6

This discussion thread is closed

Replies have been disabled for this discussion.