Solved

Trying to pre-populate HTML form

Posted on 2011-03-23
9
353 Views
Last Modified: 2012-05-11
I'm trying to pre-populate a form and the following is giving me trouble.

Here is the HTML on the form:
<div id="pbx_upload_html_0" class="pbx_upload_group pbx_hidden">
      <div class="pbx_upload_block">
            <div class="pbx_upload_block_input"><input name="photo" type="file" /></div>
            <div class="pbx_upload_block_clear pbx_hidden"><a href="#" class="pbx_upload_remove_file" onclick="return false;">Remove file</a></div>
      </div><div class="pbx_upload_block">
            <div class="pbx_upload_block_input"><input name="photo" type="file" /></div>
            <div class="pbx_upload_block_clear pbx_hidden"><a href="#" class="pbx_upload_remove_file" onclick="return false;">Remove file</a></div>
      </div><div class="pbx_upload_block">
            <div class="pbx_upload_block_input"><input name="photo" type="file" /></div>

            <div class="pbx_upload_block_clear pbx_hidden"><a href="#" class="pbx_upload_remove_file" onclick="return false;">Remove file</a></div>
      </div>
</div><div id="pbx_upload_html_1" class="pbx_upload_group">
      <div class="pbx_upload_block">
            <div class="pbx_upload_block_input"><input name="photo" type="file" /></div>
            <div class="pbx_upload_block_clear pbx_hidden"><a href="#" class="pbx_upload_remove_file" onclick="return false;">Remove file</a></div>
      </div><div class="pbx_upload_block">
            <div class="pbx_upload_block_input"><input name="photo" type="file" /></div>

            <div class="pbx_upload_block_clear pbx_hidden"><a href="#" class="pbx_upload_remove_file" onclick="return false;">Remove file</a></div>
      </div><div class="pbx_upload_block">
            <div class="pbx_upload_block_input"><input name="photo" type="file" /></div>
            <div class="pbx_upload_block_clear pbx_hidden"><a href="#" class="pbx_upload_remove_file" onclick="return false;">Remove file</a></div>
      </div>
</div>

I thought this would do it:

WebBrowser2.Document.All.Item("pbx_upload_html_0").Value = "test.jpg"

But, it is not.
0
Comment
Question by:hrolsons
  • 4
  • 2
  • 2
  • +1
9 Comments
 
LVL 51

Expert Comment

by:HainKurt
ID: 35200754
try

WebBrowser2.Document.GetElementById("pbx_upload_html_0").Value = "test.jpg"

0
 

Author Comment

by:hrolsons
ID: 35200782
HainKurt:  I tried that and got:

Run-time error '438':
Object doesn't support this property or method.
0
 
LVL 8

Expert Comment

by:imantas
ID: 35201344
Currently, "pbx_upload_html_0" is assigned to the DIV which isn't supposed to support "Value".
You should assign ID to the INPUT element instead of DIV and then try to change it's value, but I'm not sure about the inputs with type="file".

WebBrowser2.Document.All.Item("pbx_upload_html_input_0").Value = "test.jpg"

Open in new window


Where "pbx_upload_html_input_0" is the ID of the input.
0
 
LVL 51

Expert Comment

by:HainKurt
ID: 35201418
what are you trying to do?

WebBrowser2.Document.GetElementById("pbx_upload_html_0").innerHTML = "<img src='test.jpg'>"

is this what you want?

0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 

Author Comment

by:hrolsons
ID: 35201611
imantas: I got:

Run-time error '91':
Object variable or With block variable not set.
0
 

Author Comment

by:hrolsons
ID: 35201627
HainKurt:

I didn't get an error with your code, but it didn't do what i needed.

What I'm trying to do is automate the upload of a file.  I normally go to the website, click in the textbox and choose my file with my mouse.  Now, I want, let's say C:\test.jpg, to be automatically put into the textbox.
0
 
LVL 5

Accepted Solution

by:
MedievalWarrior earned 500 total points
ID: 35202485
The problem is the input type used "file" this doesn't allow you to insert values as security measure. If you could then it would let anyone upload files from a users computer just by visiting the website. It just makes sure the user is really making the choice.. Maybe disable security
0
 
LVL 5

Assisted Solution

by:MedievalWarrior
MedievalWarrior earned 500 total points
ID: 35202497
Here is link that I missed to go with the previous post

PRB: Cannot Use Script to Manipulate INPUT TYPE=File Value
http://support.microsoft.com/kb/266087
0
 

Author Closing Comment

by:hrolsons
ID: 35202517
Bummer
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
Find out what you should include to make the best professional email signature for your organization.
In this tutorial viewers will learn how to embed videos in a webpage using HTML5. Ensure your DOCTYPE declaration is set to HTML5: "<!DOCTYPE html>": Use the <video> tag to insert a video. Define the src as the URL of your video; this is similar to …
Video by: Mark
This lesson goes over how to construct ordered and unordered lists and how to create hyperlinks.

863 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now