Solved

Trying to pre-populate HTML form

Posted on 2011-03-23
9
357 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 2
  • 2
  • +1
9 Comments
 
LVL 55

Expert Comment

by:Huseyin KAHRAMAN
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
Don't Cry: How Liquid Web is Ensuring Security

WannaCry is just the start. Read how Liquid Web is protecting itself and its customers against new threats.

 
LVL 55

Expert Comment

by:Huseyin KAHRAMAN
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

Enroll in June's Course of the Month

June’s Course of the Month is now available! Experts Exchange’s Premium Members, Team Accounts, and Qualified Experts have access to a complimentary course each month as part of their membership—an extra way to sharpen your skills and increase training.

Question has a verified solution.

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

This article discusses how to create an extensible mechanism for linked drop downs.
This article describes how to use a set of graphical playing cards to create a Draw Poker game in Excel or VB6.
In this tutorial viewers will learn how to style transparent/translucent elements using alpha transparency in CSS Start with a normal styled element, such as a div.: Define its "background-color" property as "rgba (255, 255, 255, .5): The numbers in…
In this tutorial viewers will learn how to code links for mobile sites that, once clicked, send a call or text to a specified number. For a telephone link (once clicked, calls a number), begin with a normal "<a href=" link tag. For the href, specify…

707 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