/    Sign up×
Community /Pin to ProfileBookmark

My own browseFile button

[CODE]
<script>
function browse()
{
var btn = document.getElementById(“browseFile”);
btn.click();
}
</script>

<img src=browse.png alt=browse onclick=”browse();”/>

<input id=”browseFile” type=”file” style=”visibility:hidden;”>

[/CODE]

Not working damit 😑

to post a comment
JavaScript

6 Comments(s) ↴

Copy linkTweet thisAlerts:
@s0nofr4g3Nov 27.2005 β€”Β [CODE]


<img src=browse.png alt=browse onclick="browse();"/>


[/CODE]


Not working damit :mad:[/QUOTE]


could it be that you have no quotes 'round the source and alt??

try:
[CODE]


<img src=[COLOR=Red]"[/COLOR]browse.png[COLOR=Red]"[/COLOR] alt=[COLOR=Red]"[/COLOR]browse[COLOR=Red]"[/COLOR] onclick="browse();"/>


[/CODE]



is there some sort of 'all or none' rule, like you either have all ur stuff wrapped in qoutes or none of it wrapped???



maybe not... after all im not too great at this JS stuff...
Copy linkTweet thisAlerts:
@gert_cuykensauthorNov 27.2005 β€”Β no ? it has somthing to do with

Error btn has no properties
Copy linkTweet thisAlerts:
@konithomimoNov 27.2005 β€”Β Your script will work in IE, but click() does not work as you want it to in FireFox or NetScape. In those browsers click() just puts the focus on the textfield of the input. To make it work in those browsers you have to do [URL=http://www.codingforums.com/showpost.php?p=34595&postcount=5]this[/URL]
Copy linkTweet thisAlerts:
@gert_cuykensauthorNov 27.2005 β€”Β HTMLElement.prototype.click = function() {

var evt = this.ownerDocument.createEvent('MouseEvents');

evt.initMouseEvent('click', true, true, this.ownerDocument.defaultView, 1, 0, 0, 0, 0, false, false, false, false, 0, null);

this.dispatchEvent(evt);

}

I only have two words to add to this , holy and **** ? sorry :p
Copy linkTweet thisAlerts:
@gert_cuykensauthorNov 27.2005 β€”Β [CODE]
HTMLElement.prototype.click = function() {
var evt = this.ownerDocument.createEvent('MouseEvents');
evt.initMouseEvent('click', true, true, this.ownerDocument.defaultView, 1, 0, 0, 0, 0, false, false, false, false, 0, null);
this.dispatchEvent(evt);
}

function browse()
{
var btn = document.getElementById("browseFile");
btn.click();
}
[/CODE]


Hmmm nothing happens when i do this ?
Copy linkTweet thisAlerts:
@gert_cuykensauthorNov 27.2005 β€”Β [CODE]<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
<TITLE></TITLE>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"/>
<meta name="author" content=""/>
<meta name="date" content=""/>
<meta name="description" content=""/>
<meta name="keywords" content=""/>
<link rel="stylesheet" type="text/css" media="screen" href="css/screen.php" />

<link rel="shortcut icon" href="bin/favicon.ico">
<link rel="icon" href="bin/favicon.ico">
<script type="text/javascript">
HTMLElement.prototype.click = function()
{
var evt = this.ownerDocument.createEvent('MouseEvents');
evt.initMouseEvent('click', true, true, this.ownerDocument.defaultView, 1, 0, 0, 0, 0, false, false, false, false, 0, null);
this.dispatchEvent(evt);
}
</script>
</HEAD>
<BODY>
<div class="status">
text ok </div>

<form id="frm_register" name="frm_register" action="index.php" method="POST" enctype="multipart/form-data">

<label class="l01">login:</label> <input class="i01" name="login" type="text" value="" style= >
<label class="l02">passwd:</label> <input class="i02" name="passwd" type="password" value="" style= >
<label class="l03">first name:</label> <input class="i03" name="firstname" type="text" value="" style= >
<label class="l04">last name:</label> <input class="i04" name="lastname" type="text" value="" style= >
<label class="l05">address:</label> <input class="i05" name="adress" type="text" value="" style= >

<label class="l06">city:</label> <input class="i06" name="city" type="text" value="" style= >
<label class="l07">country:</label> <input class="i07" name="country" type="text" value="" style= >
<label class="l08">birthday:</label> <input class="i08" name="birthday" type="text" value='dd-mm-jjjj' onFocus="this.value=''" >
<label class="l09">gender:</label> <select class="i09" name="gender">
<option value="n/a" >n/a
<option value="female" >female
<option value="male" >male
</select>

<label class="l10">sig:</label> <input class="i10" name="sig" type="text" value='for example PGP:...' onFocus="this.value=''" >
<label class="l11">email:</label> <input class="i11" name="email" type="text" value="" style= >
<label class="l12">phone:</label> <input class="i12" name="phone" type="text" value="" style= >

<img id=pic src="file.php?id=310a7f5b7adab4f799a6ee14e5a5c26f" onclick="document.getElementById('browseFile').click();"/>
<input id="browseFile" name="browseFile" type="file" style="visibility:hidden;">

<input name="MAX_FILE_SIZE" type="hidden" value="500000">
<input name="frm_register" type="hidden" value="frm_register">
</FORM>
<div class="submit">
<img src="bin/submit.jpg" alt="submit" onclick="document.frm_register.submit()">
<img src="bin/cancel.jpg" alt="cancel" onclick="parent.location='index.php'">
</div>
</body>
</html>[/CODE]


This is the hole code any idea why the browse menu doesnt pop up ?
Γ—

Success!

Help @gert_cuykens spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 β€” BETA 5.20,
whats_new: community page,
up_next: more Davinciβ€’003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinciβ€’003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...