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
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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.