Velocity Reviews

Velocity Reviews (http://www.velocityreviews.com/forums/index.php)
-   Javascript (http://www.velocityreviews.com/forums/f68-javascript.html)
-   -   change text color onclick, and change it back - will post to DB (http://www.velocityreviews.com/forums/t930446-change-text-color-onclick-and-change-it-back-will-post-to-db.html)

apparker 03-28-2007 07:12 PM

change text color onclick, and change it back - will post to DB
 
I'm creating a new GUI for a program and it is for a medical exam.
There are so many different things to ask someone during a history it
wastes too much space to make checkboxes for everything so I had an
idea:

Can I simply create a list of conditions and when the doctor clicks
them, they turn red? And clicking them again would make them default
again? This would really make the exam better since the doctor could
quickly glance at a page of hundreds of things and see what the person
has.

I'd also like the event to post "1" or "0" to DB so the conditions can
be saved into the DB.

Anyone ever heard of something like this?


-Lost 03-29-2007 01:37 AM

Re: change text color onclick, and change it back - will post to DB
 
"apparker" <adamparkerod@gmail.com> wrote in message
news:1175109142.713946.161990@b75g2000hsg.googlegr oups.com...
> I'm creating a new GUI for a program and it is for a medical exam.
> There are so many different things to ask someone during a history it
> wastes too much space to make checkboxes for everything so I had an
> idea:
>
> Can I simply create a list of conditions and when the doctor clicks
> them, they turn red? And clicking them again would make them default
> again? This would really make the exam better since the doctor could
> quickly glance at a page of hundreds of things and see what the person
> has.


You are in luck. Very recently someone threw together a nifty example.

http://groups.google.com/group/comp....9b47d50fc007b1

> I'd also like the event to post "1" or "0" to DB so the conditions can
> be saved into the DB.
>
> Anyone ever heard of something like this?


Sure, submit all your checkboxes (and the form) to your server-side script. Of course, if
checked, submit 1, if not, 0.

-Lost



apparker 03-29-2007 01:54 AM

Re: change text color onclick, and change it back - will post to DB
 
On Mar 28, 8:37 pm, "-Lost" <missed-s...@comcast.net> wrote:
> "apparker" <adamparke...@gmail.com> wrote in message
>
> news:1175109142.713946.161990@b75g2000hsg.googlegr oups.com...
>
> > I'm creating a new GUI for a program and it is for a medical exam.
> > There are so many different things to ask someone during a history it
> > wastes too much space to make checkboxes for everything so I had an
> > idea:

>
> > Can I simply create a list of conditions and when the doctor clicks
> > them, they turn red? And clicking them again would make them default
> > again? This would really make the exam better since the doctor could
> > quickly glance at a page of hundreds of things and see what the person
> > has.

>
> You are in luck. Very recently someone threw together a nifty example.
>
> http://groups.google.com/group/comp....wse_thread/thr...
>
> > I'd also like the event to post "1" or "0" to DB so the conditions can
> > be saved into the DB.

>
> > Anyone ever heard of something like this?

>
> Sure, submit all your checkboxes (and the form) to your server-side script. Of course, if
> checked, submit 1, if not, 0.
>
> -Lost


Wow that's great stuff... looks like the code is built around the
checkbox but could be altered for radios? Would it be possible to not
have the checkbox at all?


-Lost 03-29-2007 02:19 AM

Re: change text color onclick, and change it back - will post to DB
 
"apparker" <adamparkerod@gmail.com> wrote in message
news:1175133298.398729.198620@o5g2000hsb.googlegro ups.com...
> On Mar 28, 8:37 pm, "-Lost" <missed-s...@comcast.net> wrote:
>> "apparker" <adamparke...@gmail.com> wrote in message
>>
>> news:1175109142.713946.161990@b75g2000hsg.googlegr oups.com...
>>
>> > I'm creating a new GUI for a program and it is for a medical exam.
>> > There are so many different things to ask someone during a history it
>> > wastes too much space to make checkboxes for everything so I had an
>> > idea:

>>
>> > Can I simply create a list of conditions and when the doctor clicks
>> > them, they turn red? And clicking them again would make them default
>> > again? This would really make the exam better since the doctor could
>> > quickly glance at a page of hundreds of things and see what the person
>> > has.

>>
>> You are in luck. Very recently someone threw together a nifty example.
>>
>> http://groups.google.com/group/comp....wse_thread/thr...
>>
>> > I'd also like the event to post "1" or "0" to DB so the conditions can
>> > be saved into the DB.

>>
>> > Anyone ever heard of something like this?

>>
>> Sure, submit all your checkboxes (and the form) to your server-side script. Of course,
>> if
>> checked, submit 1, if not, 0.
>>


>
> Wow that's great stuff... looks like the code is built around the
> checkbox but could be altered for radios?


I do not see why not.

> Would it be possible to not
> have the checkbox at all?


Visually? Sure, hide them via CSS (display: none; will destroy layout; visibility:
hidden; will preserve it).

You do not want to get rid of the checkboxes or radio inputs altogether. You would have
to code a scheme by which to trap 1 and 0s, and eventually send it to the server.

Keeping the form intact insures the ability to submit form contents.

-Lost




apparker 03-29-2007 02:37 AM

Re: change text color onclick, and change it back - will post to DB
 
On Mar 28, 9:19 pm, "-Lost" <missed-s...@comcast.net> wrote:
> "apparker" <adamparke...@gmail.com> wrote in message
>
> news:1175133298.398729.198620@o5g2000hsb.googlegro ups.com...
>
>
>
> > On Mar 28, 8:37 pm, "-Lost" <missed-s...@comcast.net> wrote:
> >> "apparker" <adamparke...@gmail.com> wrote in message

>
> >>news:1175109142.713946.161990@b75g2000hsg.google groups.com...

>
> >> > I'm creating a new GUI for a program and it is for a medical exam.
> >> > There are so many different things to ask someone during a history it
> >> > wastes too much space to make checkboxes for everything so I had an
> >> > idea:

>
> >> > Can I simply create a list of conditions and when the doctor clicks
> >> > them, they turn red? And clicking them again would make them default
> >> > again? This would really make the exam better since the doctor could
> >> > quickly glance at a page of hundreds of things and see what the person
> >> > has.

>
> >> You are in luck. Very recently someone threw together a nifty example.

>
> >>http://groups.google.com/group/comp....wse_thread/thr...

>
> >> > I'd also like the event to post "1" or "0" to DB so the conditions can
> >> > be saved into the DB.

>
> >> > Anyone ever heard of something like this?

>
> >> Sure, submit all your checkboxes (and the form) to your server-side script. Of course,
> >> if
> >> checked, submit 1, if not, 0.

>
> > Wow that's great stuff... looks like the code is built around the
> > checkbox but could be altered for radios?

>
> I do not see why not.
>
> > Would it be possible to not
> > have the checkbox at all?

>
> Visually? Sure, hide them via CSS (display: none; will destroy layout; visibility:
> hidden; will preserve it).
>
> You do not want to get rid of the checkboxes or radio inputs altogether. You would have
> to code a scheme by which to trap 1 and 0s, and eventually send it to the server.
>
> Keeping the form intact insures the ability to submit form contents.
>
> -Lost


perfect... love it, thanks so much!


apparker 03-29-2007 03:03 AM

Re: change text color onclick, and change it back - will post to DB
 
On Mar 28, 9:37 pm, "apparker" <adamparke...@gmail.com> wrote:
> On Mar 28, 9:19 pm, "-Lost" <missed-s...@comcast.net> wrote:
>
>
>
> > "apparker" <adamparke...@gmail.com> wrote in message

>
> >news:1175133298.398729.198620@o5g2000hsb.googlegr oups.com...

>
> > > On Mar 28, 8:37 pm, "-Lost" <missed-s...@comcast.net> wrote:
> > >> "apparker" <adamparke...@gmail.com> wrote in message

>
> > >>news:1175109142.713946.161990@b75g2000hsg.google groups.com...

>
> > >> > I'm creating a new GUI for a program and it is for a medical exam.
> > >> > There are so many different things to ask someone during a history it
> > >> > wastes too much space to make checkboxes for everything so I had an
> > >> > idea:

>
> > >> > Can I simply create a list of conditions and when the doctor clicks
> > >> > them, they turn red? And clicking them again would make them default
> > >> > again? This would really make the exam better since the doctor could
> > >> > quickly glance at a page of hundreds of things and see what the person
> > >> > has.

>
> > >> You are in luck. Very recently someone threw together a nifty example.

>
> > >>http://groups.google.com/group/comp....wse_thread/thr...

>
> > >> > I'd also like the event to post "1" or "0" to DB so the conditions can
> > >> > be saved into the DB.

>
> > >> > Anyone ever heard of something like this?

>
> > >> Sure, submit all your checkboxes (and the form) to your server-side script. Of course,
> > >> if
> > >> checked, submit 1, if not, 0.

>
> > > Wow that's great stuff... looks like the code is built around the
> > > checkbox but could be altered for radios?

>
> > I do not see why not.

>
> > > Would it be possible to not
> > > have the checkbox at all?

>
> > Visually? Sure, hide them via CSS (display: none; will destroy layout; visibility:
> > hidden; will preserve it).

>
> > You do not want to get rid of the checkboxes or radio inputs altogether. You would have
> > to code a scheme by which to trap 1 and 0s, and eventually send it to the server.

>
> > Keeping the form intact insures the ability to submit form contents.

>
> > -Lost

>
> perfect... love it, thanks so much!


another question, could other css styles interfere with this trick? I
got it working on a simple page, but not a complicated one with lots
of js and css styles.


-Lost 03-29-2007 05:09 AM

Re: change text color onclick, and change it back - will post to DB
 
"apparker" <adamparkerod@gmail.com> wrote in message
news:1175137389.598450.5790@o5g2000hsb.googlegroup s.com...
>>
>> > >> > I'm creating a new GUI for a program and it is for a medical exam.
>> > >> > There are so many different things to ask someone during a history it
>> > >> > wastes too much space to make checkboxes for everything so I had an
>> > >> > idea:

>>
>> > >> > Can I simply create a list of conditions and when the doctor clicks
>> > >> > them, they turn red? And clicking them again would make them default
>> > >> > again? This would really make the exam better since the doctor could
>> > >> > quickly glance at a page of hundreds of things and see what the person
>> > >> > has.

>>
>> > >> You are in luck. Very recently someone threw together a nifty example.

>>
>> > >>http://groups.google.com/group/comp....wse_thread/thr...

>>
>> > >> > I'd also like the event to post "1" or "0" to DB so the conditions can
>> > >> > be saved into the DB.

>>
>> > >> > Anyone ever heard of something like this?

>>
>> > >> Sure, submit all your checkboxes (and the form) to your server-side script. Of
>> > >> course,
>> > >> if
>> > >> checked, submit 1, if not, 0.

>>
>> > > Wow that's great stuff... looks like the code is built around the
>> > > checkbox but could be altered for radios?

>>
>> > I do not see why not.

>>
>> > > Would it be possible to not
>> > > have the checkbox at all?

>>
>> > Visually? Sure, hide them via CSS (display: none; will destroy layout; visibility:
>> > hidden; will preserve it).

>>
>> > You do not want to get rid of the checkboxes or radio inputs altogether. You would
>> > have
>> > to code a scheme by which to trap 1 and 0s, and eventually send it to the server.

>>
>> > Keeping the form intact insures the ability to submit form contents.

>>
>> > -Lost

>>
>> perfect... love it, thanks so much!

>
> another question, could other css styles interfere with this trick? I
> got it working on a simple page, but not a complicated one with lots
> of js and css styles.


In a word, yes.

-Lost



Dr J R Stockton 03-29-2007 03:47 PM

Re: change text color onclick, and change it back - will post to DB
 
In comp.lang.javascript message <1175109142.713946.161990@b75g2000hsg.go
oglegroups.com>, Wed, 28 Mar 2007 12:12:22, apparker
<adamparkerod@gmail.com> posted:

>Can I simply create a list of conditions and when the doctor clicks
>them, they turn red? And clicking them again would make them default
>again? This would really make the exam better since the doctor could
>quickly glance at a page of hundreds of things and see what the person
>has.


This illustrates the fundamentals of part of a possibility :-

<span onClick="alert(this.style.color=new Date()%0x1000000)">hhh</a>

But test the human-interface aspects carefully before committing
yourself to the approach.

It could be useful to select with a checkbox, but re-colour the
associated text as a better indication.

Perhaps each condition should have four states -
Default unconsidered
Condition applies
Condition does not apply
Condition considered but undecided.

It's a good idea to read the newsgroup c.l.j and its FAQ. See below.

--
(c) John Stockton, Surrey, UK. ?@merlyn.demon.co.uk Turnpike v6.05 IE 6
news:comp.lang.javascript FAQ <URL:http://www.jibbering.com/faq/index.html>.
<URL:http://www.merlyn.demon.co.uk/js-index.htm> jscr maths, dates, sources.
<URL:http://www.merlyn.demon.co.uk/> TP/BP/Delphi/jscr/&c, FAQ items, links.

Roger 03-31-2007 05:56 AM

Re: change text color onclick, and change it back - will post toDB
 
-Lost wrote:
> "apparker" <adamparkerod@gmail.com> wrote in message
> news:1175137389.598450.5790@o5g2000hsb.googlegroup s.com...
>>>>>>> I'm creating a new GUI for a program and it is for a medical exam.
>>>>>>> There are so many different things to ask someone during a history it
>>>>>>> wastes too much space to make checkboxes for everything so I had an
>>>>>>> idea:
>>>>>>> Can I simply create a list of conditions and when the doctor clicks
>>>>>>> them, they turn red? And clicking them again would make them default
>>>>>>> again? This would really make the exam better since the doctor could
>>>>>>> quickly glance at a page of hundreds of things and see what the person
>>>>>>> has.
>>>>>> You are in luck. Very recently someone threw together a nifty example.
>>>>>> http://groups.google.com/group/comp....wse_thread/thr...


Hi,

I asked the question leading to the response referenced above. Pasted
below is my modified script that processes radio buttons as well as
check boxes.

I ended up wrapping the input tag within the label tag and using
parentNode instead of nextSibling. nextSibling worked fine in the
example referenced above but can easily break if the input and label
tags are formatted on different lines (whitespace becomes a text node
and becomes the nextSibling).

As stated in the referenced thread, my form is pretty dense and may have
a hundred check boxes or radio buttons. The buff-ish background and
crimson colors seem to work well for me. I think the indentation below
is messed up from my translation from tabs to spaces -- sorry.

Roger


<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>

<title>
highlight checkbox labels
</title>

<style type="text/css">
body {background: #FFEBCD; color: #382400; font-family:
verdana,arial,sans-serif;}
..unchecked{ font-size: xx-small;}
..checked{ font-size: xx-small; color:crimson; font-weight:bold;}
..noBorder {font-size: xx-small;}
..numeric {text-align: right;}
</style>

<script type="text/javascript">
// Change the class name of a checkbox or radio button label to
highlight checked items
function setLabelStyle(x){
if (x.checked){
x.parentNode.className="checked";
if (x.getAttribute("type") == "radio") {
xName = x.name;
set = document.getElementsByName(xName);
for (var i=0;i<set.length;i+=1) {
if (!set[i].checked) {
set[i].parentNode.className="unchecked"; }
}
}
}
else{
x.parentNode.className="unchecked";
}
}

</script>

</head>
<body>
<form action="someaction">
<center>
<table>
<tr>
<td>
<label class="unchecked">
<input type="checkbox" id="check1"
onclick="setLabelStyle(this);">
Abraided
</label>
<br />
<label class="unchecked">
<input type="checkbox" id="check2"
onclick="setLabelStyle(this);">
Incised
</label>
<br />
<label class="unchecked">
<input type="checkbox" id="check3"
onclick="setLabelStyle(this);">
Pecked
</label>
<br />
<label class="unchecked">
<input type="checkbox" id="check4"
onclick="setLabelStyle(this);">
Scratched
</label>
<br />
</td>

<td>
<label class="unchecked">
<input type="radio" id="check21" name="myradio"
onclick="setLabelStyle(this);">
Abraided
</label>
<br />
<label class="unchecked">
<input type="radio" id="check22" name="myradio"
onclick="setLabelStyle(this);">
Incised
</label>
<br />
<label class="unchecked">
<input type="radio" id="check23" name="myradio"
onclick="setLabelStyle(this);">
Pecked
</label>
<br />
<label class="unchecked">
<input type="radio" id="check24" name="myradio"
onclick="setLabelStyle(this);">
Scratched
</label>
<br />
</td>
</tr>
</table>

</center>
</form>
</body>
</html>

ASM 03-31-2007 03:04 PM

Re: change text color onclick, and change it back - will post toDB
 
apparker a écrit :
> On Mar 28, 8:37 pm, "-Lost" <missed-s...@comcast.net> wrote:
>> "apparker" <adamparke...@gmail.com> wrote in message

>
> Wow that's great stuff... looks like the code is built around the
> checkbox but could be altered for radios? Would it be possible to not
> have the checkbox at all?


see my examples :

http://stephane.moriaux.perso.wanado...athologies.htm
http://stephane.moriaux.perso.wanado...ogies_form.htm


--
Stephane Moriaux et son (moins) vieux Mac déjà dépassé
Stephane Moriaux and his (less) old Mac already out of date


All times are GMT. The time now is 07:30 AM.

Powered by vBulletin®. Copyright ©2000 - 2014, vBulletin Solutions, Inc.
SEO by vBSEO ©2010, Crawlability, Inc.