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

hiding and displaying form elements with a function from a URL

Status
Not open for further replies.

DoctorGonzo

Programmer
Jan 23, 2004
48
0
0
GB
Hi guys,

I am trying to hide a form element with the ID "question1" and display a form element called "question2" (both of these are tables) with a link and function - but it is not working - thus: (I am getting "syntax error in my javascript alert)

This is my link :

<a href=javascript:nextQuestion(question1, question2)>Next Question</a>

function nextQuestion(last, next){
last.style.display="none";
next.style.display="block";
}

I have tried passing the 2 elements in the brackets both with and without quotes.... can anyone please advise?

I want to use this function over and over, passing different elemnts as the quiz progresses.

Many thanks as always!!

Gonzo
 
Try this.
[tt]
<a href="#" onclick="nextQuestion('question1', 'question2')">Next Question</a>

function nextQuestion(last, next){
document.getElementById(last).style.display="none";
document.getElementById(next).style.display="block";
}
[/tt]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top