Jump to content

Onclick show code


jaymc

Recommended Posts

I want to have a link on a webpage that when clicked the link text is replaced by a form field

So, on the webpage would be

[b]Click here to view the file upload box[/b]

Then when they click that, the 'Click here to view the file upload box' text is replaced with this code

[b]<input type='file' name='send'>[/b]

Which will obviously display an input box

What code would do this effectively.

Note, using document.write wont work alone as it will delete the rest of the page contents and jsut write out the form code

Thanks
Link to comment
Share on other sites

while divs are much better ways. You could do something:

[code]
function toBox(field)
{
    field.innerHTML = "<input type='file' name='send'>";
}
<span onClick="toBox(this)" id="field">Click here to view the file upload box</span>
[/code]

Something like this will work. But try hiding and showing divs.
Link to comment
Share on other sites

Ahh, Ive ran into a problem

    field.innerHTML = "<input type='file' name='send'>";

When the click [b]<span onClick="toBox(this)" id="field">Click here to view the file upload box</span>[/b] The input file box loads fine... great !!

But, when clicking browse and selecting a file, the file location does not load into the box

I'm guessing because its not fully part of the page code, as it was called upon after the page/form load

Any ways around that?

Hope Ive explained well enough
Link to comment
Share on other sites

No... basically when you click browse on any input file box, you select a file from your local HD and the DIR path will be loaded in the text area box..

Well, its not loading in their, obviously because of some kind of issue of how the input box is being loaded
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.