[advanced search]
 

Go Back   NamePros.com > Discussion > Web Design & Development > Programming

Programming PHP, Perl, Ruby on Rails, AJAX, HTML, XHTML, CSS, JavaScript, MySQL and any other coding topics.


Closed Thread
 
LinkBack Thread Tools
Old 12-19-2005, 01:40 PM   #1 (permalink)
An American Soldier
 
-Ray-'s Avatar
 
Join Date: Jun 2005
Location: Pennsylvania
Posts: 1,630
2.53 NP$ (Donate)

-Ray- is a splendid one to behold-Ray- is a splendid one to behold-Ray- is a splendid one to behold-Ray- is a splendid one to behold-Ray- is a splendid one to behold-Ray- is a splendid one to behold-Ray- is a splendid one to behold-Ray- is a splendid one to behold


JavaScript and PHP Help 50np reward

What im doing is trying to take a username var from javascript and post it to a php document in an inline frame.

<
HTML Code:
form method="POST" action="edit.php" target="I2"><input type="hidden" name="usrname" value="javascript: document.getElementById('username').value">
<textarea rows="2" name="profile" cols="56"></textarea><br><input type="submit" value="Save Profile" name="B1"></form>
	<p>
	<iframe name="I2" width="294" height="28" src="edit.php" frameborder="0"></iframe> 
is that corrent, because it doesnt seem to be working write.. the php end of it works fine, as it is an onpost and has been tested with an html var..

Im rewarding 50NP to the one that provides a solution that works
__________________
Completely Free cPanel Hosting
-- Deployed to Afghanistan --
"There is no such thing as rich over-night unless you owned Google stock in 2006"
-Ray- is offline  
Old 12-19-2005, 01:55 PM   #2 (permalink)
NamePros Regular
 
sjaguar13's Avatar
 
Join Date: Nov 2005
Posts: 382
7.75 NP$ (Donate)

sjaguar13 has a spectacular aura aboutsjaguar13 has a spectacular aura about


Code:
<script language="javascript">
  var username = "Sjaguar13";

  function inputUsername(obj){
    obj.usrname.value = username;
       return true;
  }
</script>

<form method="POST" action="edit.php" target="I2" onSubmit="return inputUsername(this);">
<input type="hidden" name="usrname">
<textarea rows="2" name="profile" cols="56"></textarea>
<br>
<input type="submit" value="Save Profile" name="B1">
</form>

	<p>
	<iframe name="I2" width="294" height="28" src="edit.php" frameborder="0"></iframe>
The Username field is spelled usrname for the PHP. I don't know if that's a typo or not, but if the PHP has username coming up blank, make sure it's getting the field usrname and not username.
__________________
Tiny Atoms | Nonny's | VX8800.com
sjaguar13 is offline  
Old 12-19-2005, 02:08 PM   #3 (permalink)
An American Soldier
 
-Ray-'s Avatar
 
Join Date: Jun 2005
Location: Pennsylvania
Posts: 1,630
2.53 NP$ (Donate)

-Ray- is a splendid one to behold-Ray- is a splendid one to behold-Ray- is a splendid one to behold-Ray- is a splendid one to behold-Ray- is a splendid one to behold-Ray- is a splendid one to behold-Ray- is a splendid one to behold-Ray- is a splendid one to behold


well the script im using already has the username defined... should i still use the function input username?

and no usrname isnot a typo
__________________
Completely Free cPanel Hosting
-- Deployed to Afghanistan --
"There is no such thing as rich over-night unless you owned Google stock in 2006"
-Ray- is offline  
Old 12-19-2005, 02:53 PM   #4 (permalink)
Senior Member
 
nasaboy007's Avatar
 
Join Date: Jul 2005
Location: NJ
Posts: 1,112
1,454.30 NP$ (Donate)

nasaboy007 has much to be proud ofnasaboy007 has much to be proud ofnasaboy007 has much to be proud ofnasaboy007 has much to be proud ofnasaboy007 has much to be proud ofnasaboy007 has much to be proud ofnasaboy007 has much to be proud ofnasaboy007 has much to be proud of


im not a javascript wiz, but doesnt this line:

value="javascript: document.getElementById('username').value"

need a semicolon in there somewhere? compared to all other javascript, it needs semicolons.
nasaboy007 is offline  
Old 12-19-2005, 03:00 PM   #5 (permalink)
NamePros Regular
 
sjaguar13's Avatar
 
Join Date: Nov 2005
Posts: 382
7.75 NP$ (Donate)

sjaguar13 has a spectacular aura aboutsjaguar13 has a spectacular aura about


Quote:
Originally Posted by templaterave
well the script im using already has the username defined... should i still use the function input username?
Yes, you can put that function in the same script tags as the JavaScript that defines username.

Quote:
Originally Posted by nasaboy007
m not a javascript wiz, but doesnt this line:

value="javascript: document.getElementById('username').value"

need a semicolon in there somewhere? compared to all other javascript, it needs semicolons.
Inline JavaScript doesn't absolutely have to have a semicolon. It probably should, but not necessary (it works either way). The problem is inline JavaScript doesn't work in this situation. The value is taken as a literal and would submit the whole string to the php script.
__________________
Tiny Atoms | Nonny's | VX8800.com
sjaguar13 is offline  
Old 12-20-2005, 12:34 AM   #6 (permalink)
Soon to be RICHdoggie!
 
PoorDoggie's Avatar
 
Join Date: Jan 2005
Location: UK
Posts: 2,390
316.50 NP$ (Donate)

PoorDoggie is just really nicePoorDoggie is just really nicePoorDoggie is just really nicePoorDoggie is just really nice


Hi. Can I just ask:

- Is it completely necessary to use javascript? Cant you use PHP to store the variable?
- Is it completely necessary to use an iframe? That a) causes problems in browsers that don't support iframes and b) causes problems in your script.

I don't know what you are doing, but you could probably do a better job if you just used one language. Using two would be hard/complicated but trying to mix them is suicidal. There are always obstacles you could easilly get round if you just used one language.
PoorDoggie is offline  
Old 12-20-2005, 12:36 AM   #7 (permalink)
NamePros Member
 
Join Date: Dec 2005
Location: Eau Claire, WI
Posts: 46
313.45 NP$ (Donate)

cDizzle is an unknown quantity at this point


you should just use cookies, alot easier, and more secure.
cDizzle is offline  
Old 12-20-2005, 12:46 AM   #8 (permalink)
Soon to be RICHdoggie!
 
PoorDoggie's Avatar
 
Join Date: Jan 2005
Location: UK
Posts: 2,390
316.50 NP$ (Donate)

PoorDoggie is just really nicePoorDoggie is just really nicePoorDoggie is just really nicePoorDoggie is just really nice


Have you tried adding an "ID" att to the iframe?
HTML Code:
<iframe name="I2" id="I2" width="294" height="28" src="edit.php" frameborder="0"></iframe> 
That may make it work. I can't see any other problems with your code, but if you were to do it in php it would tell you what was wrong.
PoorDoggie is offline  
Closed Thread


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools

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 On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Great Scripts for Sale With Resale Rights! Zeeble Scripts For Sale 20 01-04-2006 01:39 AM
Javascript / PHP Question Zubair1 Programming 4 08-20-2005 08:55 AM
How would I intergrate Javascript with php -Ray- Programming 12 07-02-2005 12:10 AM
PHP & JavaScript D@Z Programming 0 02-20-2005 02:49 PM
How I fill javascript array with php variables? wiedzim CODE 0 03-31-2004 02:45 AM

Site Sponsors
Advertise your business at NamePros

All times are GMT -7. The time now is 07:52 PM.


Powered by: vBulletin® Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.3.0
Template-Modifications by TMS
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85