NamePros
Welcome, Guest! Ready to make a name for yourself in the domain business? We welcome both the hobbyist and professional domainer to join the discussion as part of the NamePros community.

Click here to create your profile to start earning reputation for posting, and trader ratings for buying & selling in our free e-marketplace. Build your trader rating with each successful sale. Our system has tracked over 100,000 sales and counting!
FAQ & TOS Register Search Today's Posts Mark Forums Read

Go Back   NamePros.com > Website Development Discussion Forums > Programming
Reload this Page JavaScript and PHP Help 50np reward

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

Advanced Search


Closed Thread
 
LinkBack Thread Tools
Old 12-19-2005, 02:40 PM THREAD STARTER               #1 (permalink)
Senior Member
 
-Ray-'s Avatar
Join Date: Jun 2005
Location: Pennsylvania
Posts: 1,839
-Ray- has much to be proud of-Ray- has much to be proud of-Ray- has much to be proud of-Ray- has much to be proud of-Ray- has much to be proud of-Ray- has much to be proud of-Ray- has much to be proud of-Ray- has much to be proud of-Ray- has much to be proud of
 



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..
????: NamePros.com http://www.namepros.com/programming/149527-javascript-and-php-help-50np-reward.html

Im rewarding 50NP to the one that provides a solution that works
__________________
Poker News, articles, discussion
LIKE THIS

Its an iPod, a phone, and an internet communications device.
-Ray- is offline  
Old 12-19-2005, 02:55 PM   #2 (permalink)
NamePros Regular
 
sjaguar13's Avatar
Join Date: Nov 2005
Posts: 383
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.
__________________
Theme Mine | LA Criminal Lawers |
sjaguar13 is offline  
Old 12-19-2005, 03:08 PM THREAD STARTER               #3 (permalink)
Senior Member
 
-Ray-'s Avatar
Join Date: Jun 2005
Location: Pennsylvania
Posts: 1,839
-Ray- has much to be proud of-Ray- has much to be proud of-Ray- has much to be proud of-Ray- has much to be proud of-Ray- has much to be proud of-Ray- has much to be proud of-Ray- has much to be proud of-Ray- has much to be proud of-Ray- has much to be proud of
 



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

and no usrname isnot a typo
__________________
Poker News, articles, discussion
LIKE THIS

Its an iPod, a phone, and an internet communications device.
-Ray- is offline  
Old 12-19-2005, 03:53 PM   #4 (permalink)
Senior Member
 
nasaboy007's Avatar
Join Date: Jul 2005
Location: NJ
Posts: 1,219
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 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, 04:00 PM   #5 (permalink)
NamePros Regular
 
sjaguar13's Avatar
Join Date: Nov 2005
Posts: 383
sjaguar13 has a spectacular aura aboutsjaguar13 has a spectacular aura about
 



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.

Originally Posted by nasaboy007
m not a javascript wiz, but doesnt this line:
????: NamePros.com http://www.namepros.com/showthread.php?t=149527

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.
__________________
Theme Mine | LA Criminal Lawers |
sjaguar13 is offline  
Old 12-20-2005, 01:34 AM   #6 (permalink)
Soon to be RICHdoggie!
 
PoorDoggie's Avatar
Join Date: Jan 2005
Location: UK
Posts: 2,408
PoorDoggie is just really nicePoorDoggie is just really nicePoorDoggie is just really nicePoorDoggie is just really nicePoorDoggie 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, 01:36 AM   #7 (permalink)
NamePros Member
Join Date: Dec 2005
Posts: 49
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, 01:46 AM   #8 (permalink)
Soon to be RICHdoggie!
 
PoorDoggie's Avatar
Join Date: Jan 2005
Location: UK
Posts: 2,408
PoorDoggie is just really nicePoorDoggie is just really nicePoorDoggie is just really nicePoorDoggie is just really nicePoorDoggie 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


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

Liquid Web Smart Servers  
All times are GMT -7. The time now is 07:27 AM.

Managed Web Hosting by Liquid Web
Domain name forum recommended by Domaining.com Powered by: vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.6.0 Ad Management plugin by RedTyger