Jump to content

posting data


kev wood

Recommended Posts

i have a html form for uploading images held within an iframe.  i need to post a variable from this iframe to another php page held with the site.  i have found some code which is supposed to this but as i dont understand javascript the good i am having trouble trying to work out what the code means.

 

I know that in the first line it is asking what element it is that you want posting, and that the numbers in the [] is the elements array number, so this is not needed if the name has been entered (i think point this out if i am wrong).  it is the second line of the code i do not understand.  the code i have found is this.

 

<script type="text/javascript">
document.getElementsByName('hiddenvalue')[0].value = document.getElementsByName('main')[0].src;
</script>

 

if this code could be explained to me then i feel i will be able to implement it on to the site and then start finish the thing off.

 

i need this code to post a random number to a new page on the site so it can be used for the displaying of images.

Link to comment
https://forums.phpfreaks.com/topic/105398-posting-data/
Share on other sites

That code is pretty strit forward. There is an element ont he page with the name 'hiddenvalue' (I'm assuming it is a hidden input field). That code is setting the value of that field to the src attribute value of the element with the name 'main'.

 

Assuming these are the two elements

<nput type="hidden" name="hiddenvalue">
<img name="main" src="main_image.jpg">

 

Then the field 'hiddenvalue' will have the value of 'main_image.jpg'

Link to comment
https://forums.phpfreaks.com/topic/105398-posting-data/#findComment-540365
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.