2013-10-12 1 views
0

Как я могу добавить разные результаты к этой викторине в зависимости от выбора переключателей людей? Вот викторина:Как я могу добавить результаты к этой викторине?

<html> 
<head></head> 
<body> 
<h1></h1> 
<form> 
<ol> 
<li> How much are you willing to spend on a phone per month?</li> 
<ul> 
<li> <input type = "radio" name = "q1"> £5-£10.</input></li> 
<li> <input type = "radio" name = "q1"> £10-£15.</input></li> 
<li> <input type = "radio" name = "q1"> £15-£20.</input></li> 
<li> <input type = "radio" name = "q1"> £20-£25.</input></li> 
<li> <input type = "radio" name = "q1"> £25-£30.</input></li> 
<li> <input type = "radio" name = "q1"> £30-£35.</input></li> 
<li> <input type = "radio" name = "q1"> £35-£40.</input></li> 
</ul> 
<li> Are you good with technology?</li> 
<ul> 
<li> <input type = "radio" name = "q2"> Yes.</input></li> 
<li> <input type = "radio" name = "q2"> No.</input></li> 
</ul> 
<li> Are you looking for an easy to use phone?</li> 
<ul> 
<li> <input type = "radio" name = "q3"> Yes.</input></li> 
<li> <input type = "radio" name = "q3"> No.</input></li> 
</ul> 
<li> Are you looking for a modern type of phone?</li> 
<ul> 
<li> <input type = "radio" name = "q4"> Yes.</input></li> 
<li> <input type = "radio" name = "q4"> No.</input></li> 
</ul> 
<li> How big do you want the phone to be?</li> 
<ul> 
<li> <input type = "radio" name = "q5"> Big.</input></li> 
<li> <input type = "radio" name = "q5"> Medium.</input></li> 
<li> <input type = "radio" name = "q5"> Small.</input></li> 
<li> <input type = "radio" name = "q5"> I don't really mind.</input></li> 
</ul> 
<li> Do you care about the colour of the phone?</li> 
<ul> 
<li> <input type = "radio" name = "q6"> Yes.</input></li> 
<li> <input type = "radio" name = "q6"> No.</input></li> 
</ul> 
<li> Have you ever owned a phone before?</li> 
<ul> 
<li> <input type = "radio" name = "q7"> Yes.</input></li> 
<li> <input type = "radio" name = "q7"> No.</input></li> 
</ul> 
<li> Do you want to be able to use the phone to get out of awkward social situations?</li> 
<ul> 
<li> <input type = "radio" name = "q8"> Yes.</input></li> 
<li> <input type = "radio" name = "q8"> No.</input></li> 
</ul> 
<li> Do you want to be able to access an app store and download apps using your phone?</li> 
<ul> 
<li> <input type = "radio" name = "q9"> Yes.</input></li> 
<li> <input type = "radio" name = "q9"> No.</input></li> 
</ul> 
<li> What happened to the last phone you owned?</li> 
<ul> 
<li> <input type = "radio" name = "q10"> I got bored of it.</input></li> 
<li> <input type = "radio" name = "q10"> It broke(I'm clumsy).</input></li> 
<li> <input type = "radio" name = "q10"> It broke.</input></li> 
<li> <input type = "radio" name = "q10"> The contract ran out.</input></li> 
<li> <input type = "radio" name = "q10"> Other.</input></li> 
</ul> 
</ol> 
<input type = "button" value = "Submit"></input> <input type = "reset" value = "Clear"></input> 
<textarea>The right phone for you will be displayed here.</textarea> 



</html> 

Является ли то, что я пытаюсь сделать возможным? Я пытался найти ответ на этот вопрос целую вечность. Если вы знаете, как я могу делать то, что я описал, скажите. Спасибо за прочтение.

+1

, который открывает другой файл php. – KarlosFontana

+1

в process.php вы можете получить опубликованные данные и добавить результаты togehter. – KarlosFontana

+0

Это что-то в этом html, которое должно быть скрыто и просто показано в зависимости от выбора пользователя, или вы хотите загрузить новый контент? – Sergio

ответ

3

Используйте javascript для извлечения информации из html, затем получите сумму. Вы можете использовать jquery/ajax для этого, не отправляя страницу.

BTW, что значит добавить результат из викторины?

Обновлено 10/13/2013

Использование JavaScript себя и сделать это в веб-интерфейсе.

Во-первых, изменить каждый переключатель, чтобы:

<li><input type = "radio" id = "q1" value="5-10" name = "q1"> £5-£10.</input></li> 

и используя JDOM, чтобы получить значение

var name = document.getElementById('q1').value;//name will equal to "5-10" 

после вы получите все значения параметров, вы можете делать все, что вы хотите в логике Надежда помогает.

+0

Когда я говорю «добавить результаты», я имею в виду, что кто-то выбирает первый переключатель на каждом вопросе, который может получить iPhone в качестве результата. –

+0

@KeonDavies. Согласно тому, что вы объяснили, есть два способа сделать это. – SCV

+0

Один из них просто использует javascript, чтобы сделать это в интерфейсе, другой использует отправку формы на бэкэнд, а затем использует PHP/ASP/Ruby любой код, чтобы получить результат и отправить обратно на передний конец. – SCV

Смежные вопросы