Jump to content

Recommended Posts

Hi all,

 

I have an issue on my javascript code which I'd like you help with.

 

I have a form validator functionality which check if a value is filled onsubmit and alerts then if its not. it looks like so:

<script type="text/javascript">
function validate_form ( ) {
valid = true;
if (document.acform.c_city1.value == "") {
alert ( "Please note the first box must be filled to create a result" );
valid = false;
}
return valid;
}
</script>
 

Now this works perfectly fine no issues at all. The problem comes when I tell the above function to do something else. Which looks like so:

<script type="text/javascript">
function validate_form ( ) {
valid = true;
if (document.acform.c_city1.value == "") {
alert ( "Please note the first box must be filled to create a result" );
valid = false;
}
if ( (document.acform.c_city1.value != "") && (document.acform.c_city2.value != "") ) {
window.open("<?php echo 'town1.php?c_city1=' . $c_city1 . '' ?>");
window.open("<?php echo 'town2.php?c_city2=' . $c_city2 . '' ?>");
}
return valid;
}
</script> 

From the above, the second if statement, am asking it to open two windows, but then none of the statements work and I then get the following error:
 

 

Message: Unterminated string constant
Line: 20
Char: 20
Code: 0

Message: Object expected
Line: 2
Char: 1
Code: 0
 

 

Please I need you help as I can see any obvious errors and don't know why it doesn't work at all.

 

Many thanks

Edited by kamal213
Link to comment
https://forums.phpfreaks.com/topic/285586-open-multiple-windows/
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.