473,406 Members | 2,713 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

javascript help

65
if (confirm('Are%20you....'))%20window.location:'inde x.php'
why this code can not work?
May 11 '07 #1
8 1263
Purple
404 Expert 256MB
Hi Wish,

a very good question, I have another :)

can you post a little more so we can see what you are doing..

Purple
May 11 '07 #2
wish
65
if (confirm('Are%20you....'))%20window.location:'inde x.php'
why this code can not work?
my code is like this

<script>draw_button("delete","javascript:if(confir m('Are%20you%20want%20to%delete%20?'))%20window.lo cation:' index.php?modelid=1' ","","","","")</script>

if can modelid is refer to database model id...so i may use php script <?=$row['modelid']?>

but this code can not work
May 11 '07 #3
code green
1,726 Expert 1GB
Expand|Select|Wrap|Line Numbers
  1. <?=$row['modelid']?>
You need [PHP]$var = $_POST['modelid'];[/PHP]
May 11 '07 #4
Purple
404 Expert 256MB
Hi,

I think I am begining to understand a little better now.. If you are trying to use the value of $row['modelid'], change

[PHP]<?=$row['modelid']?>[/PHP]

to

[PHP]<?php echo $row['modelid']?> [/PHP]

if the javascript header redirect isn't happening, post again..
May 11 '07 #5
Purple
404 Expert 256MB
Hi,

can you also wrap the code in tags to make it easier to read - I was totally confused looking at your first post. But then thats not too difficult :)

Purple
May 11 '07 #6
Purple
404 Expert 256MB
Hi Wish,

have done a little more on this and again more questions - if you are still having issues with the redirect try this javascript code:

[PHP]function confirm_but()
{
if (confirm('Are you sure'))
{
alert('running redirect');
window.location='http://your/target/dir/file.php';
alert('after redirect');
}
}[/PHP]

fire with an onclick on the submit - if it fixes the problem great, if not, watch the bottom address bar as the 2nd alert is run.. is that showing the correct url for the redirect ?
May 11 '07 #7
code green
1,726 Expert 1GB
You are sending the variable via a URL[HTML] index.php?modelid=1' [/HTML] If you want to read this in index.php you need [PHP]$var = $_GET['modelid'];[/PHP]
Then [PHP]echo $var;[/PHP] should print 1
May 11 '07 #8
Purple
404 Expert 256MB
Hi Code Green - I am not convinced that is his problem

I have recreated and the redirect appears not to work - I think he has the form set to refresh itself on submit so the javascript redirect is being followed by the form refresh

Try the javascript function I posted and it ilustrates the problem better - I obviously caveat that with I have only tried it on IE7 :)
May 11 '07 #9

Sign in to post your reply or Sign up for a free account.

Similar topics

0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.