kev wood Posted May 13, 2008 Share Posted May 13, 2008 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. Quote Link to comment Share on other sites More sharing options...
Psycho Posted May 13, 2008 Share Posted May 13, 2008 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' Quote Link to comment Share on other sites More sharing options...
kev wood Posted May 15, 2008 Author Share Posted May 15, 2008 thanks for your reply Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.