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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

form element accessible from javascript

Status
Not open for further replies.

tyris

Programmer
Nov 2, 2000
311
0
0
FR
hi,
i need to have an element in my form where i can modify the value thanks to javascript. The problem is that i'd like to use something else than an input, i don't want to use a box, i'd like to have an element that apears like simple text
i mean to have something like :

value : <some element value=&quot;toto&quot;>

and not like

value : <INPUT NAME=&quot;test&quot; VALUE=&quot;toto&quot;>

so that the display result would be exactly like what you se here :

value : toto
(no box, no input)

where the toto field is an element i can access with javascript. is there a way to have something like this ? Best regards,
Elise, XML learning girl X-)
 
Maybe you can try
<input type=&quot;hidden&quot; value=&quot;toto&quot; name=&quot;test&quot;> ------------------
Freedom is a Right
 
in fact i don't want to hide the element, i'd like to keep it visible, or i would have used an hidden input as usual... but the form element must simply not be a box, look like a simple label, but visible Best regards,
Elise, XML learning girl X-)
 
If you're only using IE you can do this with a textbox by changing styles to make the borders disappear and by disabling the control to stop the user typing.

This may be possible with Netscape but I haven't tried it myself.

Again, if you are using IE only you can always use an inline DIV tag and set it's content from javascript. This will not work on Netscape unless you use absolute positioning for the DIV tag.

Code:
<p>Value: <div id=&quot;myVal&quot;></div></p>

<script>
    document.all[&quot;myVal&quot;].innerHTML = value;
</script>
[code]

Hope that helps
 [u]Bill Bruggemeyer[/u]
 
great ! i used the second solution you gave me but i'd be curious to know how to remove borders with the style part of the element. if you can give me a sample i'd be happy thanks :) Best regards,
Elise, XML learning girl X-)
 
you can disable border and edit like this :

<input type=&quot;text&quot; name=&quot;toto&quot; style=&quot;border:0;&quot; value=&quot;foo&quot; onclick=&quot;blur()&quot; onfocus=&quot;blur()&quot; onunfocus=&quot;blur()&quot; onpress=&quot;blur&quot;>

I think its IE only though (not sure havn't tested in netscrap) Regards

Big Dave

davidbyng@hotmail.com


** If I am wrong I am sorry, but i'm only trying to help!! **

 
davidbyng, what amazing i didn't know this could give this kind of result ! thanks i learned something interesting today :) i user the inneHTML property i ignored too finaly, thanks to you all.

ps : sorry for my coarse english Best regards,
Elise, XML learning girl X-)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top