Forum Moderators: coopster

Message Too Old, No Replies

image onclick problem

         

adamnichols45

1:21 pm on Dec 29, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



hi guys can you help me with this.

i have a simple text field and i would like to sumbit this value to a new window and add it to a database
problem is how to i click that image button to open a new window? i have tryed this

<INPUT TYPE="image" src="images/search_button.gif" onClick="window.open('search2.php?id=$idshow','mywindow','width=560,height=400')" name="submit">

but this does not work can any one help please.

Birdman

1:37 pm on Dec 29, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



It looks like you are out of PHP mode there...try this:

<INPUT TYPE="image" src="images/search_button.gif" onClick="window.open('search2.php?id=<?=$idshow?>','mywindow','width=560,height=400')" name="submit">

If that doesn't work, change the highlighted portion above to:

<?php print($idshow);?>

Regards

adamnichols45

2:01 pm on Dec 29, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



hi birdman-

ok it opens the new window but does not pass the varible over correctly.

code is

<INPUT TYPE="image" src="images/signup.gif" onClick="window.open('newsletter.php','mywindow','width=400,height=400')" name="submit">

and there is a textfield named email on this page also
i want this field carried over to new open window but it does not work any sugggestions please?

hughie

2:50 pm on Dec 29, 2004 (gmt 0)

10+ Year Member



<INPUT TYPE="image" src="images/signup.gif" onClick="window.open('newsletter.php<?php echo '?id='.$id;?>','mywindow','width=400,height=400')" name="submit">

then on your newsletter.php page check for the variable $_REQUEST['id'];

if you want to pass several variables then your going to need to submit the form first or things could get messy.

Hope that helps,
hughie

[edited by: hughie at 2:53 pm (utc) on Dec. 29, 2004]

adamnichols45

2:52 pm on Dec 29, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



sorry i dont know where u are getting the id from? i have a text box called email i want this varible to be passed to the new window! cheers

Birdman

3:16 pm on Dec 29, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



He's probably getting id from your first post, as I did.

Let's step back for a moment. You want to submit a form to a new window, right? It may be better to use the form tag to do this:

<form method="post" action="search2.php" target="_blank" onsubmit="window.open('', 'processor_window', 'width=560,height=400'); this.target = 'processor_window'">

You should be able to access all the form elements' values using the $_POST['element_name'] method.

adamnichols45

3:24 pm on Dec 29, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



excellent stuff birdman thats exactly what i wanted. Thanks alot

hughie

5:47 pm on Dec 29, 2004 (gmt 0)

10+ Year Member



not concentrating here, too much turkey, ignore post ;-)

adamnichols45

6:15 pm on Dec 29, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



no thats fine i should have made my post less confusing error on my part cheers everyone