/    Sign up×
Community /Pin to ProfileBookmark

Help needed to dynamically insert table on click of a Button

I am trying to change the content on click of the button.The following is the code

HTML CODE

<SCRIPT LANGUAGE=”JavaScript” SRC=”scr.js”>
</SCRIPT>

</head>
<body>
<table border=”0″ align=”center” >
<tr>
<td class =”three” ><u>April Class Listing-2007</u></td></tr></table>
<form action=”” name=”form1″>
<TABLE BORDER=”0″ cellspacing=10 cellpadding=10 align=”center” >
<TR>
<TH class=”three”>Training Location :</TH>
<TD ><select id=”location”>
<option value=”atlanta”>Atlanta</option>
<option value=”seattle”>Seattle</option>
<option value=”tampa”>Tampa</option>
<option value=”virtual”>virtual</option></select></TD><td><input type=”button” value=”submit” onclick=”inserttab()”>
</TR>

</form>

</table>
<br><br>

<div name=”i1″ class=”eight”><table border=1 bordercolor=’black’ cellspacing=0 cellpadding=2 class=’four’ align=’center’><tr class=’six’><td>Coursename<td>Date<td>Time<td>Seats<td>Instructor<td>Room</tr><tr><td>Intro to sql<td>Tuesday,April 17th<td>8:30-5.00<td>20<td>Scott/Toombs/</tr></table></span></span>

</body>

JAVAscript

window.myvalue = 0;
window.myvalue1=0;
var output = document.getElementById(“i1”);

function getValue()
{
myvalue = myvalue+1;
}
function getValue1()
{
myvalue1 = myvalue1+1;
}

function inserttab()
{

if (document.getElementById(“location”).value==”atlanta”)
{
if(myvalue<=0)
{

alert(myvalue);

var x=document.getElementsByName(“kala”);
x.=”<h1>Hello</h1>”;

document.getElementById(“i2″).style.visibility=”hidden”;

getValue();

}

}

if (document.getElementById(“location”).value==”seattle”)
{
if (myvalue1<=0)
{
alert(myvalue1);
document.getElementById(“i2″).style.visibility=”visible”;

document.getElementById(“i1″).style.visibility=”hidden”;
getValue1();

}

}

}

whenever user selects a value from drop down and hits the button i should be able to dynamically create a Table. at the same locationI was using insertadjacentHTMl but it doesnt work in Mozilla.Help is appreciated.

to post a comment
JavaScript

3 Comments(s)

Copy linkTweet thisAlerts:
@gil_davisApr 12.2007 — whenever user selects a value from drop down and hits the button i should be able to dynamically create a Table. at the same locationI was using insertadjacentHTMl but it doesnt work in Mozilla.Help is appreciated.[/QUOTE]Use W3 DOM methods like createElement() and appendChild().

www.w3schools.com/dom/met_document_createelement.asp

www.webreference.com/js/column44/createtag.html

www.w3schools.com/dom/met_element_appendchild.asp

www.webreference.com/js/column44/appendchild.html
Copy linkTweet thisAlerts:
@vijirubaApr 12.2007 — Ur post somewhat relates to the post id 737916.

Refer this post :

http://www.webdeveloper.com/forum/showthread.php?p=737916#post737916
Copy linkTweet thisAlerts:
@kalakauthorApr 12.2007 — I will try to implement it and thanks for all your suggestions.
×

Success!

Help @kalak spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.19,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...