Please help!

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.
 
A

Alexey Smirnov

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?
 
A

Alexey Smirnov

I supposed you know that js has to be called on the client (outside
code-behind).
 
R

rcoco

Hi Alexey,
How do I call it and where I've never done this before? Could you
please help me?
Thanks
 
A

Alexey Smirnov

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top