Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Updating a hidden form element 3

Status
Not open for further replies.

Tels

IS-IT--Management
Jul 10, 2001
290
GB
If I want to change a hidden form element (curtime) contained within a form (form1) on a page (IMclient.htm) to a variable named 'timenow'

How do I do it?

PS I always give stars for GOOD answers so don't be backwards in coming forwards!!!!

Thnks all
Tels Mixed Linux/Win2000 Network Administrator
 
What's the problem?

document.form1.curtime.value = timenow;


If the page is a frame inside a frameset:

parent.frame_name.document.form1.curtime.value = timenow;
 
Well you were right. I was being silly - 1 slight case-sensitive error threw it out.
but you answered another question I had... why I just spent £30 on a JavaScript Bible I'll never know

Thank you
:) Mixed Linux/Win2000 Network Administrator
 
well heres one for you then... earn it :)

I want to change a form select array from within an IFRAME embedded next to the form.
The select is named 'touser' and sits in the form 'form1'

The IFRAME source is CGI generated, and the CGI code I have is:

while($i < $usernum){ // count from the top of the list
// .... here gets new variable
echo &quot;parent.document.form1.touser[$i].text='$variable';\n&quot;;
++$i;
}

Which produces:

parent.document.form1.touser[0].text='hello';

I can assure you that the <script language='JavaScript'> headers are intact and proper, I am 99% certain the failure lays within the above line.
Can you give me the proper DOM reference?


Mixed Linux/Win2000 Network Administrator
 
I don't like ifames and never use them, but I think it should be this:

window.top.document.form1.touser[0].text='hello';

 
This is pasted directly from the IFRAME source.

<html>
<head>
<script language=&quot;JavaScript&quot;>
function upDate(){
window.top.document.updater.touser[0].text='tels';
window.top.document.updater.touser[1].text='paul';
window.top.document.updater.touser[2].text='test';

}</script>
</head>
<body onLoad='upDate()'>
</body>
</html>

...But I get no joy :(

the page source, for your reference is:

<html>
<head>
<title>Untitled Document</title>
<meta http-equiv=&quot;Content-Type&quot; content=&quot;text/html; charset=iso-8859-1&quot;>
</head>

<body bgcolor=&quot;#FFFFFF&quot; text=&quot;#000000&quot; onLoad=&quot;clock()&quot;>
<table width=&quot;400&quot; border=&quot;0&quot; cellspacing=&quot;0&quot; cellpadding=&quot;0&quot; height=&quot;150&quot; bgcolor=&quot;#CCCCFF&quot;>
<tr>
<td width=&quot;199&quot; align=&quot;center&quot; valign=&quot;middle&quot; height=&quot;174&quot;>
<table width=&quot;90%&quot; border=&quot;0&quot; cellspacing=&quot;0&quot; cellpadding=&quot;0&quot; height=&quot;151&quot; bgcolor=&quot;#FFFFFF&quot;>
<tr>
<td height=&quot;139&quot; valign=&quot;top&quot;><iframe src=&quot;&quot; name=&quot;messwin&quot; scrolling=&quot;yes&quot; width=&quot;100%&quot; height=&quot;100%&quot;></iframe></td>
</tr>
</table>
</td>
<td width=&quot;201&quot; valign=&quot;top&quot; height=&quot;174&quot;>
<form name=&quot;updater&quot; action=&quot; method=&quot;get&quot; target=&quot;messwin&quot;>
<p><br>
type your message here
<input type=&quot;text&quot; name=&quot;message&quot; value=&quot;&quot;>
</p>

// this is the select array I want to change

<select name=&quot;touser&quot;>
<option>user</option>
<option>tels</option>
<option>paul</option>
</select>

<input type=&quot;submit&quot; name=&quot;send&quot; value=&quot;send&quot;>
<input type=&quot;hidden&quot; name=&quot;method&quot; value=&quot;update&quot;>
<input type=&quot;hidden&quot; name=&quot;username&quot; value=&quot;paul&quot;>
<input type=&quot;hidden&quot; name=&quot;curtime&quot; value=&quot;23:59:59&quot;>
</form>

</td>
</tr>
</table>
</body>
</html>

Mixed Linux/Win2000 Network Administrator
 
Here is an error:

window.top.document.updater.touser[options][1].text='paul';

Each <select> has an array of <option> elements, and each one of them should be accessed as select.options[] array item.
 
sorry,
this is the correct syntax:

window.top.document.updater.touser.options[1].text='paul';

(you shouldn't hurry when you post)
 
Nope. didn't work.
Heres the cgi output

<html>
<head>
<meta http-equiv=&quot;refresh&quot; content=&quot;10&quot;>
<script language=&quot;JavaScript&quot;>
function upDate(){
window.top.document.updater.touser[options][0].text='tels';
window.top.document.updater.touser[options][1].text='paul';
window.top.document.updater.touser[options][2].text='test';

}</script>

I have definately confirmed - everything else on the page is well formed and not in the slightest erroneous.
Mixed Linux/Win2000 Network Administrator
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top