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

Making a Submit Button dynamically disappear 1

Status
Not open for further replies.

codehead

Programmer
Aug 25, 1999
96
US
Hello All:

I want to make a Submit Button disappear when a check box is checked on a form. Does anyone know how to do this or can anyone point me to a similar example that I could adapt to my usage?

Thanks!

 
Code:
<script language="javascript">

function hideSubmit(chk, obj) {
   obj.style.display = (chk.checked) ? "none" : "inline";
}

</script>
<body>
<form name="blahForm">
<input type="checkbox" onclick="hideSubmit(this, document.getElementById('submitButton'))">Hide submit button.<br>
<input type="submit" value="submit" id="submitButton">
</form>
</body>

-kaht

...looks like you don't have a job, so why don't you get out there and feed Tina.
headbang.gif
[rockband]
headbang.gif
 
Hi Kaht,

I'm getting a JavaScript error:

Line: 87
Char: 1
Error: Obj expected

Thanks.

 
I gave you a 14 line example. The only way there's an error on line 87 is if you copied/pasted this into your own program. This being the case, you're gonna have to change the element names accordingly to get it to work.

The example I posted was supposed to be exactly that: an example.

It's doubtful you'll be able to stick it right into your page w/o changing the references to match your element names. Make the appropriate changes and see how it works.

-kaht

...looks like you don't have a job, so why don't you get out there and feed Tina.
headbang.gif
[rockband]
headbang.gif
 
Hi Kaht,

I didn't just "plunk" it into my program. I changed the references, but I'm still getting the error message. Could the problem be that I'm generating multiple checkboxes from my database:

<tr>
<%do while not tl_org.EOF%>
<td><input type="checkbox" name="TL_ORG" value="<%=tl_org("ORGANIZATION")%>" onclick="hideSubmit(this, document.getElementById('SubmitToCC'))"></td><td><strong><%=tl_org("ORGANIZATION")%></strong></td>
<%tl_org.movenext%>
<%Loop%>
</tr>

Thanks.

 
Sorry for the late response, I don't check TT much on the weekend.

When posting example code in the JS forum it's usually best to pull it from the view-source code that your browser sees. Reasons being:

1. I don't know what values are in your server side variables.
2. I can copy/paste it into a new html file to see the same behavior you're seeing.

Post the relevant portion (or all of it if it will fit) of your code from a view-source in the browser. It'll be a lot easier to help ya out that way.

-kaht

...looks like you don't have a job, so why don't you get out there and feed Tina.
headbang.gif
[rockband]
headbang.gif
 
Hi Kaht,

You are correct. Your code works correctly. It's something in my code that's causing the JavaScript to fail.

It's not the code snippet above, so I'm ripping my code down, piece by piece, to figure out what's causing the problem.

Thanks.

 
Ok, hope you get it working. If you need more help let us know.

-kaht

...looks like you don't have a job, so why don't you get out there and feed Tina.
headbang.gif
[rockband]
headbang.gif
 
Well, it's really weird! I took your code, put it in a new page, then added my code in, line-by-line and it runs O.K. now!!!! I added all of my code back in, so I don't know what was causing the the failure??? Really strange....
 
Glad it's working now.

-kaht

...looks like you don't have a job, so why don't you get out there and feed Tina.
headbang.gif
[rockband]
headbang.gif
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top