Click to See Complete Forum and Search --> : How to change form elements dynamically?
Dave Straley
03-13-2000, 04:06 PM
Hi,
Can anyone direct me to sample code or a tutorial or discussion as to how
I can change a form's elements dynamically, without hitting the server?
I've seen this on a Microsoft search site, where the User chooses HOW they
want to search via Radio buttons, and based on HOW they chose, the Web page
instantly refreshes (without hitting the server) so as to show a Text input
box or a Select list, etc. I assume this is done in DHTML, but I can't figure
out how to pull it off.
Any leads would be appreciated!
Take care,
Dave Straley
Steve Cochran
03-14-2000, 09:39 AM
You can do this with the CreateElement function. See here for details and
example:
http://msdn.microsoft.com/workshop/Author/dhtml/reference/methods/createElem
ent.asp
steve
"Dave Straley" <djs@sandyhook.com> wrote in message
news:38cd4a4e$1@news.devx.com...
>
> Hi,
>
> Can anyone direct me to sample code or a tutorial or discussion as to how
> I can change a form's elements dynamically, without hitting the server?
> I've seen this on a Microsoft search site, where the User chooses HOW they
> want to search via Radio buttons, and based on HOW they chose, the Web
page
> instantly refreshes (without hitting the server) so as to show a Text
input
> box or a Select list, etc. I assume this is done in DHTML, but I can't
figure
> out how to pull it off.
>
> Any leads would be appreciated!
> Take care,
> Dave Straley
Dave Straley
03-14-2000, 10:00 AM
Steve,
Thanks a ton for that link. I checked it out and it's impressive. However,
it's not quite what I've seen in action on the MS site. For example, the
createElement() function says that it can't create Select lists. However,
on the MS site, when the User chose a certain Radio button, a select list
appeared.
The best that I can guess is that this is done with CSSS' layering capabilities,
presumably raising a different layer to the top? But I stil don't know how
to pull it off.
In my application, I do need to show/hide a select list vs. a text input
box, depending on which Radio button the User chose.
Thanks again,
Take care,
Dave Straley
"Steve Cochran" <scochran@chattanooga.net> wrote:
>You can do this with the CreateElement function. See here for details and
>example:
>
>http://msdn.microsoft.com/workshop/Author/dhtml/reference/methods/createElem
>ent.asp
>
>steve
Steve Cochran
03-16-2000, 09:32 AM
Hi Dave,
Well this was a bit trickier than I thought, but it should give you what you
want:
<HTML>
<BODY>
<p><Input name=rad1 type=radio onclick="whichrad()" language=vbs>First radio
<p><Input name=rad1 type=radio onclick="whichrad()" language=vbs>Second
radio
<p><input name=txt1 type=text value="" size=15 style="display:none">
<p><select name=sel1 size=1 style="display:none">
<option value=1>option1
<option value=2>option2
<option value=3>option3
</select>
<script langauge=vbs>
sub whichrad()
if rad1(0).checked="True" then
txt1.style.display=""
sel1.style.display="none"
elseif rad1(1).checked="True" then
txt1.style.display="none"
sel1.style.display=""
end if
end sub
</script>
</BODY>
</HTML>
The MSDN library is an invaluable site, I find, although at times I still
have to figure things out by myself. <G>
cheers,
steve
"Dave Straley" <djs@sandyhook.com> wrote in message
news:38ce45f4@news.devx.com...
>
> Steve,
>
> Thanks a ton for that link. I checked it out and it's impressive.
However,
> it's not quite what I've seen in action on the MS site. For example, the
> createElement() function says that it can't create Select lists. However,
> on the MS site, when the User chose a certain Radio button, a select list
> appeared.
>
> The best that I can guess is that this is done with CSSS' layering
capabilities,
> presumably raising a different layer to the top? But I stil don't know
how
> to pull it off.
>
> In my application, I do need to show/hide a select list vs. a text input
> box, depending on which Radio button the User chose.
>
> Thanks again,
> Take care,
> Dave Straley
>
>
>
> "Steve Cochran" <scochran@chattanooga.net> wrote:
> >You can do this with the CreateElement function. See here for details
and
> >example:
> >
>
>http://msdn.microsoft.com/workshop/Author/dhtml/reference/methods/createEle
m
> >ent.asp
> >
> >steve
>
Dave Straley
03-16-2000, 10:14 AM
Steve,
Wow! That's great! You gave me a solution which works "right out of the
box"! Thanks so much. The behavior of the form elements is just what I
was looking for. I owe you one, Steve!
Take care,
Dave Straley
"Steve Cochran" <scochran@chattanooga.net> wrote:
>Hi Dave,
>
>Well this was a bit trickier than I thought, but it should give you what
you
>want:
>
Steve Cochran
03-16-2000, 03:22 PM
Happy to help.
Don't put it inside of a form though. It screws up then.
cheers,
steve
"Dave Straley" <djs@sandyhook.com> wrote in message
news:38d0ec32$1@news.devx.com...
>
> Steve,
>
> Wow! That's great! You gave me a solution which works "right out of the
> box"! Thanks so much. The behavior of the form elements is just what I
> was looking for. I owe you one, Steve!
>
> Take care,
> Dave Straley
>
>
> "Steve Cochran" <scochran@chattanooga.net> wrote:
> >Hi Dave,
> >
> >Well this was a bit trickier than I thought, but it should give you what
> you
> >want:
> >
devx.com
Copyright WebMediaBrands Inc. All Rights Reserved