Solved

Trying to pre-populate HTML form

Posted on 2011-03-23
9
352 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
Comment Utility
try

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

0
 

Author Comment

by:hrolsons
Comment Utility
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
Comment Utility
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
Comment Utility
what are you trying to do?

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

is this what you want?

0
IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

 

Author Comment

by:hrolsons
Comment Utility
imantas: I got:

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

Author Comment

by:hrolsons
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
Bummer
0

Featured Post

Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

Things That Drive Us Nuts Have you noticed the use of the reCaptcha feature at EE and other web sites?  It wants you to read and retype something that looks like this.Insanity!  It's not EE's fault - that's just the way reCaptcha works.  But it is …
This is a PowerShell web interface I use to manage some task as a network administrator. Clicking an action button on the left frame will display a form in the middle frame to input some data in textboxes, process this data in PowerShell and display…
In this tutorial viewers will learn how to style a corner ribbon overlay for an image using CSS Create a new class by typing ".Ribbon":  Define the class' "display:" as "inline-block": Define its "position:" as "relative": Define its "overflow:" as …
HTML5 has deprecated a few of the older ways of showing media as well as offering up a new way to create games and animations. Audio, video, and canvas are just a few of the adjustments made between XHTML and HTML5. As we learned in our last micr…

763 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

9 Experts available now in Live!

Get 1:1 Help Now