473,389 Members | 1,303 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,389 software developers and data experts.

javascript accessing i.e "data[3]" in a form

Hi

I am working on a PHP-script and need javascript to set the value of a
hidden field in a form. This field happens to be an entry in an array
data[3] according to my example. How can I do this?

Below is listet two PHP-pages: one that doesn't work (to my dismay), and
another that does work, but do not use an array entry in the hidden field.

Thanks

Esben

---------- Doesn't work as planned -----------------
<? print "data[3]=".$data[3]."\n";?>
<form action='<?$PHP_SELF?>' name='edit_form' method=post
enctype='multipart/form-data'>
<input type=hidden name='data[3]' value='default :-('>
<script language='javascript'>
document.edit_form.data[3].value = 'not default :-)';
</script>
<input type='submit'></form>
----------------------------------------------------------

----------Doesn't use arrays----------------------------
<? print "data3=".$data3."\n";?>
<form action='<?$PHP_SELF?>' name='edit_form' method=post
enctype='multipart/form-data'>
<input type=hidden name='data3' value='default :-('>
<script language='javascript'>
document.edit_form.data3.value = 'not default :-)';
</script>
<input type='submit'></form>
----------------------------------------------------------
Jul 23 '05 #1
1 1499


Esben Rune Hansen wrote:

I am working on a PHP-script and need javascript to set the value of a
hidden field in a form. This field happens to be an entry in an array
data[3] according to my example. How can I do this?


Check the FAQ:
http://jibbering.com/faq/
there you find
http://jibbering.com/faq/#FAQ4_25
http://www.jibbering.com/faq/faq_not...kets.html#illc

--

Martin Honnen
http://JavaScript.FAQTs.com/

Jul 23 '05 #2

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

Similar topics

3
by: Steven K | last post by:
Hello, I am using an asp page (upload.asp) to gather information and to upload files to the web server using SoftArtisans SAUpload Tool. In the first page (upload.asp), I have a form for...
3
by: 21novembre | last post by:
Hi all, I made a question several days before to describe my strange trouble of mysqldump. But I still can't figour it out. Well, I just want to ask another question whether I could just backup...
6
by: Jon Davis | last post by:
I recently learned how to do an <OBJECT> alternative to <IFRAME> in current browsers using: <object id="extendedhtml" type="text/html" data="otherpage.html" width="250" height="400"></object> ...
8
by: Jerry | last post by:
I have an off-the-shelf app that uses an Access database as its backend. One of the tables contains a field with an "OLE Object" datatype. I'm writing some reports against this database, and I...
7
by: Alex Maghen | last post by:
Hi. I had previously installed VS2005 beta 1. I carefully followed all the steps (I thought) to deinstall it and then installed beta 2. According to the documentation, the "Data" directory which...
6
by: P. Prosper | last post by:
Hello, Sorry for the cross-posting, I first posted this message to the vb.6 NG (wrong group) <g>. Are there any add-in or tools out there (for VB.NET ) that would allow one to drag and drop...
1
by: Stimp | last post by:
I have an asp.net page with a form and several <INPUT type=fileinput fields so that I can upload images via the form. I also have about 30 other standard dropdownlists and text boxes as part of...
3
by: nkoriginal | last post by:
Hello: I tried an script for keep my data form after reload page, but I've some errors. In this momento I runnung my own browser because we've an intranet. And for security reason, our page...
4
by: vunet.us | last post by:
Hi all, I am converting my app to AJAX-based. I have a form that submits some data including images. When I use AJAX XmlHttpRequest I am unable to submit the form with...
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: 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
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

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.