Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Need help with a simple Problem

Status
Not open for further replies.

BennySHS

Programmer
Mar 15, 2005
32
DE
Hi there!

I'm new to javascript and I got a problem that i cannot solve myself. I hope you can help me out ;)

The situation:
With a click on a link a DIV is set to visible.
In this div I got a input-field, and another link. With a click on this link I want to set the text of the input-field.

The problem:
When I click on the link to set the text of the input-field, I get a blank page with only the text I want to set to the input-field.

I can't explain this very good, so better check the problem online:

-> click on the "einfügen"-link and the DIV is set visible
-> then in this DIV click the other "einfügen"-link, now the value of the input-field should be set to 'test', but it doesn't work correct.

Thanks a lot for your help,
greets ben
 

Try adding "return(false);" to the link:

Code:
<a href="javascript:document.forms['linkform'].elements['ziel'].value = 'test'; return(false);">einfügen</a>

Hope this helps,
Dan


The answers you get are only as good as the information you give!

 

Scrap that. Use this instead:

Code:
<a href="javascript:void(0);" onclick="document.forms['linkform'].elements['ziel'].value = 'test';">

Hope this helps,
Dan


The answers you get are only as good as the information you give!

 
try adding "return false;" after the javascript in your link:
Code:
<a href="javascript: document.linkform.ziel.value = 'test'; return false;">einfügen</a>

by the way - i don't use these kind of links too much anymore. i prefer to use the onclick event of an element (e.g. a span) instead. i think i read somewhere that this was now the preferred method.
Code:
<span onclick="document.linkform.ziel.value = 'test'; return false;">einfügen</span>
 
hmmm should have refreshed the page before i posted back... glad the advice concurred though ;->
 
Hi guys!

Thanks a lot for your fast replies, u solved my problem ;)
Great!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top