mike B
05-07-2009, 04:28 PM
New to JavaScript coding, help me write the last part.
I have everything working accept the last part and I don't know what to do.
function show() works and shows data entered in text box.
function open_win() works,but I only need it to open when there is a input
match say like the name Tom,otherwise I want function show() just to show the input.
Currently the new window opens every time the button is pressed needs to match input string only before window opens and then string print to window
I think these two lines are the problems
(whatever the input) document.getElementById('myDiv').innerHTML = string;
And var bselect= "Tom" open_win();
I think I need to set var to the string printed to page to solve the last part.
lastly, how to I get the blank window to the center of screen,as it covers
the data in the function show.
Thanks to all for any help.
Michael
Below is my code thus far
********************************************************
<html>
<head>
<title>Input</title>
<script>
var array = new Array();
function insert(val){
array[array.length]=val;
}
function show() {
var string="<b>Name :</b><br>";
for(i = 0; i < array.length; i++) {
string =string+array[i]+"<br>";
}
if(array.length > 0)
document.getElementById('myDiv').innerHTML = string;
var bselect= open_win();
function open_win(){
window.open("","_blank","toolbar=no, location=no, directories=no, status=no, menubar=no, scrollbars=yes, resizable=no,
copyhistory=no, width=200, height=305")
}
}
</script>
</head>
<body>
<h2>Input</h2>
<form name="form1">
<table width="407">
<tr>
<td width="154" align="right"><b>Name</b>
<td width="9"><b> :</b>
<td width="224">
<input type="text" name="name"/>
</tr>
<tr>
<td width="154" align="right">
<td width="9">
<td width="224">
</tr>
<tr>
<td width="154" align="right">
<td width="9">
<td width="224">
<input type="button" Value="Push to see input and open new window"
onclick="insert(this.form.name.value),show()"/>
</tr>
</table>
</form>
<div id="myDiv"></div>
</body>
</html>
*********************************************************
Dear Philip M , Old Pedant and all who took interest.
Thank you for your help in trying to resolve my prior post. I have gave up on that approach and it seems that this will give me something that's workable.
:o
I have everything working accept the last part and I don't know what to do.
function show() works and shows data entered in text box.
function open_win() works,but I only need it to open when there is a input
match say like the name Tom,otherwise I want function show() just to show the input.
Currently the new window opens every time the button is pressed needs to match input string only before window opens and then string print to window
I think these two lines are the problems
(whatever the input) document.getElementById('myDiv').innerHTML = string;
And var bselect= "Tom" open_win();
I think I need to set var to the string printed to page to solve the last part.
lastly, how to I get the blank window to the center of screen,as it covers
the data in the function show.
Thanks to all for any help.
Michael
Below is my code thus far
********************************************************
<html>
<head>
<title>Input</title>
<script>
var array = new Array();
function insert(val){
array[array.length]=val;
}
function show() {
var string="<b>Name :</b><br>";
for(i = 0; i < array.length; i++) {
string =string+array[i]+"<br>";
}
if(array.length > 0)
document.getElementById('myDiv').innerHTML = string;
var bselect= open_win();
function open_win(){
window.open("","_blank","toolbar=no, location=no, directories=no, status=no, menubar=no, scrollbars=yes, resizable=no,
copyhistory=no, width=200, height=305")
}
}
</script>
</head>
<body>
<h2>Input</h2>
<form name="form1">
<table width="407">
<tr>
<td width="154" align="right"><b>Name</b>
<td width="9"><b> :</b>
<td width="224">
<input type="text" name="name"/>
</tr>
<tr>
<td width="154" align="right">
<td width="9">
<td width="224">
</tr>
<tr>
<td width="154" align="right">
<td width="9">
<td width="224">
<input type="button" Value="Push to see input and open new window"
onclick="insert(this.form.name.value),show()"/>
</tr>
</table>
</form>
<div id="myDiv"></div>
</body>
</html>
*********************************************************
Dear Philip M , Old Pedant and all who took interest.
Thank you for your help in trying to resolve my prior post. I have gave up on that approach and it seems that this will give me something that's workable.
:o