Please help!

  • Thread starter Thread starter rcoco
  • Start date Start date
R

rcoco

Hi everyone,
I'm having trouble with a datagrid that is supposed to insert data.
But one row has to insert data in the data base using Radio button. So
I created two buttons one of Bad Mood then the other one is Good mood.
when one is selected, the data is to be inserted into the database.
this is working well. But the problem comes when it comes to images,
thes images are smilies. When good mood is selected I want a smiley to
be inserted into the database too. So I created the smilies but when
and made them invisible so I wrote this code to be able save them in
the database but I'm getting two errors. Where could I be wrong?

document.getElementById("imggm").style.visibility = "hidden";
function ChangeSmile()
{
if (document.getElementById("rblmood_0"))
{
document.getElementById("imggm").style.visibility = "none";
document.getElementById("imggm").src = "laughing.gif";
}
else
{
document.getElementById("imgbm").style.visibility = "visible";
document.getElementById("imgbm").src = "sad.gif";
}
}

The errors are:

Invalid token '(' in class, struct, or interface member declaration
Invalid token '=' in class, struct, or interface member declaration
(This error appears on the line:
document.getElementById("imggm").style.visibility = "hidden";)

Thanks.
 
thes images are smilies. When good mood is selected I want a smiley to
be inserted into the database too.
??

(This error appears on the line:
document.getElementById("imggm").style.visibility = "hidden";)

Are you sure?

Where do you call this javascript?
 
I supposed you know that js has to be called on the client (outside
code-behind).
 
Hi Alexey,
How do I call it and where I've never done this before? Could you
please help me?
Thanks
 
Hi Alexey,
How do I call it and where I've never done this before? Could you
please help me?
Thanks

If your page is:

<%@ Page ...

<html>
<head>

<script type="text/javascript" language="javascript">

-------------put your js-code here----------------

</script>
</head>

<body>
.....

But I'm not sure what you are doing there, because the javascript
doesn't work with database (and it cannot). The code you've posted
changes the picture.

If your buttons have runat=server then you should tell to your buttons
how to call the ChangeSmile function

VB code here...

Sub Page_Load(sender as Object, e as EventArgs)

Button1.Attributes.Add("onclick", "ChangeSmile()")
Button2.Attributes.Add("onclick", "ChangeSmile()")

End Sub

you should also have document.getElementById("rblmood_0") initialized
somehow
 
Back
Top