Solved

Trying to pre-populate HTML form

Posted on 2011-03-23
9
354 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
Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

 
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
 

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

Optimizing Cloud Backup for Low Bandwidth

With cloud storage prices going down a growing number of SMBs start to use it for backup storage. Unfortunately, business data volume rarely fits the average Internet speed. This article provides an overview of main Internet speed challenges and reveals backup best practices.

Question has a verified solution.

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

Suggested Solutions

This article describes some techniques which will make your VBA or Visual Basic Classic code easier to understand and maintain, whether by you, your replacement, or another Experts-Exchange expert.
Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
In this Micro Tutorial viewers will learn how to create navigation buttons that change on rollover, using CSS (Continuation of the CSS Image Sprite tutorial) Create a parent ID for all the list items       - Specify position: absolute and display: block…
In this tutorial viewers will learn how to position overlapping items using z-index in CSS. They will also learn the restrictions on the z-index property.  Create a new HTML document with an internal stylesheet.: Create a div in CSS and name it Red.…

803 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