•
•
•
•
What is DaniWeb IT Discussion Community?
You're currently browsing the JavaScript / DHTML / AJAX section within the Web Development category of DaniWeb, a massive community of 374,148 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 3,461 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our JavaScript / DHTML / AJAX advertiser: Lunarpages Web Hosting
Views: 667 | Replies: 4 | Solved
![]() |
i have created a page which has an iframe held on it i now what to post the data from this iframe and make it available to my other php page. I have researched this a bit and found out it can be done using javascript. the code i have found is this.
i am not to up on javascript so a little help is needed with this. i know the first element is the name of the hidden input i want to post, were i loose understanding is the next element name. is this the name of the page that the information needs to be posted to or is this how it posts it to the page the iframe is held on (main being the name used for that).
<script type="text/javascript">
document.getElementsByName('rand')[0].value = document.getElementsByName('main')[0].src;
</script>i am not to up on javascript so a little help is needed with this. i know the first element is the name of the hidden input i want to post, were i loose understanding is the next element name. is this the name of the page that the information needs to be posted to or is this how it posts it to the page the iframe is held on (main being the name used for that).
from my research i think i am beginning to understand this code a bit more but if someone knows if i am wrong please tell me.
as it is asking for the element by name then the number in the [] is not needed as this is the elements id number in the array. So as i have put the name rand in it will already know which element i want to post.
the next part is what i am still struggling to understand. It has the =value section and this is where i am stuck. the value in this section i think must have something to do with where the information is being posted to but as the the page were i found this code did not explain things to greatly i am lost.
please someone explain this code to me or point me in the right direction of were to find a good example and explanation of the code so i can then try to implement the code on to my site.
as it is asking for the element by name then the number in the [] is not needed as this is the elements id number in the array. So as i have put the name rand in it will already know which element i want to post.
the next part is what i am still struggling to understand. It has the =value section and this is where i am stuck. the value in this section i think must have something to do with where the information is being posted to but as the the page were i found this code did not explain things to greatly i am lost.
please someone explain this code to me or point me in the right direction of were to find a good example and explanation of the code so i can then try to implement the code on to my site.
<script type="text/javascript">
document.getElementsByName('rand')[0].value = document.getElementsByName('main')[0].src;
</script>getElementsByName returns a nodelist i.e. an array of all the elements which go by that name. Hence the array indexing operator [] is a must. If you are pretty sure that there is only one element on the entire page which goes by that name, you can do document.getElementsByName('name')[0] . The first line probably sets the value of some form element e.g. an input element and the second line probably sets the source of the iframe element which goes by the name of 'main' . "I don't accept change. I don't deserve to live."
"Working a real job is a win if you're lazy, greedy, or unmotivated. If you're average, you fit right in. And if you're above average, the basic terms of employment and premise of the arrangement is against your interests."
"Working a real job is a win if you're lazy, greedy, or unmotivated. If you're average, you fit right in. And if you're above average, the basic terms of employment and premise of the arrangement is against your interests."
![]() |
•
•
•
•
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
•
•
•
•
•
•
•
•
DaniWeb JavaScript / DHTML / AJAX Marketplace
•
•
•
•
access advice breach broadband business code code injection combo crime cult of the dead cow daniweb data data protection data transfer database drive dropdownlist encryption epilepsy europe firefox forensic forensics gadget government hacking hard hardware help hitachi hp html industrial espionage internet javascript linux mobile module net news privacy protection reuse search security storage terabyte tv web wikipedia
- Advanced verification on error checking (PHP)
- posting data from a form to msg broker fail (RSS, Web Services and SOAP)
- how to send data in POST method using javascript (JavaScript / DHTML / AJAX)
- mysql data (JSP)
- One form, posting to two scripts? (PHP)
- Just another "Best Offer" Need for Help! (Viruses, Spyware and other Nasties)
- Experienced C# .NET developer looking for offsite job! (Post your Resume)
- Javascript array from sql query (JSP)
- Posting form data to an Oracle database (JavaScript / DHTML / AJAX)
Other Threads in the JavaScript / DHTML / AJAX Forum
- Previous Thread: Field with UPPERCASE but without soecial characters
- Next Thread: Area Shape Map question



Linear Mode