开发者

Check for duplicates and submit

EDIT: I am using Code Igniter: www.codeigniter.com

So I'm new to web developem开发者_C百科ent and programming in general and I've been playing around with PHP and started developing a little website and i want to make it easier for users to submit.

I have 9 radio buttons (oh and I'm using code igniter)

    <?php
    echo form_radio('name1', '3')." 3 ";
    echo form_radio('name1', '2')." 2 ";
    echo form_radio('name1', '1')." 1 ";
    echo form_radio('name2', '3')." 3 ";
    echo form_radio('name2', '2')." 2 ";
    echo form_radio('name2', '1')." 1 ";
    echo form_radio('name3', '3')." 3 ";
    echo form_radio('name3', '2')." 2 ";
    echo form_radio('name3', '1')." 1 ";
    $submit = Array ("name" => 'submit', "value" => 'Submit', "class" => "g-button large");
    echo form_submit($submit);
    echo form_close();
    ?>

So i want something to check for duplicates and display an error (preferable a div) without reloading the page and i would also like the form to submit without the submit button (for example hotornot.com but with 3 sets of radio buttons).

I understand this needs jQuery and possibly AJAX (?) and i'm completely clueless with them both. And also i saw this: http://jquery.malsup.com/form/ and i tried tinkering with it but i had nfi what i was doing.


You don't need to use every helper in CI; I wouldn't use form helper, at least for the radio buttons as you'll need to include onClick event handler into radio button html code:

<input type="radio" name="name1" value="3" onclick="set_info('send_something')" />
<div id="info">&nbsp;</info>

this part should be put between tags in your html code, above radio buttons of course:

<script type="text/javascript">
set_info=function(send_something){
$('#info').html(send_something);
}
</script>

the last one includes jQuery code of course and you sould include it too:

<script type="text/javascipt" src="jquery.js"></script>

I hope that this code snippets give you more than basic idea where your coding should go for this case.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜