Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

PHP Forum


You are currently viewing our PHP Forum as a guest. Please register to participate.
Login



Freelance Jobs

Reply
need a little advice.
Old 08-14-2009, 06:56 PM need a little advice.
webznz's Avatar
Junior Talker

Posts: 2
Name: Casey Smith
Trades: 0
Hi there, im a uni student working on an assignment I have just been given, this is my first time using php. so far I have mostly programed in C, C++.
anyway I have been given this relatively simple assingment where i have an online personality test that someone might fill in and I am to generate a response depending on the data recived.

So far I have been able to pull the values from txt boxes etc fairly easy however im stuck on this function that has a loop generating 5 radio buttons per question, and there is about 20 questions, it looks like this :

HTML Code:
function writequestion(txt, qno)
{
  document.write("<li><b> ... " + txt + "</b><br>")
  document.write("Disagree")
  for (i=1; i<=5; i++) {
    document.write("&nbsp <input type=radio name=question[" + qno + "] value=" + i + ">" + i)
  }
  document.write("&nbsp Agree")
}

writequestion("is talkative", 1)
writequestion("does a thorough job", 2)
writequestion("is original, comes up with new ideas", 3)
writequestion("is helpful, unselfish with others", 4)
Im just woundering if someone can point me in the right direction with some suggestions on what variable i should be looking at capture and a general how too.. im not looking for a complete solution just somthing that can get me going in the right direction as I have been doing abit of research about value extraction from radio buttons but it all seems abit foregn.

thankyou in advance for any help you can offer.
__________________
I want to become a master programmer one day.
webznz is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 08-14-2009, 08:35 PM Re: need a little advice.
lizciz's Avatar
Webmaster Talker

Posts: 744
Name: Mattias Nordahl
Location: Sweden
Trades: 0
Just thought I'd point out that the code you presented seem to be JavaScript, not php.
__________________
34343639363436653237373432303635373837303635363337 34323037343638363137343263323036343639363432303739 366637353366
lizciz is offline
Reply With Quote
View Public Profile Visit lizciz's homepage!
 
Old 08-14-2009, 08:51 PM Re: need a little advice.
webznz's Avatar
Junior Talker

Posts: 2
Name: Casey Smith
Trades: 0
yea, its a javascript function in which im meant to capture the input from the user.
Im meant to be able to capture and display the results with my php code.

I hope that makes sense, im still fairly new at all this but thus far in my assignment I have been capturing text boxes and check boxes with my server side php script that then produces results to the client.
__________________
I want to become a master programmer one day.
webznz is offline
Reply With Quote
View Public Profile
 
Old 08-14-2009, 10:54 PM Re: need a little advice.
NullPointer's Avatar
Will Code for Food

Posts: 2,784
Name: Matt
Location: Irvine, CA
Trades: 0
Before I try to answer your question, is there any particular reason you are using javascript to generate your form? If you're going to be using PHP you might as well generate it server side and just send the HTML code to the user:

PHP Code:
function writeQuestion($txt$qno)
{
     echo 
"<li><b> ... $txt </b><br>";
     echo 
'Disagree';
     for (
$i=1$i<=5$i++) {
          echo 
"<input type=\"radio\" name=\"question[$qno]\" value=\"$i\"> $i";
     }
     echo 
'Agree';
}

writeQuestion("is talkative"1);
writeQuestion("does a thorough job"2);
writeQuestion("is original, comes up with new ideas"3);
writeQuestion("is helpful, unselfish with others"4); 
When you retrieve the form data you'll do so using the $_POST array. PHP identifies form elements by the name attribute:

PHP Code:
$questions $_POST['question']; 
In this case $questions is an array of all of the values associated with each question, in order.
__________________

Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE

Last edited by NullPointer; 08-14-2009 at 10:55 PM..
NullPointer is online now
Reply With Quote
View Public Profile Visit NullPointer's homepage!
 
Reply     « Reply to need a little advice.
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

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 Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.81137 seconds with 12 queries