Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > PHP/MySQL > PHP How-To
Password Reminder
Register
| FAQ | Members List | Search | Today's Posts | Mark Forums Read
PHP How-To Post your "How do I do this with PHP?" questions here.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the PHP How-To section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old November 25th, 2003, 09:54 PM
Authorized User
 
Join Date: Oct 2003
Location: kl, wp, Malaysia.
Posts: 10
Thanks: 0
Thanked 0 Times in 0 Posts
Default display return value of prompt box to php page

when the user clicked the second or third radio button, the prompt box will ask for the name. then the name is will be displayed on the text box when the ok button of the prompt box is clicked. However, I'm not able to display the value in the text box.

Please correct my code below.

<HTML>
<HEAD>
<script type="text/javascript">
function function1(){
var name = prompt("Please enter your name","")
if (name != null && name != "")
{
return name;
}
}
</script>
</HEAD>
<BODY>
<input type="radio" name="radio1" value="one" >one
<input type="radio" name="radio1" value="two" onclick="function1()">two
<input type="radio" name="radio1" value="three" onclick="function1()">three
<input type="hidden" name="hidden1" value="name">
</BODY>
</HTML>

Reply With Quote
  #2 (permalink)  
Old November 26th, 2003, 02:02 PM
Friend of Wrox
Points: 2,570, Level: 21
Points: 2,570, Level: 21 Points: 2,570, Level: 21 Points: 2,570, Level: 21
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: San Diego, CA, USA
Posts: 836
Thanks: 0
Thanked 0 Times in 0 Posts
Default

I don't see anywhere in your code where you'd display that name.

Notes:

1) function1() just returns the name entered in the checkbox.
2) function1() is ONLY called by your radio buttons onClick event, and nothing is done with the return value.


That means you're just throwing the value away -- you're not DOING anything with it.

Your hidden input field has a value of "name". That's just a string, "name". It's in no way related to the local variable you define within the scope of function1().

Perhaps you meant to do this:

function function1()
{
    var name = prompt("Please enter your name", "");
    if ((name != null) && (name != ""))
    {
        document.form1.hidden1.value = name;
    }
}


See the difference? You're actually DOING something with the value returned from the prompt box -- you're assigning the value property of the hidden1 object (which translates into the value attribute of the hidden1 element in HTML).

You need to wrap your form input elements in a <form name="form1"> tag for this to work.


You've been asking a lot of JavaScript questions lately -- remember that this is a PHP forum, so in the future you should direct your JavaScript questions to the appropriate forum -- there's several to choose from.


Take care,

Nik
http://www.bigaction.org/
Reply With Quote
  #3 (permalink)  
Old November 27th, 2003, 10:49 PM
Authorized User
 
Join Date: Oct 2003
Location: kl, wp, Malaysia.
Posts: 10
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thanks!it works.
Sorry for the trouble because i was new here and doesn't realize that there's a javascript forum.

Reply With Quote
  #4 (permalink)  
Old December 1st, 2003, 01:02 PM
Friend of Wrox
Points: 2,570, Level: 21
Points: 2,570, Level: 21 Points: 2,570, Level: 21 Points: 2,570, Level: 21
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: San Diego, CA, USA
Posts: 836
Thanks: 0
Thanked 0 Times in 0 Posts
Default

It's not a problem, I just think you'll get much better answers from the JS gurus in the other forums than you will from PHP gurus who dabble in JS when it suits us. =)


Take care,

Nik
http://www.bigaction.org/
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Count in combo box(display results in text box) mboyisis Access 4 April 4th, 2008 07:08 AM
Php page doest not display anything urtrivedi Beginning PHP 2 November 9th, 2007 02:38 AM
Closing page without prompt in IE7 gp_mk ASP.NET 1.0 and 1.1 Professional 2 November 22nd, 2006 10:29 AM
Input Box return value pakman Excel VBA 1 June 15th, 2005 04:29 AM
List box in prompt box hosefo81 Javascript How-To 3 December 8th, 2003 04:18 AM



All times are GMT -4. The time now is 07:29 AM.


Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.