Forum Moderators: open
I have a form
<FORM METHOD=POST ACTION="new.php" name="form1">
<INPUT TYPE="text" NAME="domain_name2" value="">
<INPUT TYPE="button" value="Check Avialibity" onclick="openwindow()">
</form>
and script also..
<script type="text/javascript">
function openwindow(){
var txtval = document.form1.domain_name2.value; window.open("domain.php?domain_name3=txtval","win1","width=350,height=375,screenX=200,screenY=300,titlebar=no,scrollbars=auto,maximize=no");
}
</script>
Now when i click on the button, i want that domain_name2 textbox value should go to popup window.. i am trying that in the script.. but value is not passing..
any help?
Regards
tabish
A slightly different approach, note how I'm passing the form OBJECT and you don't have to explicitly reference the form name. This allows you to have several forms on the page and use the same code.
Also the thingy with the window ID insures each time it's clicked it opens in a NEW window instead of opening in the same window you've named win1. Lastly, you only need to call an attribute in open() if you need it - no need to add attribute=no.
In any case I don't see the problem, seems to work fine as you have it.
<FORM METHOD=POST ACTION="new.php" name="form1">
<INPUT TYPE="text" NAME="domain_name2" value="">
<INPUT TYPE="button" value="Check Availibity" onclick="openwindow(this.form)">
</form>
<script type="text/javascript">
function openwindow(form){
var txtval = form.domain_name2.value;
var day = new Date();
var id = day.getTime();
alert(txtval);
window.open("domain.php?domain_name3=txtval",id,"width=350,height=375,screenX=200,screenY=300,scrollbars=auto");
}
</script>